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 07-15-2009, 06:49 AM   #11 (permalink)
ZunePod
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Quote:
Originally Posted by wrightph View Post
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

----

Code:
#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) 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
Use code tags.
ZunePod is offline   Reply With Quote
 

» Advertisements
» Online Users: 363
22 members and 341 guests
ADY, apatsufas, bobli, Dani77, Dattee, Desert Diva, HDshot, HemiMG, ilmman, leahov, MarcoAlmeida, mer10, michelle, ngaikwad, Punkjumper, Raffaello, Robiwan, Rudy, skrew88, wilky94
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,726
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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