Open newmuis opened 6 years ago
AFAIK, the way to enable this is to always keep a video playing. We would need to experiment with it, but I would guess you could allocate a video (if the page does not have one) and play some default video on loop, while hidden.
I tried this and it's not working on iOS, also tried restarting the video in case it finished playing (causes device to go to sleep), but that didn't make the trick either...
...
vid.style['z-index'] = '-1000';
vid.setAttribute('loop', '');
vid.setAttribute('playsinline', '');
vid.setAttribute('title', 'No Sleep');
vid.addEventListener('timeupdate', () => {
if (vid.currentTime > 0.5) {
vid.currentTime = Math.random()
}
if (vid.paused) {
vid.play();
}
});
...
Poking and asking around it sounds like this is impossible in iOS 13+. The Wake Lock API seems to be underway, though.
Hmm, so on iOS 13+, if you try a story like this one, does the device sleep?
Yep, and I have that snippet above where a video is playing on repeat in the background.
Investigating a bit more since I can keep it awake by visiting sites with real videos, maybe the video I was using was faulty
The snippet you pasted above looks like:
(1) It doesn't have a source? You could try settings its source to the default source we use in stories if that helps: https://github.com/ampproject/amphtml/blob/master/extensions/amp-story/1.0/default-media.js#L21
(2) I'm not sure why you need the timeupdate
listener? Seems like you should just be able to have a muted, autoplay, looping video and it should handle that.
Yeah I omitted the source since it was a local video, and the timeupdate
listener was there since I heard some devices might go to sleep when a video has finished playing (even though video was set to loop).
For the prototype I'm just adding an amp-video
behind the story using z-index: -1000
.
<amp-video
autoplay
height="10"
width="10"
layout="fixed"
muted
noaudio
id="vid1"
loop
style="z-index: -100; position: absolute"
><source
src="./tinyvid.mp4"
type="video/mp4"/></amp-video>
this still doesn't seem to do the trick.. doing more investigations...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Some stories have the experience of being more lean-back style, with auto-advance on every page. We should keep the screen on during this, if possible.