iphone, ipad VGA External Display - tvOutManager - iphone

i used all the examples and source code out there for displaying application content to external VGA display. while playing video in inside of the application am getting bellow thing in external device. any suggestion.... am i missing somthing.. but in device it showing actual window in fine way..

Hello All here am answering to my own question.
robterrell's TVOutManager will not play any video to external device by simply doing [[TvOutManager sharedinstance] startTvOut] and [[TvOutManager sharedinstance]s topTVOut];
here we have add the instance of player to tvoutWindow.
[tvoutWindow addSubview:player's instance];
but here thing is the video is not displayed in device,
but you can control external window player from device.
cheers.

NSString *url = [[NSBundle mainBundle] pathForResource:#"Overview" ofType:#"mov"];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(movieFinishedCallback:)name:MPMoviePlayerPlaybackDidFinishNotification object:player];
//---play partial screen---
player.view.frame = CGRectMake(35, 450, 430, 300);
[self.view addSubview:player.view];
[player play];
- (void) movieFinishedCallback:(NSNotification*) aNotification {
[[TVOutManager sharedInstance] startTVOut];
player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
}
this the code am added in mainviewController class in robterrell's TVOutManager sample application. after connecting device into external device. while switching mirror video on am not getting anything..

Related

play iTunes preview video with MPMoviePlayerController

i'm trying to play a video from URL, the video i want play is a iTunes preview video like this:
http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v
i have tried on the iPhone, and open the player, i see the buffer is loaded, but if i play it i don't see anything, how i can do?...this is the code:
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer
respondsToSelector:#selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}
- (IBAction)playVideo:(id)sender {
NSURL *url = [NSURL URLWithString:#"http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
Since you are trying to access a .m4v file from iTunes. The DRM protection is the problem.
EDIT: Your link works in Quicktime, but not in the browser.
Apple does not allow playing DRM protected music or videos from iTunes in the MPMoviePlayerConroller (which includes the previews).
Please also see following link on Stackoverflow
when i copy&paste the link (http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v) to a browser , i did not see/hear the video/audio also..
first there seems to be more than 1 point between hwbfvfdq and 640x480 , maybe there is some characters you did not copy or did not see.
and also, since this is a url from itunes, they may be a usage of tokens to avoid users to reach videos like this url link permanently.
hope this helps ..
p.s. : have you tried your code with a direct url of a movie you know?

MPMoviePlayerController failing to stream .3gp video since iOS 4.3

I have an existing iPhone/iPad universal app that streamed video with the MPMoviePlayerController over wi-fi (mp4) and 3G Network (3gp). When iOS 4.3 was released our 4.3 devices can no longer play a 3gp video over 3G network. I tested a local 3gp file and that fails too, but works on a 3G phone running 4.2.x.
After debugging the view controller I see the MPMoviePlayerLoadStateDidChangeNotification notification is not being triggered when trying to play the 3gp file locally or streaming it via URL.
[APPDEL showStatusView: #"Please wait..."];
NSString * videoUrl = [[request.URL description] stringByReplacingOccurrencesOfString: #"idvideo:" withString: #"http:"];
DLog(#"Loading video %#", videoUrl);
_moviePlayer = [[IDMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString: videoUrl]];
_moviePlayer.view.backgroundColor = [UIColor clearColor];
_moviePlayer.allowsAirPlay = YES;
_moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
if ([_moviePlayer respondsToSelector:#selector(loadState)]) {
// May help to reduce latency
[_moviePlayer prepareToPlay];
// Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:_moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayerPreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:_moviePlayer];
//[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:#selector(moviePlayerTimerUp:) userInfo:nil repeats:NO];
}
else {
// Register to receive a notification when the movie is in memory and ready to play.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: #selector(onMovieDone:) name: MPMoviePlayerPlaybackDidFinishNotification object: nil];
if ([_moviePlayer respondsToSelector: #selector(view)]) {
[self.view addSubview: _moviePlayer.view];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
_moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
}
else {
_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
}
_moviePlayer.view.frame = _webView.frame;
}
[_moviePlayer play];
The first condition for the loadState is always hit. For the 3gp file the code will never reach the moviePlayerLoadStateChanged selector method which hides an indicator/status view and creates other fullscreen/orientation notifications. The indicator/status view will just remain up & spinning. Within debugger I can see the onMovieDone selector method gets triggered far sooner than the video would of really of finished.
Confused.
This my answer in regards with playing .3gp file with iPhone .....I have successfully played .3gp file with iphone sdk with using MpMoviePlayerController and my answer link is:
Link: https://stackoverflow.com/a/13088808/1092219
hope you will got help from my answer.........!! :))))))

MPMoviePlayerController in Background mode

I am trying to play streaming file from particular URL using MPMoviePlayerController. It is working fine when I load the player but I need to keep it running when application enter into the background mode (Multitasking). This is what I am doing:
-(void) playAudio :(NSString *)playAudioURL
{
//NSURLRequest *audioFile = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString:self.playAudioURL] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];
MPMoviePlayerController *mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:playAudioURL]];
mediaPlayer.scalingMode = MPMovieScalingModeAspectFill;
mediaPlayer.scalingMode = MPMovieScalingModeAspectFill;
mediaPlayer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Home-bg.png"]];
//[self.view addSubview:mediaPlayer.view];
mediaPlayer.fullscreen = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mediaPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(videoPreloadCallback:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:mediaPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[mediaPlayer play];
}
Now when I press iPhone home button while running the audio, it pauses the streaming until I load back the Application. I need to keep it running when app enter into background.
In your plist file, did you set the UIBackgroundModes key to audio ? Without this, your application will not play any sound in background
Note that in iOS5, UIBackgroundModes is now referenced as Required background modes when you edit your plist file.
See mpmovieplayercontroller-multitasking-problem

Why does MPMoviePlayerController prevent resumption of audio after the movie ends?

I have a class that plays a repeating background music loop with an AVAudioPlayer, and on specific occasion, plays a full-screen video with its own sound track using MPMoviePlayerController. In order to to have only one track at a time, I stop the background music before launching the video:
-(void)startVideo{
[backgroundMusic stop];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"videofile" ofType:#"m4v"]]];
[self presentMoviePlayerViewControllerAnimated:mp];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(videoOver) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[mp.moviePlayer play];
[mp release];
}
-(void)videoOver{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
if(![backgroundMusic play]){
NSLog(#"bad: can't resume bg music!");
[backgroundMusic release];
backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"videofile" ofType:#"m4v"]] error:NULL];
backgroundMusic.delegate = self;
backgroundMusic.numberOfLoops = -1;
[backgroundMusic play];
}
}
The resumption worked fine without recreating the AVAudioPlayer object (i.e. the play method returned YES) on analogous code on os versions up to and including 3.2. But on iOS4, the play method always returns NO, and has to recreate the object. Why is that, and can I get to resume the background track properly (I have cases where the solution used above is unacceptable.)?
Figured this out. It turns out that in iOS 3.2 and above, when a video finishes playing, it goes into MPMoviePlaybackStatePaused state rather than MPMoviePlaybackStateStopped, and in order to make it release the hardware, you have to explicitly call the stop method on MPMoviePlayerController after it finishes playing before trying to resume AVAudioPlayer.

MPMoviePlayerController worked fine up to iOS 4.0 now just plays sound, no video

The code below is more or less taken from the example MPMoviePlayerController sample code. In an app I wrote last year, it used to play videos fullscreen without an issue. Since iOS 4.0, there's just audio in the background. It's like the movie player doesn't have a view or the view is behind my app. I can still interact with my app, even 'start' a new video (audio only).
It's like the movie player now needs a view, but I don't see any way of supplying this in the API or the sample code (which does seem to be a version or two behind.
I load my videos from a URL and if I type these into Safari, they play just fine.
Here's the relevant code fragments, for what it's worth:
- (void)playMovieUrl:(NSURL*)url
delegate:(id)delegate
callbackSelector:(SEL)selector
{
#try {
movieFinishedCallbackDelegate = delegate;
movieFinishedCallbackSelector = selector;
movieURL = url;
MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie play];
}
#catch (NSException * e) {
return;
}
}
// When the movie is done,release the controller.
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie release];
[movieURL release];
[movieFinishedCallbackDelegate performSelector:movieFinishedCallbackSelector];
}
You probably need to present theMovie:
[self presentMoviePlayerViewControllerAnimated:theMovie];
And change to:
MPMoviePlayerViewController
in ios 3.2 letter use MPMoviePlayerViewController. it behave like a modelViewcontroller