Skip to content

Commit

Permalink
Feature/february changes 3 (#274)
Browse files Browse the repository at this point in the history
* Fixed lint issues

* Fixed subtitles setup issue

Co-authored-by: jhomlala <j.homlala@gmail.com>
  • Loading branch information
jhomlala and jhomlala authored Feb 6, 2021
1 parent ef134c7 commit c68c7ef
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.51
* Fixed lint issues.
* Fixed subtitles setup issue.

## 0.0.50
* Fixed deprecated resizeToAvoidBottomPadding
* Fixed playing large videos in iOS.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This plugin is based on [Chewie](https://github.com/brianegan/chewie). Chewie is

```yaml
dependencies:
better_player: ^0.0.50
better_player: ^0.0.51
```
2. Install it
Expand Down
28 changes: 12 additions & 16 deletions lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,20 @@ class BetterPlayerController extends ChangeNotifier {

if (_isDataSourceHls(betterPlayerDataSource)) {
_setupHlsDataSource().then((dynamic value) {
_betterPlayerSubtitlesSourceList.add(
BetterPlayerSubtitlesSource(
type: BetterPlayerSubtitlesSourceType.none),
);
_setupSubtitles();
});
} else {
_betterPlayerSubtitlesSourceList.add(
BetterPlayerSubtitlesSource(type: BetterPlayerSubtitlesSourceType.none),
);
_setupSubtitles();
}

///Process data source
await _setupDataSource(betterPlayerDataSource);
}

void _setupSubtitles() {
_betterPlayerSubtitlesSourceList.add(
BetterPlayerSubtitlesSource(type: BetterPlayerSubtitlesSourceType.none),
);
final defaultSubtitle = _betterPlayerSubtitlesSourceList.firstWhere(
(element) => element.selectedByDefault == true,
orElse: () => null);
Expand All @@ -257,10 +257,10 @@ class BetterPlayerController extends ChangeNotifier {

bool _isDataSourceHls(BetterPlayerDataSource betterPlayerDataSource) =>
betterPlayerDataSource.url.contains(_hlsExtension) ||
betterPlayerDataSource.videoFormat == VideoFormat.hls;
betterPlayerDataSource.videoFormat == BetterPlayerVideoFormat.hls;

Future _setupHlsDataSource() async {
String hlsData =
final String hlsData =
await BetterPlayerHlsUtils.getDataFromUrl(betterPlayerDataSource.url);
if (hlsData != null) {
/// Load hls tracks
Expand Down Expand Up @@ -662,9 +662,7 @@ class BetterPlayerController extends ChangeNotifier {
.playerVisibilityChangedBehavior(visibilityFraction);
} else {
if (visibilityFraction == 0) {
if (_wasPlayingBeforePause == null) {
_wasPlayingBeforePause = isPlaying();
}
_wasPlayingBeforePause ??= isPlaying();
pause();
} else {
if (_wasPlayingBeforePause == true && !isPlaying()) {
Expand Down Expand Up @@ -735,9 +733,7 @@ class BetterPlayerController extends ChangeNotifier {
}
}
if (appLifecycleState == AppLifecycleState.paused) {
if (_wasPlayingBeforePause == null) {
_wasPlayingBeforePause = isPlaying();
}
_wasPlayingBeforePause ??= isPlaying();
pause();
}
}
Expand Down Expand Up @@ -831,7 +827,7 @@ class BetterPlayerController extends ChangeNotifier {
_postEvent(BetterPlayerEvent(BetterPlayerEventType.seekTo));
break;
case VideoEventType.completed:
final videoValue = await videoPlayerController.value;
final videoValue = videoPlayerController.value;
_postEvent(
BetterPlayerEvent(
BetterPlayerEventType.finished,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/hls/better_player_hls_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ class BetterPlayerHlsUtils {
String data, String masterPlaylistUrl) async {
assert(data != null, "Data can't be null");
assert(masterPlaylistUrl != null, "MasterPlaylistUrl can't be null");
List<BetterPlayerHlsAudioTrack> audios = [];
final List<BetterPlayerHlsAudioTrack> audios = [];
final parsedPlaylist = await HlsPlaylistParser.create()
.parseString(Uri.parse(masterPlaylistUrl), data);
final hlsMasterPlaylist = parsedPlaylist as HlsMasterPlaylist;

for (int index = 0; index < hlsMasterPlaylist.audios.length; index++) {
Rendition audio = hlsMasterPlaylist.audios[index];
final Rendition audio = hlsMasterPlaylist.audios[index];
audios.add(BetterPlayerHlsAudioTrack(
id: index,
label: audio.name,
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.50
version: 0.0.51
authors:
- Jakub Homlala <jhomlala@gmail.com>
homepage: https://github.com/jhomlala/betterplayer
Expand Down

0 comments on commit c68c7ef

Please sign in to comment.