Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-23-2009, 01:34 PM   #1 (permalink)
wrightph
Registered Member
 
Join Date: Sep 2008
Posts: 10
Default Video Player -- Gotta See This !

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:MPMoviePlayerContentPreloadDidFinishNotificat ion
object:nil];
}

-(void) moviePlayBackDidFinishid)sender {
NSLog(@"playback stop");
[moviePlayer stop];
}

-(void) moviePreloadDidFinishid)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
wrightph is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,808
Threads: 89,205
Posts: 380,623
Top Poster: BrianSlick (7,129)
Welcome to our newest member, kaileymo123
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.