Using "Gifs" in Safari and IOS: Videos won't autoplay - ios

Instead of using true gifs, we are using mp4 videos that loop (in order to save load time)
However, Safari is refusing to autoplay the videos, even with autoplay loop muted playsinline.
Is there a way to create looping videos/gifs that do not require large file sizes and can autoplay in mobile
My video tags look like:
<video preload autoplay="autoplay" muted="true" playsinline="true" loop>
<source src= 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4'>
Your browser does not support video tag
</video>
Have also tried:
<video preload autoplay muted playsinline loop>
<source src= 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4'>
Your browser does not support video tag
</video>
In some cases I want the gif to start when a user scrolls to a specific point. So I use:
if (/* user scrolls to div */){
document.getElementById('my-video').play();
}
Is there a way to have videos autoplay in Safari, or any best practice alternatives?

Your HTML5 actually works fine with a different source video - the following runs in Safari 12.1.1 on Mac OSX 10.14.5:
<video preload autoplay="autoplay" muted="true" playsinline="true" loop>
<source src= 'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4'>
Your browser does not support video tag
</video>
It may be that there was be an issue with the video source you were using or the network or server it is on - for example, it is very slow loading and won't play in Chrome or Safari when I test it directly.
If you are seeing the same issue with another video, it may be that there is a format issue or that there is some server to safari indication issue which have been seen previously, although the root cause is not clear at this time: Safari 9.0 can not play mp4 video on the storage server
Either way, there is nothing obvious wrong with your original HTML5 above.
For iOS, there are specific auto play rules - at the time of writing these are the most recent AFAIK (https://webkit.org/blog/6784/new-video-policies-for-ios/):
By default, WebKit will have the following policies:

Related

Adding Loop Feature To HTML5 Video Streaming Link

At work we given a link to a video in our network to use for HTML5 video streaming that plays an mp4 video. Is there a way to add a string to that link that will loop the video or refresh the link at video's end. Below is a made up link but if that were real, can any extension be added to that that would work? Additionally, is having the video open muted or unmuted an option to add to the link as well or are these options something that have to be done in code through JavaScript or something like that?
https://www.examplelink.com/video/stream/12345.mp4
Thanks !
you can use the loop feature,
<video src="https://www.examplelink.com/video/stream/12345.mp4" type="video/mp4" autoplay loop> </video>
If you want to see an example of documentation, click here.

Play mp4 file from webapp directory

I want to play video file in my application, so I write below code for the same
<video width="640" id="videoPlayer" style="background:black" autoplay controls>
<source src="/cam01/2017-11-07_17-04-25.mp4" type="video/mp4">
<p>Your browser does not support the video tag.</p>
</video>
The cam01 folder is in Tomcat's webapp directory (/apache-tomcat-7.0.70/webapps/cam01), but I'm getting following error in console log
Even when I'm trying to hit url http://localhost:8080/cam01/2017-11-07_17-04-25.mp4 directly on browser to see video, I'm getting following error...
Here is how you can play videos on a page from the local directory or remote directory:
<video src="[ YOUR VIDEO ].mp4"
controls
width="720" height="480">
Your browser does not support the video element, please #D try downloading the video instead
</video>
Please check the compatibility of the browser that your trying to test playing in through:
https://caniuse.com/#search=video
The current state of support for the element is below:
It is also preferred if you could play webm format instead of mp4.
If it still does not work make sure you have flash installed.
https://get.adobe.com/flashplayer/

Videos on my website Monsterfilms.com are not playing on Apple devices. Why?

I'm using django and so my templates look like this:
<video playsinline autoplay muted loop poster="{{page.image.url}}" id="bgvid">
<source src="{{page.video.url}}" type="video/mp4">
</video>
The videos work fine on Linux and Microsoft but are not working on Apple devices. Why?
How are you serving the video files? If you are using Django's built in server you will find that the videos will not load due to Django's server does not support byte range requests. See this thread:
https://groups.google.com/forum/#!msg/django-developers/NZ1qTkZ6vok/fhdz7rTtL1EJ
And this ticket:
https://code.djangoproject.com/ticket/22479
I'm afraid the answer is rather mundane. I've tried using different video editing software to render the videos to h.264 codec and it now works. It seems the software I was using is not doing something right for Apple?

iPad safari html5 audio playback

I use HTML5 to play mp3 file on iPad.
I put two audio tags:
One use audio source from
http://www.schillmania.com/projects/soundmanager2/demo/_mp3/office_lobby.mp3
The other is from my local nginx server, the mp3 file is download
from
http://www.schillmania.com/projects/soundmanager2/demo/_mp3/office_lobby.mp3
After I click play button on audio player controls, both of them can play.
The remote one can playback; but mp3 from my local nginx can't playback, it always shows 'streaming...' even after the mp3 playing is done.
The HTML5 code is below:
<p>Remote</p>
<audio controls="controls">
<source src="http://www.schillmania.com/projects/soundmanager2/demo/_mp3/office_lobby.mp3" type="audio/mpeg" />
Audio not support!
</audio>
<p>Local Nginx</p>
<audio controls="controls">
<source src="http://192.168.1.100/office_lobby.mp3" type="audio/mpeg" />
Audio not support!
</audio>
I want to know why two audio controls behave diffrently.
Is it nginx configuration problem?
Similar problems happened for me too.
You may check the audio URL directly in the browser. If you meet "403 Forbidden" issue, that means your local mp3 has wrong permission.
Hope it's helpful.

How can I embed Youku or Tudou videos in my iOS app?

Or open them in a UIWebView? Their videos are in .swf format though.
Thank you.
EDIT: Okay, so I can get it to play in UIWebView, also when you click on the video in the UIWebView it will play the video in fullscreen. So am wondering if I can just get the code of when it clicks to fullscreen, and use it in some button I have.
Did that make sense?
Oh and thank you again.
Try embed the iframe snippet from Youku into your webview
<iframe height="498" width="510" frameborder="0" allowfullscreen
src="http://player.youku.com/embed/XNTY4ODU0NzQ0"></iframe>
I got it working on Android, but not tried it on iOS yet.
<video width="480" height="320"
src="http://v.youku.com/player/getRealM3U8/vid/XMzkxMTM3MDQw/type//video.m3u8"
controls>
<embed src="http://player.youku.com/player.php/sid/XMzkxMTM3MDQw/v.swf"
allowFullScreen="true" quality="high" width="480" height="320"
align="middle" allowScriptAccess="always"
type="application/x-shockwave-flash"></embed>
</video>
Just use the above HTML in a UIWebView for Youku. It can be played on iOS device and PC. Replace the XMzkxMTM3MDQw with the corresponding code of the video.
As you will easily be able to verify on the internet, Flash (.swf) is not supported on iOS devices. Maybe they offer their videos in another format, otherwise this won't work.
Update: I guess you're just opening the website in your web view. So that means on their web site they have an iOS compatible stream. You can fetch the stream data from the website's source code and build your own web site (stored locally on the device) that only displays that video stream in an UIWebView. Or you use MPMoviePlayer or HTTPLiveStream, whatever. However, make sure that this is allowed/legal, I can't help you there since I guess it heavily depends on what you want to do with your app.
See here to get the url of .m3u8 file for a youku video by its ID, and simply embed it into a <video> tag

Resources