MPMovieplayerController spielen das zweite Mal Video
-
19-09-2019 - |
Frage
Ich muss die Möglichkeit haben, mehr als ein Video in einer App zu spielen.
Leider erscheint das zweite Mal, als ich das Spielen drücke, das Video blinkt.
Ich verwende nur diesen Code zum Spielen von Videos
Nsurl *url = [[[nsurl alloc] initFileurlwithPath: [[nsbundle mainBundle] pathforresource:@"move" oftype:@"m4v"] Autorelease];
MpMovieplayerController *mp = [[mpMovieplayertroller alloc] initWithContentUrl: URL];
mp.MovieControlMode = mpMovieControlModEDeFault;
MP Play];
movieplayer = mp;
MP Release];
Kann mir jemand sagen, wo das Problem sein kann? Danke im Voraus!
Update 1: Es scheint, dass der Apfel Movieplayer Beispiel hat das gleiche Problem.
Lösung
you can also do it by setting the initial playback time to -1.0 before calling the play function
mp.initialPlaybackTime = -1.0;
Put this code before ur play method is called.
Andere Tipps
I had this problem and solved it by using the notification system to execute a callback after the MPMoviePlayerController finishes playing, and releasing the player object there.
Add a notification before you play the movie:
NSURL *url = [[[NSURL alloc]initFileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Movie" ofType:@"m4v"]] autorelease];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc]initWithContentURL:url];
mp.movieControlMode = MPMovieControlModeDefault;
//***Add this line***
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:mp];
[mp play];
Then add the callback method,
-(void)myMovieFinished:(NSNotification*)aNotification
{
MPMoviePlayerController *moviePlayer = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidFinishNotification object:moviePlayer];
[moviePlayer release];
}
It seams that the only solution is... to make the app for 3.1
I also find run on the OS 3.1 or later version of simulator can be played well.It won't appears blinking.But when I add
initialPlaybackTime = -1.0
it will also play well on OS 3.0.