 |
 |
|
 |
04-23-2009, 01:34 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Sep 2008
Posts: 10
|
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) 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
|
|
|
07-03-2009, 08:28 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 10
|
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?
|
|
|
07-03-2009, 08:41 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jun 2008
Location: Planet Earth
Posts: 402
|
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.
|
|
|
07-03-2009, 08:44 AM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 10
|
Quote:
Originally Posted by mnemonic_fx
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?
|
|
|
07-03-2009, 08:47 AM
|
#6 (permalink)
|
|
Registered Member
Join Date: Jun 2008
Location: Planet Earth
Posts: 402
|
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.
|
|
|
07-03-2009, 09:23 AM
|
#7 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 10
|
Thanks for the tip, will try!
Quote:
Originally Posted by mnemonic_fx
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!
|
|
|
07-06-2009, 03:23 AM
|
#8 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 10
|
Bump
All the above doesn't seem to help. Anybody any idea?
|
|
|
07-06-2009, 05:06 AM
|
#9 (permalink)
|
|
Registered Member
Join Date: Jun 2008
Location: Planet Earth
Posts: 402
|
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.
|
|
|
07-15-2009, 06:38 AM
|
#10 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 10
|
Must be a bug. Apple sample code also exhibits the problem.
Quote:
Originally Posted by mnemonic_fx
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.)
|
|
|
07-15-2009, 06:49 AM
|
#11 (permalink)
|
|
Registered Member
Join Date: Apr 2009
Posts: 204
|
Quote:
Originally Posted by wrightph
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.
|
|
|
07-19-2009, 09:44 AM
|
#12 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 127
|
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!
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 518 |
| 47 members and 471 guests |
| 9livesoftware, al31, Alexman, bartender, blackoutq3, BrianSlick, ChristyS, coolman, coulls, dbarrett, DenVog, designomatt, dljeffery, DorkyMohr, dsailer, ethanwa, fabiolpi, ggalante, grouchal, HUngable, hyang, iphonedevelopment@me, issya, javaconvert, jixu2002cn, josechuis, jschorn, learnSomething, marciokoko, masc2279, MiniRobinho, mlo, Mopedhead, m_kaminsky@yahoo.com, P2k, pablo.roqueta, popclock, ryguy2503, seriessix, SmallWonder, Stephane.tamis, themathminister, TunaNugget, wheli, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,491
Threads: 35,773
Posts: 156,705
Top Poster: smasher (2,448)
|
| Welcome to our newest member, DorkyMohr |
|