File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Original file line number Diff line number Diff line change 1
1
2
- ## 0.10.0+6
3
-
4
- * Android: Fix missing call to ` event.put("event", "completed"); ` which makes it possible to detect when the video is over.
5
-
6
- ## 0.10.0+5.1
2
+ ## 0.10.0+7
7
3
8
4
* Implemented playback speed feature.
9
5
10
- ## 0.10.0+5.2
6
+ ## 0.10.0+6
11
7
12
- * Fixed iOS build warnings about implicit retains .
8
+ * Android: Fix missing call to ` event.put("event", "completed"); ` which makes it possible to detect when the video is over .
13
9
14
10
## 0.10.0+5
15
11
16
- * Implemented playback speed feature .
12
+ * Fixed iOS build warnings about implicit retains .
17
13
18
14
## 0.10.0+4
19
15
Original file line number Diff line number Diff line change @@ -342,6 +342,19 @@ - (void)setVolume:(double)volume {
342
342
_player.volume = (volume < 0.0 ) ? 0.0 : ((volume > 1.0 ) ? 1.0 : volume);
343
343
}
344
344
345
+ - (void )setPlayBackSpeed : (double )speed {
346
+ if (speed == 1.0 || speed == 0.0 ) {
347
+ _player.rate = speed;
348
+ } else if (speed < 0 || speed > 2.0 ) {
349
+ NSLog (@" Speed outside supported range %f " , speed);
350
+ } else if ((speed > 1.0 && _player.currentItem .canPlayFastForward ) ||
351
+ (speed < 1.0 && _player.currentItem .canPlaySlowForward )) {
352
+ _player.rate = speed;
353
+ } else {
354
+ NSLog (@" Unsupported speed. Cannot play fast/slow forward: %f " , speed);
355
+ }
356
+ }
357
+
345
358
- (CVPixelBufferRef)copyPixelBuffer {
346
359
CMTime outputItemTime = [_videoOutput itemTimeForHostTime: CACurrentMediaTime ()];
347
360
if ([_videoOutput hasNewPixelBufferForItemTime: outputItemTime]) {
@@ -494,6 +507,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
494
507
} else if ([@" pause" isEqualToString: call.method]) {
495
508
[player pause ];
496
509
result (nil );
510
+ } else if ([@" setPlayBackSpeed" isEqualToString: call.method]) {
511
+ [player setPlayBackSpeed: [[argsMap objectForKey: @" speed" ] doubleValue ]];
512
+ result (nil );
497
513
} else {
498
514
result (FlutterMethodNotImplemented);
499
515
}
Original file line number Diff line number Diff line change @@ -93,7 +93,9 @@ class VideoPlayerValue {
93
93
final double speed;
94
94
95
95
bool get initialized => duration != null ;
96
+
96
97
bool get hasError => errorDescription != null ;
98
+
97
99
double get aspectRatio => size != null ? size.width / size.height : 1.0 ;
98
100
99
101
VideoPlayerValue copyWith ({
@@ -359,6 +361,9 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
359
361
value = value.copyWith (position: newPosition);
360
362
},
361
363
);
364
+
365
+ // Ensure the video is played at the correct speed
366
+ await _applyPlayBackSpeed ();
362
367
} else {
363
368
_timer? .cancel ();
364
369
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
@@ -433,6 +438,12 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
433
438
return ;
434
439
}
435
440
441
+ // On iOS setting the speed will start playing the video automatically
442
+ // Do not change the video speed until after the video is played
443
+ if (! value.isPlaying) {
444
+ return ;
445
+ }
446
+
436
447
// ignore: strong_mode_implicit_dynamic_method
437
448
await _channel.invokeMethod (
438
449
'setPlayBackSpeed' ,
You can’t perform that action at this time.
0 commit comments