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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-02-2010, 01:47 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Ireland
Age: 21
Posts: 472
kieran12 is on a distinguished road
Default MPMoviePlayerController only playing audio

As the title says my MPMoviePlayerController should display on the button press but instead only the audio plays. I know it's not a problem with my video file as I have tried several including a sample video of the .mp4 format from apple.

Here is my code:

Code:
-(IBAction)playVideo:(id)sender {
	NSBundle *bundle = [NSBundle mainBundle];
	NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];
	
	NSURL *movieURL;
	
	if (moviePath)
	{
		movieURL = [NSURL fileURLWithPath:moviePath];
	}
	
	if (movieURL != nil) {
		moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
		
		[[NSNotificationCenter defaultCenter] addObserver:self
												 selector:@selector(moviePlayBackDidFinish:) 
													 name:MPMoviePlayerPlaybackDidFinishNotification 
												   object:moviePlayer];
		moviePlayer.fullscreen = YES;
		moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
		
		[moviePlayer play]; 
		
	}
	
}

-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
	moviePlayer = [notification object];
	[moviePlayer stop];
}
Can you see any issues? I'm using iOS4.0 and SDK 4.0.

Thanks
__________________
On the iOS App Store
kieran12 is offline   Reply With Quote
Old 07-02-2010, 01:55 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

If you want it to be this simple on iOS 4.0, look up MPMoviePlayerViewController.
JasonR is offline   Reply With Quote
Old 07-02-2010, 02:27 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Ireland
Age: 21
Posts: 472
kieran12 is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
If you want it to be this simple on iOS 4.0, look up MPMoviePlayerViewController.
Thanks, didn't realise they changed to a new class.
__________________
On the iOS App Store
kieran12 is offline   Reply With Quote
Old 07-07-2010, 07:56 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
cwobrien is on a distinguished road
Default MPMoviePlayerViewController undeclared

I had the exact same problem. Except, when I tried to use the MPMoviePlayerViewController as I've seen in different examples out there I get an error:

MPMoviePlayerViewController undeclared (first use in function)

from this line of code:

MPMoviePlayerViewController *playerViewController =
[[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];

I have SDK 3.2, and I've included the MediaPlayer.h file. I'm not sure what I'm doing wrong. Any ideas?
cwobrien is offline   Reply With Quote
Old 07-07-2010, 11:49 AM   #5 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

If you look at the docs for MPMoviePlayerViewController, you'll see you also have to include MPMoviePlayerViewController.h
JasonR is offline   Reply With Quote
Old 07-07-2010, 12:21 PM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
cwobrien is on a distinguished road
Default

I had tried the include earlier but was getting an error even with that. I went and started digging around in the framework folder and realized that file wasn't even there! I had the iPhone 3.2 SDK, which should include it. I'm not sure what happened there. I reinstalled xcode and deleted / relinked that framework and now I can at least build it....doesn't work yet...but that is progress.

Thanks!
cwobrien is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 326
6 members and 320 guests
anothermine, Chickenrig, givensur, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0