@@ -22,7 +22,7 @@ class _App extends StatelessWidget {
2222 @override
2323 Widget build (BuildContext context) {
2424 return DefaultTabController (
25- length: 7 ,
25+ length: 9 ,
2626 child: Scaffold (
2727 key: const ValueKey <String >('home_page' ),
2828 appBar: AppBar (
@@ -37,6 +37,8 @@ class _App extends StatelessWidget {
3737 Tab (icon: Icon (Icons .cloud), text: 'DRM PlayReady' ),
3838 Tab (icon: Icon (Icons .cloud), text: 'Track' ),
3939 Tab (icon: Icon (Icons .cloud), text: 'Asset' ),
40+ Tab (icon: Icon (Icons .live_tv), text: 'Live' ),
41+ Tab (icon: Icon (Icons .local_florist), text: 'ChangeURLTest' ),
4042 ],
4143 ),
4244 ),
@@ -49,6 +51,8 @@ class _App extends StatelessWidget {
4951 _DrmRemoteVideo2 (),
5052 _TrackTest (),
5153 _AssetVideo (),
54+ _LiveRemoteVideo (),
55+ _TestRemoteVideo (),
5256 ],
5357 ),
5458 ),
@@ -748,3 +752,142 @@ class _GetTextTrackButton extends StatelessWidget {
748752 );
749753 }
750754}
755+
756+ class _LiveRemoteVideo extends StatefulWidget {
757+ @override
758+ State <_LiveRemoteVideo > createState () => _LiveRomoteVideoState ();
759+ }
760+
761+ class _LiveRomoteVideoState extends State <_LiveRemoteVideo > {
762+ late VideoPlayerController _controller;
763+
764+ @override
765+ void initState () {
766+ super .initState ();
767+ _controller = VideoPlayerController .network (
768+ 'https://hlive.ktv.go.kr/live/klive_h.stream/playlist.m3u8' ,
769+ );
770+
771+ _controller.addListener (() {
772+ if (_controller.value.hasError) {
773+ print (_controller.value.errorDescription);
774+ }
775+ setState (() {});
776+ });
777+ _controller.setLooping (true );
778+ _controller.initialize ().then ((_) => setState (() {}));
779+ _controller.play ();
780+ }
781+
782+ @override
783+ void dispose () {
784+ _controller.dispose ();
785+ super .dispose ();
786+ }
787+
788+ @override
789+ Widget build (BuildContext context) {
790+ return SingleChildScrollView (
791+ child: Column (
792+ children: < Widget > [
793+ Container (padding: const EdgeInsets .only (top: 20.0 )),
794+ const Text ('Playing Live TV' ),
795+ Container (
796+ padding: const EdgeInsets .all (20 ),
797+ child: AspectRatio (
798+ aspectRatio: _controller.value.aspectRatio,
799+ child: Stack (
800+ alignment: Alignment .bottomCenter,
801+ children: < Widget > [
802+ VideoPlayer (_controller),
803+ ClosedCaption (text: _controller.value.caption.text),
804+ _ControlsOverlay (controller: _controller),
805+ VideoProgressIndicator (_controller, allowScrubbing: true ),
806+ ],
807+ ),
808+ ),
809+ ),
810+ ],
811+ ),
812+ );
813+ }
814+ }
815+
816+ class _TestRemoteVideo extends StatefulWidget {
817+ @override
818+ State <_TestRemoteVideo > createState () => _TestRemoteVideoState ();
819+ }
820+
821+ class _TestRemoteVideoState extends State <_TestRemoteVideo > {
822+ late VideoPlayerController _controller;
823+
824+ @override
825+ void initState () {
826+ super .initState ();
827+ _controller = VideoPlayerController .network (
828+ 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8' ,
829+ );
830+
831+ _controller.addListener (() {
832+ if (_controller.value.hasError) {
833+ print (_controller.value.errorDescription);
834+ }
835+ setState (() {});
836+ });
837+ _controller.setLooping (true );
838+ _controller.initialize ().then ((_) => setState (() {}));
839+ _controller.play ();
840+ _controller.setRestoreData (
841+ restoreDataSource: restoreDataSource,
842+ resumeTime: restoreTime,
843+ );
844+ }
845+
846+ @override
847+ void dispose () {
848+ _controller.dispose ();
849+ super .dispose ();
850+ }
851+
852+ DataSource restoreDataSource () {
853+ final DataSource dataSource = DataSource (
854+ sourceType: DataSourceType .network,
855+ uri: 'https://media.w3.org/2010/05/bunny/trailer.mp4' ,
856+ );
857+ return dataSource;
858+ }
859+
860+ int restoreTime () {
861+ /// if resumeTime >= 0 , it will restore from resumeTime
862+ /// if resumeTime is not set or <0, it will restore from the time when suspend is called
863+ const int resumeTime = 0 ;
864+ return resumeTime;
865+ }
866+
867+ @override
868+ Widget build (BuildContext context) {
869+ return SingleChildScrollView (
870+ child: Column (
871+ children: < Widget > [
872+ Container (padding: const EdgeInsets .only (top: 20.0 )),
873+ const Text ('ChangeURLTest' ),
874+ Container (
875+ padding: const EdgeInsets .all (20 ),
876+ child: AspectRatio (
877+ aspectRatio: _controller.value.aspectRatio,
878+ child: Stack (
879+ alignment: Alignment .bottomCenter,
880+ children: < Widget > [
881+ VideoPlayer (_controller),
882+ ClosedCaption (text: _controller.value.caption.text),
883+ _ControlsOverlay (controller: _controller),
884+ VideoProgressIndicator (_controller, allowScrubbing: true ),
885+ ],
886+ ),
887+ ),
888+ ),
889+ ],
890+ ),
891+ );
892+ }
893+ }
0 commit comments