forked from matthewrice345/betterplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed dispose issue when user disposes controller manually
- Loading branch information
1 parent
64e1252
commit b2b6524
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:better_player/better_player.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class OtherPage extends StatefulWidget { | ||
@override | ||
_OtherPageState createState() => _OtherPageState(); | ||
} | ||
|
||
class _OtherPageState extends State<OtherPage> { | ||
BetterPlayerController _betterPlayerController; | ||
|
||
@override | ||
void initState() { | ||
var dataSource = BetterPlayerDataSource( | ||
BetterPlayerDataSourceType.NETWORK, | ||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", | ||
subtitles: BetterPlayerSubtitlesSource( | ||
type: BetterPlayerSubtitlesSourceType.NETWORK, | ||
url: | ||
"https://dl.dropboxusercontent.com/s/71nzjo2ux3evxqk/example_subtitles.srt", | ||
), | ||
); | ||
|
||
_betterPlayerController = BetterPlayerController( | ||
BetterPlayerConfiguration( | ||
controlsConfiguration: | ||
BetterPlayerControlsConfiguration(enableProgressText: true), | ||
), | ||
betterPlayerDataSource: dataSource); | ||
_betterPlayerController.addEventsListener((event) { | ||
print("Better player event: ${event.betterPlayerEventType}"); | ||
}); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("Other page"), | ||
), | ||
body: AspectRatio( | ||
aspectRatio: 16 / 9, | ||
child: BetterPlayer(controller: _betterPlayerController), | ||
)); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_betterPlayerController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
} |