Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

MPMoviePlayer Video via URL Glitch

Hey Everyone,

I ran into an issue with the iPhone (2.2.1) MediaPlayer that I haven't been able to resolve.

I created a simple ViewController project with a single press the play button to play the video.

The glitch is that if you press play and then immediately press "done" it takes you back to the button and the music will begin playing (if you wait a minute) and you press play to lock up the app.

It must have something to do with the "preloading" of the video.

Any thoughts on this one?

Phil

----



#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
Video.zip
1 x 1 - 19K
Post edited by wrightph on

Replies

Sign In or Register to comment.