Environments
iOS 14.4.2 (safari)
chrome 91.4472.80
As I was trying to find a way to prevent my iPhone going to sleep while a browser page is opened, I found 3 ways.
use Screen Wake Lock API
https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API
call window.location.href periodically and stop it
play a video with a user interaction
For #1, this doesn't work on iPhone, should work on Android.
#2, didn't seem to work on either safari or chrome on iPhone.
#3, also didn't work (even playing a video after user interaction).
I tried https://github.com/richtr/NoSleep.js/ but didn't prevent from sleeping.
I also tried https://github.com/roldanjr/use-stay-awake and it opened a blank video in fullscreen (this maybe fixed by just adding https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-playsinline)
Then, I noticed browser version of Youtube preventing my phone from sleeping while it's playing a video (I set my sleep time for 30 seconds, and it can play a 10 min video without turning itself off).
Does anyone know what kind of technics they are using to do that?
Related
It appears that Safari 11 on iOS will pause the video capturing during a WebRTC session when the browser/tab is moved into the background; meaning the remote client will just see a black image unless the video capturing browser tab is currently in focus. I can understand why it would do that*, but I could not find any official statement or documentation about this behaviour.
* (Both for privacy and resource conservation reasons.)
Is this the expected behaviour or is there anything that can be done about this?
It looks like expected behavior in our experience. Similarly, a native iOS app cannot capture video while in background.
The behavior is the same on other platforms, e.g. Chrome on Android - both when backgrounding the browser or the WebRTC tab.
We' ve created web site with Youtube Iframe API . On the copmuter everything is playing OK, but we have problem with mobile devices. The video plays just one time. When you push the play button again it doesn't work.
We checked everything and decided that there is problem with youtube player.
I would very grateful for any solving this problem!
p.s. Devices are: Android, IOS (Phones and Tablets), browsers are Chrome and Safari
I've been having the same issue on Safari on iOS 8 -- videos will not replay after they play through to the end. Right now, I have a temporary fix in place: when you detect a state change to YT.PlayerState.ENDED (0 = ended), call seekTo(0) and then pauseVideo() on the player.
I have an app that uses AirPlay. I am using the iPad to present data on a TV. The user sets up the demo and then puts the device down and the app should take care of updating the TV even in the background state. The app is processing data in the background and I can see it is always being updated. However the AirPlay disconnects after a few minutes if nothing on the screen changes.
How can I prevent AirPlay from disconnecting?
Note:
I am not streaming video or audio. I am only presenting data using views.
Update:
After more twiddling I found that the background task dies after 10 minutes and that is when the screen dies. I tried to play a sound like https://stackoverflow.com/a/15732710/1449607 described but the AirPlay still disconnected. I am now toggling a pixel and now it seems that the screen is staying connect. There must be a better solution for displaying slowly updating data to AirPlay.
I'm trying to create an HTML5 video player to automatically start streaming video. I searched a lot but I didn't achieve my goal.
Then I found www.filmon.com, where all videos start to play automatically on iPad.
Does anyone know how they did it? I looked at their JS files, but I cannot make mine start automatically.
Apple has specifically disabled every method and workaround to autoplay video on iPads and iPhones (the "autoplay" attribute, and Javascript solutions like triggering hidden link's "onclick" event).
I have yet to find a way to autoplay on iPads and it looks like Apple is continuing to squash all efforts to do it. They state, "In Safari on iPhone OS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, autobuffering and autoplay are disabled. No data is loaded until the user initiates it."
As a quick update I just checked out Filmon.com and the videos there no longer seem to be autoplaying on an iPad. Example: http://demand.filmon.com/distant-roads-173-cnd-ontario-ca-1 autoplays on Chrome, but not on the iPad.
I don't think that iphone or ipad play streams automatically due to high traffic.
Why don't you play it manually using script at document ready?
somewhat like this:
window.onload=function(){
var audio = document.getElementById('audio');
audio.play();
}
I am writing a web app that uses HTML5 audio. I want to make sure that the user can move to a different application while still listening to the audio in the background. This works while the web app is still within Safari itself. However, when the user adds the web app to their homescreen and it has been set to allow for fullscreen access (no Safari toolbars), when they leave the app the audio does not continue to play. Does anyone know of any way to have a web app proceed while in the background?
Thanks.
I observe exactly the same thing. It's really puzzling as to why Safari, webkit on iOS I suppose really, handles it differently in the two cases.
I notice one thing that might be a small clue, when running as a home-screen'ed 'app' when you playback the audio the iOS status bar (at least on my ios4.1/iphone4) does NOT show playback indicator (blue triangle). But when using the site directly via Safari (and the sound stays in the backgroun as expected) it DOES show the playback indicator.
I think the only people who can probably answer your question are apple since it's their webkit implementation. If you haven't already I would urge you to take this up on the apple developer message boards.
For others not familiar the 'full screen access' Dan is referring to is a Safari specific meta tag that enables a bookmarked web page to open in safari 'full screen' without the location and menu bars.
While HTML5 is making progress on supporting device native features through HTML 5 APIs (such as accelerometers, etc) having true background audio seems like it hasn't really been spec'ed out yet. By background I mean when the browser is not the application that the user is currently focused on. It was only more recently that iOS even supported application multitasking which is what making the behavior from safari possible but it's a separate thing together to integrate that tightly with the OS'es native audio control features, which is what would need to happen.
This is not possible, at least not currently. You are playing the audio from the browser and when the browser closes the system kills the app, or freezes it, unless it has multi-tasking support(but that isn't allowed for web apps)
In iOS 5 and Android 4.0.3, putting a browser window to background does not stop playback. I am not sure about other versions prior to them.
You can do so with an iPhone 4. On my website, I posted a song with the simple html5 tag and I went on it with the iPhone 4. Played the song, left the app. Song runs in the background and there is even a play button on the top bar like when you listen to music on the iPod app.