AVPlayer seektoTime iPhone

I used seekToTime in my application and it works correctly. But I want more information about this. If I have a streaming video file with 1 minute, I want to play it from the second 15th to the second 45 (the first 15 seconds and the last 15 seconds will not play).

How can i do this?

I know that with seekToTime I can play a video from the 15th second, but how can I stop it at the 45th second, and also notice that the method played the video for a specified period of time?

CMTime timer = CMTimeMake(15, 1);
[player seekToTime:timer];

The above code brings me back to the 15th second of the stream file, but how to stop it at the 45th second and receive a notification?

I searched a lot, but could not get the information.

thank

EDIT:

As suggested by @codeghost, just use forwardPlaybackEndTime.

:

yourAVPlayerItem.forwardPlaybackEndTime = CMTimeMake(10, 1);

10 - , AVPlayerItem .

+5
3

forwardPlaybackEndTime AVPlayerItem.

+7

, - AVPlayer, , , :

[self performSelector:@selector(stopPlaying) withObject:nil afterDelay:45];


-(void)stopPlaying{
   [player pause];
}

45 , , , 45 .

0

You can use [AVPlayer addPeriodicTimeObserverForInterval:queue:usingBlock:]for this purpose.

Receive AVPlayer.currentTimeand pause periodically, or stop the exact time.

0
source

All Articles