OK, it works on Chrome & Firefox but not Safari. – should it?
I’ll assume you’re asking all readers and not me, because I don’t know. I’m just a guy with some answers and experience.
I suggest you dig into the safari error logs and see if something pops out. Also I don’t use OS X on a normal basis.
Alternately run the debug version of the app and run it then see what Corona says.
Look in the folder where you built to and load this file in the browser: index-debug.html
Tip: You can’t just drop the file on your browser.
Instead,
-
Install python on your machine.
-
Install SimpleHTTPServer (https://www.pythonforbeginners.com/modules-in-python/how-to-use-simplehttpserver/)
-
Open a console and cd to the folder where the file sample built to.
-
rename _index.html to _index.html
-
rename index-debug.html to index.html
-
Run SimpleHTTPServer in that folder: python -m SimpleHTTPServer 8080
-
Open the link http://127.0.0.1:8080 in your browser.
This may or may not be related, but just a heads up that different browsers and operating systems support different codecs for HTML5 video playback, and some browsers impose limitations. For example in your comment above, you referenced an m4v file which isn’t supported by iOS Safari but is by Windows Safari I believe. Additionally, modern versions of both Chrome and Safari won’t autoplay videos that have sound - a fairly recent change.
I’ve no idea whether Corona does some magic to work around these things, but you might find better results with audioless MP4. Presumably you can simultaneously play the audio track separately if need be.
Richard, you are exactly right. I removed the audio from an mp4, uploaded it to a web location, then it worked on Safari.
I also tried playing the same mp4 from the system.ResourceDirectory (and then copying from system.ResourceDirectory to system.DocumentsDirectory) which did not work. Seems there is not a system.DocumentsDirectory for HTML5. I also tried just copying the file into the directory (because I saw in the java console log that it was looking for it there) this made it find the file, but it failed to play, gave error about a “Promise rejection NotSupportedError”.
So I think we have found the answer - Safari won’t play a video with sound in the way Corona is making it play - because it is considered “autoplaying” the video.
And there is something weird about bundling video with app, but that might have been me getting something wrong.
I’ve downloaded files to the system.DocumentsDirectory in HTML5 builds before and then used those files. So, I’m pretty sure there is a system.DocumentsDirectory.
For example, this old experiment (takes a while to load): https://roaminggamer.github.io/RGDocs/pages/html5_tests/tests/askEd/
When you click the examples (only 3) they are downloaded with their assets and then run.