Mpmovieplayercontroller Stops Playing After 5 Seconds - Swift

MPMoviePlayerController Stops Playing After 5 seconds - Swift

Could your moviePlayer be going out of scope? Have you tried making it a member variable?

moviePlayer is a local variable of viewDidLoad, so once that function finishes, I don't see any reason why your player would not be deallocated.

If you instead make it a variable of the class, its lifetime will be extended to match your class's lifetime.

something like

class ViewController: UIViewController {

var player: MPMoviePlayerController?

override func viewDidLoad() {
// ...
self.player = MPMoviePlayerController(contentURL: url) // won't go out of scope at end of viewDidLoad()
// ...
}

video stop after few seconds while playing video from URL using MPMoviePlayerController with error in the console

There is no error actually media player is downloading your video after completing the download it will show this message

Ending background task assertion (6) for playback stall

and then video will be played automatically

Audio file stops playing after a couple seconds

The first thing I would fix is changing your @ObservedObject wrapper to a @StateObject wrapper. This will prevent deallocation if the view updates at some point in the process of playing the sound. Let me know if that works...

Why is the MPMoviePlayerController not pausing?

What to do to make the video paused as it loads ?

Try: [yourPlayer setShouldAutoplay:NO];

Why does MPMoviePlayerController setCurrentPlaybackTime goes to the wrong time?

You should seek using seekToTime or seekToTimeWithSeconds.

 CMTime npt = CMTimeMake(9,1);
[self.player seekToTime:npt];

or

  CMTime npt = CMTimeMakeWithSeconds(9.3, 600);
[self.player seekToTime:npt toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];


Related Topics



Leave a reply



Submit