forked from jhomlala/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.
Feature/memory player (jhomlala#134)
* Memory player implementation * Added factories for DataSource * Refactored data sources * Fixed placeholder showing after full screen when using showPlaceholderUntilPlay * Added setControlsVisibility to BetterPlayerController * Removed showControlsOnInitialize from BetterPlayerConfiguration * Fixed cupertino controls issue with hasError * Dartfmt
- Loading branch information
Showing
16 changed files
with
428 additions
and
30 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
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
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,72 @@ | ||
import 'package:better_player/better_player.dart'; | ||
import 'package:better_player_example/constants.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class ControllerControlsPage extends StatefulWidget { | ||
@override | ||
_ControllerControlsPageState createState() => _ControllerControlsPageState(); | ||
} | ||
|
||
class _ControllerControlsPageState extends State<ControllerControlsPage> { | ||
BetterPlayerController _betterPlayerController; | ||
|
||
@override | ||
void initState() { | ||
BetterPlayerConfiguration betterPlayerConfiguration = | ||
BetterPlayerConfiguration( | ||
aspectRatio: 16 / 9, | ||
fit: BoxFit.contain, | ||
); | ||
BetterPlayerDataSource dataSource = BetterPlayerDataSource( | ||
BetterPlayerDataSourceType.NETWORK, Constants.elephantDreamVideoUrl); | ||
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration); | ||
_betterPlayerController.setupDataSource(dataSource); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("Controller controls page"), | ||
), | ||
body: Column( | ||
children: [ | ||
const SizedBox(height: 8), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 16), | ||
child: Text( | ||
"Control player with BetterPlayerController", | ||
style: TextStyle(fontSize: 16), | ||
), | ||
), | ||
AspectRatio( | ||
aspectRatio: 16 / 9, | ||
child: BetterPlayer(controller: _betterPlayerController), | ||
), | ||
Wrap( | ||
children: [ | ||
FlatButton( | ||
child: Text("Play"), onPressed: _betterPlayerController.play), | ||
FlatButton( | ||
child: Text("Pause"), | ||
onPressed: _betterPlayerController.pause), | ||
FlatButton( | ||
child: Text("Hide controls"), | ||
onPressed: () { | ||
_betterPlayerController.setControlsVisibility(false); | ||
}, | ||
), | ||
FlatButton( | ||
child: Text("Show controls"), | ||
onPressed: () { | ||
_betterPlayerController.setControlsVisibility(true); | ||
}, | ||
), | ||
], | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
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,62 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:better_player/better_player.dart'; | ||
import 'package:better_player_example/constants.dart'; | ||
import 'package:better_player_example/utils.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class MemoryPlayerPage extends StatefulWidget { | ||
@override | ||
_MemoryPlayerPageState createState() => _MemoryPlayerPageState(); | ||
} | ||
|
||
class _MemoryPlayerPageState extends State<MemoryPlayerPage> { | ||
BetterPlayerController _betterPlayerController; | ||
|
||
@override | ||
void initState() { | ||
BetterPlayerConfiguration betterPlayerConfiguration = | ||
BetterPlayerConfiguration( | ||
aspectRatio: 16 / 9, | ||
fit: BoxFit.contain, | ||
); | ||
|
||
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration); | ||
_setupDataSource(); | ||
super.initState(); | ||
} | ||
|
||
void _setupDataSource() async { | ||
var filePath = await Utils.getFileUrl(Constants.fileTestVideoUrl); | ||
File file = File(filePath); | ||
|
||
List<int> bytes = file.readAsBytesSync().buffer.asUint8List(); | ||
BetterPlayerDataSource dataSource = BetterPlayerDataSource.memory(bytes); | ||
_betterPlayerController.setupDataSource(dataSource); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("Memory player"), | ||
), | ||
body: Column( | ||
children: [ | ||
const SizedBox(height: 8), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 16), | ||
child: Text( | ||
"Memory player with plays video from bytes.", | ||
style: TextStyle(fontSize: 16), | ||
), | ||
), | ||
AspectRatio( | ||
aspectRatio: 16 / 9, | ||
child: BetterPlayer(controller: _betterPlayerController), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
///Source types of video. Network type is used for videos that are hosted on | ||
///the web service. File type is used for videos that will be read from | ||
/// mobile device. | ||
enum BetterPlayerDataSourceType { NETWORK, FILE } | ||
enum BetterPlayerDataSourceType { NETWORK, FILE, MEMORY } |
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
Oops, something went wrong.