Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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 04-23-2009, 12:34 PM   #1 (permalink)
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
Old 04-25-2009, 10:55 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 10
Default Still no resolution

Hi!

Also, you can download at
http://code.agilephil.com/code/video.zip

Still no resolution.. submitted bug to apple.
wrightph is offline   Reply With Quote
Old 07-03-2009, 07:28 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default Same problem: Video keeps playing after pressing done while buffering...

Hi,

I'm having the exact same problem. The movieplayer keeps playing the movie in the background (I can't see it, but I hear the sound playing) after the user has exited the video via the 'done' button while it was buffering.

When I perform the same action (done) when the movie is playing it acts totally normal.

So somehow... the player doesn't stop the movie when pressing done only in situations where it is still buffering.

Already found a solution? Anybody some tips?
PipoDeClown is offline   Reply With Quote
Old 07-03-2009, 07:41 AM   #4 (permalink)
Registered Member
 
mnemonic_fx's Avatar
 
Join Date: Jun 2008
Location: Planet Earth
Posts: 415
Default

It works totally fine here
__________________
Visit Me

Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
mnemonic_fx is offline   Reply With Quote
Old 07-03-2009, 07:44 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default

Quote:
Originally Posted by mnemonic_fx View Post
It works totally fine here
Ok.. I'm happy for you! Any idea what I could've done wrong so that my version doesn't work?
PipoDeClown is offline   Reply With Quote
Old 07-03-2009, 07:47 AM   #6 (permalink)
Registered Member
 
mnemonic_fx's Avatar
 
Join Date: Jun 2008
Location: Planet Earth
Posts: 415
Default

Try to set the Base SDK to 3.0, and set the deployment target to whatever you want.

But, I don't see the preload notification.
__________________
Visit Me

Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
mnemonic_fx is offline   Reply With Quote
Old 07-03-2009, 08:23 AM   #7 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default Thanks for the tip, will try!

Quote:
Originally Posted by mnemonic_fx View Post
Try to set the Base SDK to 3.0, and set the deployment target to whatever you want.

But, I don't see the preload notification.
Thanks for the tip! Going to try that one.

Also found this thread:
MPMoviePlayerController vs. UIMoviePlayerController?

Will try the movie export from quicktime to see if the videoformat was wrong.
Will try releasing the movieplayer before and after playback.

Will post results later on... if someone has some other tips they're welcome!
PipoDeClown is offline   Reply With Quote
Old 07-06-2009, 02:23 AM   #8 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default Bump

All the above doesn't seem to help. Anybody any idea?
PipoDeClown is offline   Reply With Quote
Old 07-06-2009, 04:06 AM   #9 (permalink)
Registered Member
 
mnemonic_fx's Avatar
 
Join Date: Jun 2008
Location: Planet Earth
Posts: 415
Default

I download the code from agilephil, and it works as expected, so I'm not sure which part is wrong in your case, or what is the exact behaviors do you expect ?
__________________
Visit Me

Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
mnemonic_fx is offline   Reply With Quote
Old 07-15-2009, 05:38 AM   #10 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default Must be a bug. Apple sample code also exhibits the problem.

Quote:
Originally Posted by mnemonic_fx View Post
I download the code from agilephil, and it works as expected, so I'm not sure which part is wrong in your case, or what is the exact behaviors do you expect ?
After some mind-breaking nights we decided to stop and try the bare minimum: apple's sample code for the movieplayer. It exhibits the exact same bug as described in this thread above.

Will submit the bug to apple too. Guess the more bug reports on this particular one the sooner it will get fixed.

What also didn't help is that the buggy behaviour appears almost random. Couldn't recreate it every time, but often enough to be annoying.

(To recap the bug: when pressing 'done' during the buffering of a movie, the object is not killed. Therefore, the sound will resume playing anywhere in the app although you already left the video fullscreen view and maybe have navigated to another view.)
PipoDeClown is offline   Reply With Quote
Old 07-15-2009, 05:49 AM   #11 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 829
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 online now   Reply With Quote
Old 07-19-2009, 08:44 AM   #12 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 128
Default

So can we take it that this is a bug given that Apple's code sample does the same thing?

I can load the video OK and it plays but even if I let it play full cycle if I run it again I get a black screen but with audio, if I play it after that I get flashing video?

I am sure this was not the case in 2.2.1 which I am trying to find my code I used that used to work ok!
ghanalupo is offline   Reply With Quote
Reply

Bookmarks

Tags
video mediaplayer bug

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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 231
13 members and 218 guests
Ajameel, andrei_c, chorew, Ed99, jazzbearz, JoyiPhone, Jupiterus, MartinIngvar, marwa, naqviak, pereorra, SiVola, ZunePod
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,279
Threads: 39,072
Posts: 171,337
Top Poster: smasher (2,575)
Welcome to our newest member, yogen81
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0