Skip to content

Commit

Permalink
Feature/january changes 6 (#245)
Browse files Browse the repository at this point in the history
* Added fix for loading large videos

* Added fix for loading large videos

* Fixed partly progress bar jumping when seek issue in iOS

* Added forceDispose parameter to dispose method in BetterPlayerController.

* Better Player 0.0.48
  • Loading branch information
jhomlala authored Jan 23, 2021
1 parent a3d6bdc commit b4a510c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.48
* Fixed loading large videos in iOS.
* Fixed partly progress bar jumping when seek issue in iOS.
* Added forceDispose parameter to dispose method in BetterPlayerController.
* Fixed Android notification vibration issue (fixed by https://github.com/marcusforsberg).

## 0.0.47
* Fixed Android loading indicator issue.
* Added setControlsAlwaysVisible in BetterPlayerController.
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.47
better_player: ^0.0.48
```
2. Install it
Expand Down
25 changes: 22 additions & 3 deletions ios/Classes/FLTBetterPlayerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ - (instancetype)initWithFrameUpdater:(FLTFrameUpdater*)frameUpdater {
_disposed = false;
_player = [[AVPlayer alloc] init];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

///Fix for loading large videos
if (@available(iOS 10.0, *)) {
_player.automaticallyWaitsToMinimizeStalling = false;
}
_displayLink = [CADisplayLink displayLinkWithTarget:frameUpdater
selector:@selector(onDisplayLink:)];
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
Expand Down Expand Up @@ -117,7 +122,8 @@ - (void)addObservers:(AVPlayerItem*)item {
selector:@selector(itemDidPlayToEndTime:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:item];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStalled:) name:AVPlayerItemPlaybackStalledNotification object:item ];
///Currently disabled, because it leads to unexpected problems
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStalled:) name:AVPlayerItemPlaybackStalledNotification object:item ];
self._observersAdded = true;
}
}
Expand Down Expand Up @@ -169,7 +175,8 @@ - (void) removeObservers{
[[_player currentItem] removeObserver:self
forKeyPath:@"playbackBufferFull"
context:playbackBufferFullContext];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemPlaybackStalledNotification object:nil];
///Currently disabled
///[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemPlaybackStalledNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
self._observersAdded = false;
}
Expand Down Expand Up @@ -500,9 +507,21 @@ - (int64_t)duration {
}

- (void)seekTo:(int)location {
///When player is playing, pause video, seek to new position and start again. This will prevent issues with seekbar jumps.
bool wasPlaying = _isPlaying;
if (wasPlaying){
[_player pause];
}

[_player seekToTime:CMTimeMake(location, 1000)
toleranceBefore:kCMTimeZero
toleranceAfter:kCMTimeZero];
toleranceAfter:kCMTimeZero
completionHandler:^(BOOL finished){
if (wasPlaying){
[self->_player play];
}
}];

}

- (void)setIsLooping:(bool)isLooping {
Expand Down
7 changes: 5 additions & 2 deletions lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,12 @@ class BetterPlayerController extends ChangeNotifier {
_controlsVisibilityStreamController.add(controlsAlwaysVisible);
}

///Dispose BetterPlayerController. When [forceDispose] parameter is true, then
///autoDispose parameter will be overridden and controller will be disposed
///(if it wasn't disposed before).
@override
void dispose() {
if (!betterPlayerConfiguration.autoDispose) {
void dispose({bool forceDispose = false}) {
if (!betterPlayerConfiguration.autoDispose && !forceDispose) {
return;
}
if (!_disposed) {
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.47
version: 0.0.48
authors:
- Jakub Homlala <jhomlala@gmail.com>
homepage: https://github.com/jhomlala/betterplayer
Expand Down

0 comments on commit b4a510c

Please sign in to comment.