It looks like you're new here. If you want to get involved, click one of these buttons!
#import \"VideoViewController.h\"
#import <MediaPlayer/MediaPlayer.h>
@implementation VideoViewController
@synthesize moviePlayer;
-(void)viewDidLoad {
if(!moviePlayer) {
//moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[self bundleURL]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[self movieURL]];
}
}
-(IBAction)playVideo {
[moviePlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
}
-(void) moviePlayBackDidFinish:(id)sender {
NSLog(@\"playback stop\");
[moviePlayer stop];
}
-(void) moviePreloadDidFinish:(id)sender {
NSLog(@\"preload\");
}
- (NSURL *)movieURL {
return [NSURL URLWithString: @\"http://code.agilephil.com/fox.m4v\"];
//return [NSURL URLWithString: @\"http://code.agilephil.com/video/iphone.m4v\"];
}
- (NSURL *)bundleURL {
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@\"fox\" ofType:@\"m4v\"];
return [NSURL fileURLWithPath:moviePath];
}
- (void)dealloc {
[moviePlayer release];
[super dealloc];
}
@end
Replies
Rod
---
Tried this and still no go :(
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAlso, you can download at
http://code.agilephil.com/code/video.zip
Still no resolution.. submitted bug to apple. :(
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI'm having the exact same problem. The movieplayer keeps playing the movie in the background (I can't see it, but I hear the sound playing) after the user has exited the video via the 'done' button while it was buffering.
When I perform the same action (done) when the movie is playing it acts totally normal.
So somehow... the player doesn't stop the movie when pressing done only in situations where it is still buffering.
Already found a solution? Anybody some tips?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeWill submit the bug to apple too. Guess the more bug reports on this particular one the sooner it will get fixed.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomePlace the following code in the (finishedCallback:) notification:
[theMovie stop];
theMovie.initialPlaybackTime = -1.0;
[theMovie release];
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeBut why are you worried whether Apple approves it?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI've put
and placed your code in my MoviePlayerDidFinish notification.
I get the following error:
Can you perhaps show me how you've integrated the initialPlayBackTime?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome{
// get current MPMoviePlayerController object from (NSNotification*)aNotification
MPMoviePlayerController *celebVideo = [aNotification object];
//manually stop movie
[celebVideo stop];
// set initialPlaybackTime property of the MPMoviePlayerController class to -1.0 to prevent continued playback in case user closes
// movie player before pre loading has finished.
celebVideo.initialPlaybackTime = -1.0;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:celebVideo];
[celebVideo release];
}
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomejust before
in my MPMoviePlayerPlaybackDidFinishNotification callback
and it fixes the problem.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome