iPhone, how to detect when control is returned to browser? - iphone

I'm a newbie to cocoa programing on iPhone.
My client has a website that plays YouTube videos. Once a video is finished playing, it will automatically play the next one. This is done by using the YouTube API and swfobject.
After some research, I was told that Safari on iPhone does not support flash. This make the current swfobject code not working on the iPhone browser.
As workaround, when the user clicked on an embedded player, iPhone will launch the YouTube app.
Is to possible to determine when the YouTube app has finished playing and has returned control back to browser?

You can use UIWebView to play videos from YouTube. You'll have to control those from your application though (start, stop, play next, etc).
Also In iOS you can register custom URI schemes and then redirect the browser (or UIWebView) back to your application. This is how many application do 3-legged OAuth for example (which requires a browser interaction). Which might require having a control over the server.

No, it is not possible to jump out of your App and then come back to it again. Once you leave your App, you are finished.
You'll need to stay in a UIWebView, or come up with another method of playing the YouTube videos from within your App.
-t

Related

WKWebView audio interrupted when app AudioSessionCategory changes

TLDR: How to jumpstart a webviews audioSession without reloading its content?
Hello everyone. I am having a very specific issue with the wkwebview on iOS in regards to the AudioSession.Category management. I guess I start with that it is well understood that the wkwebview operates on its own process and therefor owns its own AudioSession. That means that any changes on the APPs AudioSession won't reflect on the webviews AudioSession.
We build an app, which is entirely web based and has to be for reasons I don't want to go into, so our IOS app is essentially a wrapper for the web content. Recent web content required us to use webrtc functionality do do audio recordings which is only available from iOS 14.3 upwards, which required us to work out a solution, which is backwards compatible down to iOS 12. The idea was to create a native audio recorder, which then interfaces with the webview to transfer audio recordings to the web content.
In order to make recordings within the app the AudioSession.Category needs to change to playAndRecord and is triggered by the webviews content through the messageHandler interface. A change of the APP category will trigger an interruption of the webview audioSession, which from then on does not play any media anymore (until a new url is loaded(single page apps do not make new requests in general)). To fix this a reload of the current url is needed to un-interrupted the sound, which can be somewhat masked behind loading screens but isn't a really good solution.
I am looking for ways to start the audio again without reloading the webview.
Thanks for any insights on this.
I've recently stuck with similar problem. Here is what I've found.
Whenever background music like YouTube in WKWebView or Music app is playing and your app audio session category or mode (but not options [1]) is changed while app's audio session is active background audio is interrupted. Even when re-configuration of audio session is happen between mixable configurations. The solution I've found is to deactivate app audio session prior applying new configuration and activating it again. And in case of playAndRecord it is important not to forget to add [.mixWithOthers]/[.mixWithOthers, .duckOthers] option. For some reason I can't find formal documentation on this behavior but confirmed it with simple demo app which provide manual way to activate/deactivate audio session and configure it to variety of category/mode/options.
[1] It is possible to switch between [.mixWithOthers] and [.mixWithOthers, .duckOthers] on active audio session and not to interrupt background audio, if category and mode are not changed during reconfiguration.

How to play vimeo videos inline in moblie application and grab seek, play events

We are developing a mobile application (using ionic framework, jquery) and thinking to let our users to share videos from vimeo, youtube etc. in this case we are integrating vimeo video link in iframe. Below are challenges:
Not able to play vimeo videos inline in our application:
on iPhone device when we play vimeo video from our ionic application it opens in a native video player, on the contrary we want to play it inline in our application itself
in case of Youtube video its supported and works well. They have provide Playsinline property to support it.
As per vimeo developers documentation, we have not found any similar video player property to allow inline video rendering
Is there any workaround that you suggest to play vimeo video inline inside application?
Play, seek & load progress events are not supported in mobile application
As per your developers page, play, seek, load progress etc events are not supported in mobile application
Is there any workaround to enable these events on our mobile application
Yes, I know there are limitations that vimeo has declared but can someone provide me if there are any workarounds? Your response to our queries is very much important for us.
Reference:
https://developers.google.com/youtube/player_parameters
https://developer.vimeo.com/player/js-api#event-compatibility
try adding background=1 to your embed code
<iframe id="player1" src="https://player.vimeo.com/video/[video id]?api=1&player_id=player1&background=1" width="630" height="354" frameborder="0"></iframe>
This wil not work in browsers which revert to the flashplayer.
I don't know if you'll have javascript API functionallity.
This will remove all controls aswell. What I've read, it's still in an experimental fase, but hope it works for you.

Can a iOS app load a webview with youtube?

I am developing an iOS app. In that I am loading couple of youtube videos using HTML5 using webview.
I am bit concerned about the fact that apple will reject the apps that are loading some big videos directly without HTTP live streaming.
So, is my approach wrong? Shall I load youtube video directly? Is the youtube providing HTTP livestreaming by itself?
I am curious to know these stuffs.
Thanks.
It's fine to load the YouTube video in HTML WebViews. Many apps do it this way.
The key thing to remember is that you are not allowed to autoplay videos, they have to be user initiated i.e. they have to press the play button.
Edit:
Please check this official page

How to detect that youtube has finished to play on iphone?

How to detect that youtube has finished to play on iphone ? I can't see how since youtube plays in another app or web safari.
But I have seen some apps that can play youtube video one after another so it should be but then how ?
If you're talking about integrating a movie into your app, (which I believe you'd do by loading the video URI into MPMoviePlayerController), you'd listen for MPMoviePlayerPlaybackDidFinishNotification. If you clarify your question though, I may know another method.

playing an intro video for a website on iphone and ipad

I have been doing some research into what is possible, as far as I can tell
Autoplay
Possible to autostart videos on early versions of IOS http://www.codeblog.co/getting-autoplay-working-on-ios/ although this no longer works on current version (exact version it stopped working I don't know). Behaviour seems to be the same on both the iPad and iPhone?
Playing video in page
On the iPhone videos always pop out to player, its not possible to play in page.
However is possible to play videos in page on the iPad - have tried out the videos on here and they do play inline.
http://www.html5rocks.com/en/tutorials/video/basics/
Playing as intro video
May be able to do an enter now button for the site with below code to trigger
<input type="button" value="Play" onClick="document.myMovie.play()">
https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW10
Could then on iPad make this take the full screen in page in website and use js to detect when the video finishes. Am thinking on iPhone may not be possible to detect when video finishes?
Can anyone clarify what is possible?
As much as I know intro video aren't too popular, this is a requirement for the site.
Automatic play is not possible on iOS as fas sa I'm aware. They removed support on purpose to stop people from doing it.
Any playback now requires the user to actually specify for the video to play, so providing a button to play it should be fine?
Can't you keep your video in the bundle and play it with MPMovieePlayer.Then you won't need to autoplay the video,the video will be played autometically itself.As I do the same thing.