MP4 files not playing in Safari on Iphones
-
Enable Video Autoplay
Video elements that include <video autoplay> play automatically when the video loads in Safari on macOS and iOS, only if those elements also include the playsinline attribute. For more information on inline playback, see Enable Inline Video Playback.By default, autoplay executes only if the video doesn’t contain an audio track, or if the video element includes the muted attribute. Video playback pauses if the element gains an audio track, becomes unmuted without user interaction, or if the video is no longer onscreen (either by CSS or due to the user scrolling the page). The video doesn’t pause unless the user clicks or taps the video. This same expectation applies to WebRTC one-way video conferencing. For more information on WebRTC playback controls, see Add WebRTC Playback Controls.
Autoplay video when the user expects it to autoplay in your website. For example, autoplay video in interfaces where video playback is the purpose of the webpage, like a video-sharing or hosting website.
Source: https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari/
-
@danielreyes61 I tested this one a iphone and can confirm mp4 does not play. But I could not play the mp4's in https://samplelib.com/sample-mp4.html either . So, seems like some iphone issue. It's not my iphone so I didn't test this further.
-
Mmmm, that's interesting.
The videos on that page do not load on my Chrome/Firefox on linux either. If I download the file and play them via vlc or some other media player, they work fine!Edit: see below
-
This is ... crazy. The file loads fine on Chrome/Firefox on linux if I load the file directly. So, this is something related to video tag and h264. Curiously, the video tag works just fine in Android's Chrome and Firefox .
-
OK, so it seems on the desktop , the full file has to be "downloaded" before it can start playing. I can confirm that the site works fine everywhere. It only doesn't work on iphone - this I don't know why.
-
@danielreyes61 I could reproduce this issue with the mp4 at https://mobamotion.mobatek.net/samples/sample-mp4-video.html . Maybe the earlier site I mentioned has some other mp4 issue. But with the file in think link, the page loads fine and plays the video on safari. But via xbackbone, it does not work.
-
I know the issue is not cloudron related but still can't resist debugging The issue is to do with range requests not being handled properly by XBackBone . https://stackoverflow.com/questions/30199261/why-wont-safari-play-file-without-extension-in-video . Seeing if the fix is trivial, otherwise we have to report it upstream.
-
I have opened an issue upstream - https://github.com/sergix44/XBackBone/issues/557
-
@girish I've confirmed, all that is needed is to remove the autoplay attribute from the video html tag and everything will work on iphones, I spun up a separate docker container on a fresh ubuntu vm and it is working after editing the template resource files that I listed above.
-
@danielreyes61 when I tested it, it was not working even without autoplay . What is your patch? Did you only remove
autoplay
in public.twig and nothing else (and clear cache) ? -
@girish oh I didn't clear the cache, I didn't fully understand that cache is created on demand, I looked in about 6 cache folders for the autoplay tag and removed it and it worked. I removed it from the audio only element and the video element as well, so to summarize: removed in twig and in cache. Did you confirm in chrome developer tools that the tag was removed? It's late in my shift and I'm getting sleepy so I'm trying to be clear. I usually skip steps when I'm writing once I get tired. Hope this makes sense.
-
@danielreyes61 I tried this again. As you said, without
autoplay
it works on iphone. But the same thing doesn't work on desktop safari though Looks like something upstream to fix. -
@girish or leave autoplay and add playsinline attribute and see if it works then.
Enable Video Autoplay
Video elements that include <video autoplay> play automatically when the video loads in Safari on macOS and iOS, only if those elements also include the playsinline attribute. -
@danielreyes61
playsinline
doesn't seem to help on desktop safari. It does play inline on iphone . Funnily, iphone shows negative values in the time slider! And seek doesn't work either. I think it's all to do with the app not doing byte range requests properly.