Play / Rewind Video at 2x 3x 4x Speed ​​- iPhone SDK

I want to play / forward videos to MPMoviePlayerController with different speeds. Can anyone suggest me how I do this.

Now I am doing fast forward (at the same speed), but after a few seconds it returns to normal speed.

Please offer.

+3
source share
2 answers
MPMoviePlayerController Conforms to MPMediaPlayback protocol you can see the property currentPlaybackRate as :- @property(nonatomic) float currentPlaybackRate A value of 0 represents that the video is stopped , a value of 1 indicates normal speed and further positive values indicate increased speed while negative ones indicate reverse . 

Also check out your endseeking delegation method for MPMediaPlayback, as this is the only method that returns playback to normal

+4
source

Here is the code for Forward and BackWard Movie as 2x 3x 4x for MPMoviePlayerViewController

In the .h file

 @property(nonatomic) float currentPlaybackRate; 

In the .m File

 - (void)viewDidLoad { currentPlaybackRate=1.0; //video Play in Normal speed } 

Now about the actions of the FastForward and FastBackward buttons

 [fastForward addTarget:self action:@selector(fastForward) forControlEvents:UIControlEventTouchUpInside]; [fastBackWard addTarget:self action:@selector(fastBackward) forControlEvents:UIControlEventTouchUpInside]; 

Action code

 -(void)fastForward { [mp.moviePlayer pause]; playPauseButton.selected=TRUE; if (currentPlaybackRate < 0.0) { currentPlaybackRate = 1.0; } if (currentPlaybackRate < 4.0) { currentPlaybackRate=currentPlaybackRate+1.0; NSLog(@"Forward::%f",currentPlaybackRate); mp.moviePlayer.currentPlaybackRate=currentPlaybackRate; } } -(void)fastBackward { [mp.moviePlayer pause]; playPauseButton.selected=TRUE; if (currentPlaybackRate > 0.0) { currentPlaybackRate = 0.0; } if (currentPlaybackRate > -4.0) { currentPlaybackRate=currentPlaybackRate-1.0; NSLog(@"BackWard::%f",currentPlaybackRate); mp.moviePlayer.currentPlaybackRate=currentPlaybackRate; } } 
0
source

Source: https://habr.com/ru/post/1416305/


All Articles