Skip to content

Commit

Permalink
Feature/november changes 2 (#145)
Browse files Browse the repository at this point in the history
* iOS black frame issue fix

* Fixed full screen placeholder issue

* Fixed event not firing in enterFullScreen and exitFullScreen

* Fixed subtitles parsing

* Better Player 0.0.35

Co-authored-by: jhomlala <[email protected]>
  • Loading branch information
jhomlala and jhomlala authored Nov 21, 2020
1 parent 943798b commit b07dcaf
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.0.35
* Fixed iOS black screen issue
* Fixed full screen placeholder issue
* Fixed event not firing in enterFullScreen and exitFullScreen
* Fixed subtitles parsing issues


## 0.0.34
* Added memory data source
* Added factories: network, file, memory for BetterPlayerDataSource
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This plugin is based on [Chewie](https://github.com/brianegan/chewie). Chewie is

```yaml
dependencies:
better_player: ^0.0.34
better_player: ^0.0.35
```
2. Install it
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/subtitles_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _SubtitlesPageState extends State<SubtitlesPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Normal player"),
title: Text("Subtitles"),
),
body: Column(children: [
const SizedBox(height: 8),
Expand Down
5 changes: 3 additions & 2 deletions ios/Classes/FLTBetterPlayerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,11 @@ - (CVPixelBufferRef)prevTransparentBuffer {
}

- (CVPixelBufferRef)copyPixelBuffer {
if (!_videoOutput || !_isInitialized || !_isPlaying || !_key || ![_player currentItem] ||
//Disabled because of black frame issue
/*if (!_videoOutput || !_isInitialized || !_isPlaying || !_key || ![_player currentItem] ||
![[_player currentItem] isPlaybackLikelyToKeepUp]) {
return [self prevTransparentBuffer];
}
}*/

CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()];
if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,13 @@ class BetterPlayerController extends ChangeNotifier {

void enterFullScreen() {
_isFullScreen = true;
_postEvent(BetterPlayerEvent(BetterPlayerEventType.OPEN_FULLSCREEN));
notifyListeners();
}

void exitFullScreen() {
_isFullScreen = false;
_postEvent(BetterPlayerEvent(BetterPlayerEventType.HIDE_FULLSCREEN));
notifyListeners();
}

Expand All @@ -308,7 +310,6 @@ class BetterPlayerController extends ChangeNotifier {
Future<void> play() async {
await videoPlayerController.play();
_hasCurrentDataSourceStarted = true;
notifyListeners();
_postEvent(BetterPlayerEvent(BetterPlayerEventType.PLAY));
}

Expand Down
32 changes: 19 additions & 13 deletions lib/src/core/better_player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,33 @@ class _BetterPlayerVideoFitWidgetState
}

void _initialize() {
_initializedListener = () {
if (!mounted) {
return;
}
if (_initialized != controller.value.initialized) {
_initialized = controller.value.initialized;
setState(() {});
}
widget.betterPlayerController.addListener(() {
if (controller?.value?.initialized == false) {
_initializedListener = () {
if (!mounted) {
return;
}

if (_initialized != controller.value.initialized) {
_initialized = controller.value.initialized;
setState(() {});
}
};
controller.addListener(_initializedListener);
} else {
_initialized = true;
}
widget.betterPlayerController.addEventsListener((event) {
if (event.betterPlayerEventType == BetterPlayerEventType.PLAY) {
if (widget.betterPlayerController.betterPlayerConfiguration
.showPlaceholderUntilPlay &&
!_started) {
setState(() {
_started =
widget.betterPlayerController.hasCurrentDataSourceStarted;
print("STARTED:" + _started.toString());
});
}
});
};
controller.addListener(_initializedListener);
}
});
}

@override
Expand Down
26 changes: 19 additions & 7 deletions lib/src/subtitles/better_player_subtitle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class BetterPlayerSubtitle {
if (scanner[0].isEmpty) {
scanner.removeAt(0);
}
final index = int.parse(scanner[0]);

final index = int.tryParse(scanner[0]);

var timeSplit = scanner[1].split(timerSeparator);
final start = _stringToDuration(timeSplit[0]);
Expand All @@ -71,7 +72,16 @@ class BetterPlayerSubtitle {
static Duration _stringToDuration(String value) {
assert(value != null);
try {
final component = value.split(':');
final valueSplit = value.split(" ");
String componentValue;

if (valueSplit.length > 1) {
componentValue = valueSplit[0];
} else {
componentValue = value;
}

final component = componentValue.split(':');
if (component.length != 3) {
return Duration();
}
Expand All @@ -81,11 +91,13 @@ class BetterPlayerSubtitle {
if (secsAndMillsSplit.length != 2) {
return Duration();
}
return Duration(
hours: int.parse(component[0]),
minutes: int.parse(component[1]),
seconds: int.parse(secsAndMillsSplit[0]),
milliseconds: int.parse(secsAndMillsSplit[1]));

var result = Duration(
hours: int.tryParse(component[0]),
minutes: int.tryParse(component[1]),
seconds: int.tryParse(secsAndMillsSplit[0]),
milliseconds: int.tryParse(secsAndMillsSplit[1]));
return result;
} catch (exception) {
print("Failed to process value: $value");
return Duration();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: better_player
description: Advanced video player based on video_player and Chewie. It's solves many typical use cases and it's easy to run.
version: 0.0.34
version: 0.0.35
authors:
- Jakub Homlala <[email protected]>
homepage: https://github.com/jhomlala/betterplayer
Expand Down

0 comments on commit b07dcaf

Please sign in to comment.