Skip to content

Commit

Permalink
Merge branch 'release/0.8.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
befovy committed May 16, 2020
2 parents e80b712 + 81c326d commit 3ba097d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ All notable changes to this project will be documented in this file. See [standa
---
## [0.8.4](https://github.com/befovy/fijkplayer/compare/v0.8.3...v0.8.4) (2020-05-16)

* add fsFit in demo and docs ([4608acb](https://github.com/befovy/fijkplayer/commit/4608acbc295ce78425cec98d65849140e1a390f6))
* fix initial volume in iOS device is zero ([fc6a60d](https://github.com/befovy/fijkplayer/commit/fc6a60d68f59730390fa7668933f28e270fc1389))
* fix pos update roll back when seeking ([064f062](https://github.com/befovy/fijkplayer/commit/064f062ab42dfd8c1831507861ff5973fca39ad3))

* add fsFit in demo and docs ([4608acb](https://github.com/befovy/fijkplayer/commit/4608acbc295ce78425cec98d65849140e1a390f6))
* lazy load android native libriries, fixes [#234](https://github.com/befovy/fijkplayer/issues/234) ([3788cfe](https://github.com/befovy/fijkplayer/commit/3788cfec1f33e590d20aff5801633185e529044d))
* fix spell error go package name ([40446af](https://github.com/befovy/fijkplayer/commit/40446afa25aefb0f9bed293ee77784277d2a3cae))

Expand Down
7 changes: 7 additions & 0 deletions android/src/main/java/com/befovy/fijkplayer/FijkPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ private void handleEvent(int what, int arg1, int arg2, Object extra) {
mWidth = arg1;
mHeight = arg2;
break;
case SEEK_COMPLETE:
event.put("event", "seek_complete");
event.put("pos", arg1);
event.put("err", arg2);
mEventSink.success(event);
break;
case ERROR:
mEventSink.error(String.valueOf(arg1), extra.toString(), arg2);
break;
Expand Down Expand Up @@ -311,6 +317,7 @@ public void onEvent(IjkMediaPlayer ijkMediaPlayer, int what, int arg1, int arg2,
case AUDIO_RENDERING_START:
case CURRENT_POSITION_UPDATE:
case VIDEO_ROTATION_CHANGED:
case SEEK_COMPLETE:
handleEvent(what, arg1, arg2, extra);
break;
default:
Expand Down
12 changes: 10 additions & 2 deletions ios/Classes/FijkPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ - (void)handleEvent:(int)what
_width = arg1;
_height = arg2;
break;
case 600:
[_eventSink success:@{
@"event" : @"seek_complete",
@"pos" : @(arg1),
@"err" : @(arg2),
}];
break;
case IJKMPET_ERROR:
[_eventSink error:[NSString stringWithFormat:@"%d", arg1]
message:extra ? [NSString stringWithUTF8String:extra] : nil
Expand All @@ -391,7 +398,8 @@ - (void)onEvent4Player:(IJKFFMediaPlayer *)player
case IJKMPET_VIDEO_RENDERING_START:
case IJKMPET_AUDIO_RENDERING_START:
case IJKMPET_ERROR:
case 510:
case IJKMPET_CURRENT_POSITION_UPDATE:
case 600:
case IJKMPET_VIDEO_ROTATION_CHANGED:
[self handleEvent:what andArg1:arg1 andArg2:arg2 andExtra:extra];
break;
Expand Down Expand Up @@ -554,12 +562,12 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
result(nil);
} else if ([@"seekTo" isEqualToString:call.method]) {
long pos = [argsMap[@"msec"] longValue];
[_ijkMediaPlayer seekTo:pos];
if (_state == completed)
[self handleEvent:IJKMPET_PLAYBACK_STATE_CHANGED
andArg1:paused
andArg2:-1
andExtra:nil];
[_ijkMediaPlayer seekTo:pos];
result(nil);
} else if ([@"setLoop" isEqualToString:call.method]) {
int loopCount = [argsMap[@"loop"] intValue];
Expand Down
9 changes: 8 additions & 1 deletion lib/core/fijkplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class FijkPlayer extends ChangeNotifier implements ValueListenable<FijkValue> {
Stream<Duration> get onCurrentPosUpdate => _currentPosController.stream;

bool _buffering = false;
bool _seeking = false;

/// return true if the player is buffering
bool get isBuffering => _buffering;
Expand Down Expand Up @@ -430,6 +431,7 @@ class FijkPlayer extends ChangeNotifier implements ValueListenable<FijkValue> {
return Future.error(StateError("Non playable state $state"));
} else {
FijkLog.i("$this invoke seekTo msec:$msec");
_seeking = true;
_channel.invokeMethod("seekTo", <String, dynamic>{"msec": msec});
}
}
Expand Down Expand Up @@ -550,7 +552,9 @@ class FijkPlayer extends ChangeNotifier implements ValueListenable<FijkValue> {
case 'pos':
int pos = map['pos'];
_currentPos = Duration(milliseconds: pos);
_currentPosController.add(_currentPos);
if (!_seeking) {
_currentPosController.add(_currentPos);
}
break;
case 'size_changed':
int width = map['width'];
Expand All @@ -559,6 +563,9 @@ class FijkPlayer extends ChangeNotifier implements ValueListenable<FijkValue> {
_setValue(
value.copyWith(size: Size(width.toDouble(), height.toDouble())));
break;
case 'seek_complete':
_seeking = false;
break;
default:
break;
}
Expand Down
25 changes: 9 additions & 16 deletions lib/ui/panel2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,16 @@ class __FijkPanel2State extends State<_FijkPanel2> {
});
}

Future<void> onRefresh() async {
String dataSource = player.dataSource;
await player.reset();
await player.setDataSource(dataSource,autoPlay: true);
}

void playOrPause() {
onRefresh();
// if (player.isPlayable() || player.state == FijkState.asyncPreparing) {
// if (player.state == FijkState.started) {
// player.pause();
// } else {
// player.start();
// }
// } else {
// FijkLog.w("Invalid state ${player.state} ,can't perform play or pause");
// }
if (player.isPlayable() || player.state == FijkState.asyncPreparing) {
if (player.state == FijkState.started) {
player.pause();
} else {
player.start();
}
} else {
FijkLog.w("Invalid state ${player.state} ,can't perform play or pause");
}
}

void onDoubleTapFun() {
Expand Down

0 comments on commit 3ba097d

Please sign in to comment.