I have a button in my iPhone app which launches the iPhone YouTube player and plays a video. The code I use is this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=xxx"]];
It works fine, but when I stop the video (or it ends) the context does not come back to the app from which I run YouTube. It just remains in YouTube or, if I force its closure, turns to the iPhone menu.
Is there any way to come back to the executing app?
You may want to take a look at Display YouTube Videos Without Exiting Your Application
Related
I've been attempting to make this work for quite a while now:
My app has the potential to play videos of Youtube from within UIWebView. The user could want to use AirPlay for this. When AirPlay is on, the device could go to sleep and normally video stops playing moments after that happens. As advised in other posts, I set the AVAudioSession category to the Playback one and it works - AirPlay continues even when the device display goes to sleep.
However, this has a side-effect; if the user has activated the app while music playback is on in the background, setting the app's audio session category to Playback causes the playing music to stop and this is definitely annoying.
Ideally, I want to set the AVAudioSession category when playback of Video starts, not when my App is activated - but I've not seen any central or UIWebview notification / delegate method to determine this.
I've got a hackish workaround for iPhone where the UIWebview hosted video player always loads full screen modal and thus can be determined. But my app is Universal and on iPad the video starts inline; I can't figure out a way to know when Video playback is going to happen. This is exactly the point when the audio category should be switched to Playback - it will actually help users who want background music playing only until video starts up.
I don't want to fool around with adding Javascript events on to Video tags inside the UIWebView - that seems too fragile to me.
Is it possible to observe any AVFoundation notifications that trigger for the UIWebView video playback? Or anyone know of any other way to determine if video playback will start / has started?
I have a problem playing youtube videos in fullscreen mode within UIWebView. By default video is inlined. When I switch to fullscreen (native player button), video player is resized to fullscreen and after that is quits playing and page gets refreshed.
This works just fine is iOS5 but not iOS6.
This is more obvious on iPhone cos player goes fullscreen mode as soon as video starts playing. As a results this videos can not be played on iPhone device using iOS6.x.
I know that Apple change its policy about youtube videos. But how does this helps me? How can I assure videos are also playing in fullscreen mode?
-(void)viewWillDisappear is now (iOS6) called if you play a video in fullscreen mode
try registering for UIMoviePlayerControllerDidEnter*(/Exit)*FullscreenNotification
and modifying viewWillDisappear like UIWebView Movie Player getting dismissed iOS 6 bug
http://silver.co.uk/rla
I have problems with the above page. Setup information is on the page.
It does not play on iPhone (iOS 5). The file plays if downloaded to iPhone first but does not stream from the page. The play button does nothing.
It only plays after loading the video on Safari on Windows. i.e. it doesn't stream as soon as you click on the play button but wait to load the video. Then it plays. This doesn't happen on Safari for MacOS.
What am I doing wrong?
Thanks
Riz
In my app it has lots of videos and animation to present a view. Am implemented External display by using TVOutManager sample app. Every thing works fine except video part.
inside my application videos are playing fine but in external window it not showing anything is simply shows "TV is connected, Video is playing in TV" in a small window.
So how to resolve this.. how to display inside app video to external window.
any idea or am i doing something wrong here..
thanks,
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.
I am trying to play youtube videos after loading the webview. But Only Audio is being played, not video. Although I get play button in status bar, the Media Player does not become active. The Same piece of code works in iTouch 4.1 and simulator but not on iPhone 4.1/4.0. What am I missing here???
Is the default youtube application playing video? If yes, You might want to try removing the frameworks, add them again and clean build your project.