@@ -28,6 +28,7 @@ function YouTubeVideo(options) {
28
28
onPropChanged ( 'time' ) ;
29
29
onPropChanged ( 'volume' ) ;
30
30
onPropChanged ( 'muted' ) ;
31
+ onPropChanged ( 'playbackSpeed' ) ;
31
32
} , timeChangedTimeout ) ;
32
33
33
34
var video = null ;
@@ -46,6 +47,7 @@ function YouTubeVideo(options) {
46
47
buffering : false ,
47
48
volume : false ,
48
49
muted : false ,
50
+ playbackSpeed : false ,
49
51
subtitlesTracks : false ,
50
52
selectedSubtitlesTrackId : false
51
53
} ;
@@ -165,6 +167,7 @@ function YouTubeVideo(options) {
165
167
onPropChanged ( 'buffering' ) ;
166
168
onPropChanged ( 'volume' ) ;
167
169
onPropChanged ( 'muted' ) ;
170
+ onPropChanged ( 'playbackSpeed' ) ;
168
171
onPropChanged ( 'subtitlesTracks' ) ;
169
172
onPropChanged ( 'selectedSubtitlesTrackId' ) ;
170
173
}
@@ -240,6 +243,13 @@ function YouTubeVideo(options) {
240
243
241
244
return video . isMuted ( ) ;
242
245
}
246
+ case 'playbackSpeed' : {
247
+ if ( stream === null || typeof video . getPlaybackRate !== 'function' || video . getPlaybackRate ( ) === null || ! isFinite ( video . getPlaybackRate ( ) ) ) {
248
+ return null ;
249
+ }
250
+
251
+ return video . getPlaybackRate ( ) ;
252
+ }
243
253
case 'subtitlesTracks' : {
244
254
if ( stream === null || typeof video . getOption !== 'function' ) {
245
255
return [ ] ;
@@ -335,6 +345,14 @@ function YouTubeVideo(options) {
335
345
336
346
break ;
337
347
}
348
+ case 'playbackSpeed' : {
349
+ if ( stream !== null && typeof video . setPlaybackRate === 'function' && isFinite ( propValue ) ) {
350
+ video . setPlaybackRate ( propValue ) ;
351
+ onPropChanged ( 'playbackSpeed' ) ;
352
+ }
353
+
354
+ break ;
355
+ }
338
356
case 'selectedSubtitlesTrackId' : {
339
357
if ( stream !== null ) {
340
358
selectedSubtitlesTrackId = null ;
@@ -388,6 +406,7 @@ function YouTubeVideo(options) {
388
406
onPropChanged ( 'buffering' ) ;
389
407
onPropChanged ( 'volume' ) ;
390
408
onPropChanged ( 'muted' ) ;
409
+ onPropChanged ( 'playbackSpeed' ) ;
391
410
onPropChanged ( 'subtitlesTracks' ) ;
392
411
onPropChanged ( 'selectedSubtitlesTrackId' ) ;
393
412
} else {
@@ -417,6 +436,7 @@ function YouTubeVideo(options) {
417
436
onPropChanged ( 'buffering' ) ;
418
437
onPropChanged ( 'volume' ) ;
419
438
onPropChanged ( 'muted' ) ;
439
+ onPropChanged ( 'playbackSpeed' ) ;
420
440
onPropChanged ( 'subtitlesTracks' ) ;
421
441
onPropChanged ( 'selectedSubtitlesTrackId' ) ;
422
442
break ;
@@ -477,7 +497,7 @@ YouTubeVideo.canPlayStream = function(stream) {
477
497
YouTubeVideo . manifest = {
478
498
name : 'YouTubeVideo' ,
479
499
external : false ,
480
- props : [ 'stream' , 'loaded' , 'paused' , 'time' , 'duration' , 'buffering' , 'volume' , 'muted' , 'subtitlesTracks' , 'selectedSubtitlesTrackId' ] ,
500
+ props : [ 'stream' , 'loaded' , 'paused' , 'time' , 'duration' , 'buffering' , 'volume' , 'muted' , 'playbackSpeed' , ' subtitlesTracks', 'selectedSubtitlesTrackId' ] ,
481
501
commands : [ 'load' , 'unload' , 'destroy' ] ,
482
502
events : [ 'propValue' , 'propChanged' , 'ended' , 'error' , 'subtitlesTrackLoaded' ]
483
503
} ;
0 commit comments