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 10-18-2010, 10:54 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 34
nightfox500 is on a distinguished road
Exclamation MoviePlayer with .mp4/youtube

Hello,

I'm trying to stream a .mp4 movie/youtube movie in MPMoviePlayerController. I've found an example from stanford university but the movie does start, I can hear the sound play, but the movie itself isn't visible.

The first test was with an .mp4 movie but actually I want the MoviePlayer to play a youtube movie that I export from my xml feed.

I don't want to open the youtube app so I want to use MoviePlayer for that, does anyone has the solution for this viewing problem or an example for how to play the youtube movie in the app itself?!

Here is the code that play's the movie:
Code:
- (void)playVideoWithURL:(NSURL *)url showControls:(BOOL)showControls {
	if (!player) {
		player = [[MPMoviePlayerController alloc] initWithContentURL:url];
		
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
		
		NSLog(@"Play video");
		if (!showControls) {
			player.scalingMode = MPMovieScalingModeAspectFill;
			player.movieControlMode = MPMovieControlModeHidden;
		}
		
		[player play];
	}
}

- (IBAction)playVideoWithControls {

	NSURL *url = [NSURL URLWithString:@"*/yamaha_r6.mp4"];

	[self playVideoWithURL:url showControls:YES];
}
nightfox500 is offline   Reply With Quote
Old 10-18-2010, 11:30 AM   #2 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

Quote:
Originally Posted by nightfox500 View Post
Hello,

I'm trying to stream a .mp4 movie/youtube movie in MPMoviePlayerController. I've found an example from stanford university but the movie does start, I can hear the sound play, but the movie itself isn't visible.

The first test was with an .mp4 movie but actually I want the MoviePlayer to play a youtube movie that I export from my xml feed.

I don't want to open the youtube app so I want to use MoviePlayer for that, does anyone has the solution for this viewing problem or an example for how to play the youtube movie in the app itself?!

Here is the code that play's the movie:
Code:
- (void)playVideoWithURL:(NSURL *)url showControls:(BOOL)showControls {
	if (!player) {
		player = [[MPMoviePlayerController alloc] initWithContentURL:url];
		
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
		
		NSLog(@"Play video");
		if (!showControls) {
			player.scalingMode = MPMovieScalingModeAspectFill;
			player.movieControlMode = MPMovieControlModeHidden;
		}
		
		[player play];
	}
}

- (IBAction)playVideoWithControls {

	NSURL *url = [NSURL URLWithString:@"*/yamaha_r6.mp4"];

	[self playVideoWithURL:url showControls:YES];
}
This problem is when you use MPMoviePlayerController, because it only works with 3.0, from 3.2+ you must use mpmovieplayerviewcontroller
MozyMac is offline   Reply With Quote
Old 10-18-2010, 11:32 AM   #3 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

There are some examples of how to use mpmovieplayerviewcontroller on apple developer forum, just search for "mpmovieplayerviewcontroller"
MozyMac is offline   Reply With Quote
Old 10-18-2010, 01:19 PM   #4 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by MozyMac View Post
There are some examples of how to use mpmovieplayerviewcontroller on apple developer forum, just search for "mpmovieplayerviewcontroller"
Or just copy the needed code from my tutorial.. (this works on 4.0 or later) YouTube - Xcode Tutorial 1 - How to play videos in 4.0 or lower
Chessin is offline   Reply With Quote
Old 10-18-2010, 04:48 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 34
nightfox500 is on a distinguished road
Default

Quote:
Originally Posted by Chessin View Post
Or just copy the needed code from my tutorial.. (this works on 4.0 or later) YouTube - Xcode Tutorial 1 - How to play videos in 4.0 or lower
The weird thing is, when I use your code it does exactly the same. The audio starts but the video isn't visible. Also the debugger gets this message:

AddRunningClient starting device on non-zero client count
nightfox500 is offline   Reply With Quote
Old 10-18-2010, 09:56 PM   #6 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by nightfox500 View Post
The weird thing is, when I use your code it does exactly the same. The audio starts but the video isn't visible. Also the debugger gets this message:

AddRunningClient starting device on non-zero client count
My code is proven working, it must be your part of the code then
Chessin is offline   Reply With Quote
Old 10-21-2010, 12:55 PM   #7 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 1
dinu_1987 is on a distinguished road
Default

Quote:
Originally Posted by Chessin View Post
My code is proven working, it must be your part of the code then
Hi Chessin,

I am new to ios development.
I was searching for the same information.
Your code helped me at the right time.

Thank you very much!

Dinesh Kumar P
dinu_1987 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: 337
7 members and 330 guests
Desert Diva, dre, hain, mottdog, oceanlablight, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,895
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 01:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0