-
[Flutter] YouTube playerFlutter ํ ํฌ 2022. 8. 25. 01:20
1. ํจํค์ง ๋ค์ด๋ก๋
youtube_player_flutter: ^8.0.0
(https://pub.dev/packages/youtube_player_flutter)
2. android ์ค์ (iOS๋ ์ถ๊ฐ์ ์ธ ์ค์ X)
minSdkVersion -> 17๋ก ์ค์ (android/app/build.gradle)
3. ํ์ผ ์์ฑ ํ ์ ์ฉ
import 'package:youtube_player_flutter/youtube_player_flutter.dart' as youtube; class YoutubePlayer extends StatefulWidget { @override YoutubePlayerState createState() => YoutubePlayerState(); } class YoutubePlayerState extends State<YoutubePlayer> { late youtube.YoutubePlayerController _controller; @override void initState() { _controller = youtube.YoutubePlayerController( initialVideoId: makeVideoId(), flags: const youtube.YoutubePlayerFlags( mute: false, autoPlay: true, disableDragSeek: false, loop: false, isLive: false, forceHD: false, enableCaption: true, ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( 'youtube player', style: TextStyle(fontSize: 20.0), ), ), body: youtube.YoutubePlayer( key: ObjectKey(_controller), controller: _controller, actionsPadding: const EdgeInsets.only(left: 16.0), bottomActions: [ youtube.CurrentPosition(), const SizedBox(width: 10.0), youtube.ProgressBar(isExpanded: true), const SizedBox(width: 10.0), youtube.RemainingDuration(), ], ), ); } makeVideoId() { String videoId = ""; videoId = youtube.YoutubePlayer.convertUrlToId("youtube URL")!; return videoId.toString(); } }
'Flutter ํ ํฌ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Flutter Fastlane CI/CD(2) - Android (1) 2023.03.07 Flutter Fastlane CI/CD(1) - iOS (0) 2023.03.07 [Flutter] host platform ๊ตฌ๋ณ (Web, Phone) (0) 2022.07.26 [Flutter] ๊ฒ์๊ธ ๊ธฐ๋ฅ์ ํ์ํ ํจ์๋ค(Firestore์ฌ์ฉ) (0) 2022.07.22 [Flutter] ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ๋ ํ ์คํธ ์ธ์, ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ ๋ฐ ํ์ฉ (0) 2022.07.12