I'm trying to play a video taken with an Android phone. I want it to play in Chrome on a desktop or laptop. When I run the code, I get the video controls. When I play the video, I can hear the sound, but the video part is just empty background. I can get other videos to play just fine, but not the video from my phone. In the code below, the duration reports correctly (1.8 sec), but the height and width are reported as zero. (The test video from Big Buck Bunny plays just fine.)
What am I missing? (Yes, not a professional programmer, just a HS physics teacher...)
<html>
<body>
<video width="400" controls id="theVideo">
<source src="https://noragulfa.com/random/movie3.mp4" type="video/mp4">
<source src="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" type="video/mp4">
</video>
</body>
<script>
document.getElementById("theVideo").addEventListener('loadedmetadata', function(e) {
console.log(this.videoWidth, this.videoHeight, this.duration);
});
</script>
</html>
The video (movie3.mp4) contains a HEVC/H.265 (1920x1080#30fps) video stream.
Most browsers currently do not support HEVC/H.265. At the time of writing, only Safari does have support. Edge can also play HEVC/H.265 if the device has hardware decoding.
Please consider using AVC/H.264, VP8 or VP9 instead. For future reference, AV1 would also make a great alternative but support is currently not that great yet.
Your code is perfectly fine and working, The problem is with the video source that you are using, as you can see in the below code, I just replace your video URL with another URL and it working fine. the best solution would be to change your video source.
<html>
<body>
<video width="400" controls id="theVideo">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</body>
<script>
document.getElementById("theVideo").addEventListener('loadedmetadata', function(e) {
console.log(this.videoWidth, this.videoHeight, this.duration);
});
</script>
</html>
You can you any free sites to host your video if you want, and use that URL to your code or maybe try to find another Url of the same video online.
Related
I come today with a 'fairly easy' question around using video.
I have used this before and it seems to be working on Android devices. However, I just recently realised that the same video won't work on any Apple device.
My initial thought was around the video format (which is currently MP4), so I added a 'webm' back-up. MP4 should be enough, but I just wanted to give it a try (unsuccessfully)
Am I missing something? Do I need an specific format to be able to display a video on Apple devices?
<video class="intro-header-mobile" playsinline autoplay loop muted preload="auto" width="100%" height="100%">
<source src="/medias/custom-content/projects/2021/Own-brand-hub/e0821_Ownbrand_mob_v2.mp4" type="video/mp4">
<source src="/medias/custom-content/projects/2021/Own-brand-hub/e0821_Ownbrand_mob_v2.webm" type="video/webm">
</video>
Thank you everyone!
Diana
I created a very new Cordova (6.4.0) project, placed a html5 video tag in the html body. Running the project for iOS, it works well. But for Android (6.0.0), the video plays without image UNTIL the zoom button in lower right corner is clicked.
White screen when playing the video for Android
Here is the html:
<body>
<video controls="controls" src="http://url/somemovie.MOV"></video>
<script type="text/javascript" src="cordova.js"></script>
</body>
If you mean that your video doesn't auto-play until you click on something, you may be encountering a deliberate limitation Google inserted into their mobile Chrome browser, which stops videos from auto-playing without user interaction. The reasoning behind this is because on mobile devices, bandwidth may result in charges to the user. (Hopefully they'll change their minds in future.)
However, there is a workaround for this, where you can still auto-play a video as long as it is muted by using the autoplay and muted properties. Example:
<video autoplay loop muted poster="/app/img/videos/timeapps.jpg">
<source src="/app/img/videos/timeapps.mp4" />
</video>
In the example above, I also have a poster image to display while the video content is first loaded.
I found a solution. Set the video full screen mode when it's played for android.
if (_IsAndroid()){
video = attElement.querySelector('.video');
video.src = filepath;
video.webkitRequestFullscreen();
//video.onclick = function(){document.webkitExitFullscreen();}
}
I am using WowzaServer Live Streaming type. So I am able to view Video from wowza examples directly using
http://[wowza ip address]:1935/live/myStream/Manifest - LIVE Video Streaming Silverlight Player.
http://[wowza ip address]:1935/live/myStream/playlist.m3u8 - LIVE Video Streaming iOS and MAC.
rtmp://[wowza ip address]/live - LIVE Video Streaming Flash RTMP Player
http://[wowza ip address]:1935/live/myStream/manifest.f4m - LIVE Video Streaming Flash HTTP Player
I am able to view video from browser using the above links.
I am trying to run the link from a android application and get the video running on android device. I am not able to get the video running.
I tried using the HTML video tag for HLS streaming i.e. I used this:
<video id="videohtml" width="320" height="240" controls>
<source src="http://[wowza IP address]:1935/live/myStream/playlist.m3u8" type="video/mp4">
</video>
I also tried playing it without using the type.
<video id="videohtml" width="320" height="240" controls>
<source src="http://[wowza IP address]:1935/live/myStream/playlist.m3u8">
</video>
It does not do anything. I am not able to view any video.
I also tried to play manifest.f4m stream but no video.
I also tried using the Flowplayer but it asks to install Flash on android application. I also tried using JWPlayer but no video is played.
Can some one please advise me how to play live video stream in android application. I am using Samsung S4 to play the video. I also tried into emulator.
Which is the good video player to be used to play this as there are so many video players and I am a confused as which one to use which will surely play the video on my android device.
<html>
<head>
<title>HTML5 VOD Streaming Test</title>
</head>
<body>
<video width="640" height="400" controls="controls" src="http://[wowza-ip-address]:1935/vod/[mp4:sample.mp4]/playlist.m3u8">
</video>
</body>
</html>`
It should work. Please try this.
I am getting issue in while playing video in "Android Phone's chrome Browser".
In that I am putting HTML5 video tag and providing m3u8 file's link as a source of video tag.
But it does not play in "Android's chrome browser".
But if I provide same m3u8 file's link to browser than it plays the video in Android's video player.
So what should be done to play video in HTML5 video tag?
Note: I have checked this with Android 4.0.3 and 4.1
Thanking in Advance,
Sagar Joshi
I think it depends on the encoding, by looking at the server logs the playlists are requested, but since no webm content is found nothing is played.
That's really unfortunate because the stock browser used to play h264 videos just fine.
the hls link will not work directly on android chrome you need a hls javascript library to get it to work, have a look at this code
<video id="my-video" style="width:640px height:480px;" controls>
<source src="{put your source link here}">
</video>
</div>
<script src="http://hlsbook.net/wp-content/examples/hls.min.js"></script>
<script>
if ( Hls.isSupported() ) {
var video = document.getElementById('my-video');
var hls = new Hls();
hls.loadSource('{put your source link here}');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
}
</script>
and remember the source link will not work on android platform, it works for ios-safari platform only as ios-safari platform don't require hls javascript, since Safari mobile does not support media source extensions and thus will not work with hls.js.
So for android you need to add the video link in the script tag in hls.loadSource and it will work on android chrome.
I ended up using video.js's VHS to solve this https://github.com/videojs/http-streaming.
In my case, I was using fragmented MP4s which isn't supported by Android's native HLS support. To workaround this, you need to force VHS to override native support:
<video id="player" class="video-js" width="360" height="640" controls playsinline muted preload="auto" poster="https://example.com/poster.jpg">
<source src="https://example.com/stream.m3u8" type="application/x-mpegURL">
</video>
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
<script src="https://unpkg.com/#videojs/http-streaming/dist/videojs-http-streaming.min.js"></script>
<script>
const player = videojs('player');
player.play({
overrideNative: true // <-- this fixes Android Chrome
});
</script>
I was using hls.js before but had several issues with fragments MP4s. Definitely recommend video.js/VHS.
I have a problem in HTML5 I'm trying to show a video on the Android Emulator Browser
I'm using the following Code
<!DOCTYPE HTML>
<html>
<body>
<video width="320" height="240" controls="controls">
<source src="TJ.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</body>
</html>
It's not working
I tried to run the same code on Chrome but still not working
Any Ideas ??
Remove the type attribute from the <source> element and implement the play via the JavaScript API.
var video = document.getElementsByTagName('video')[0];
video.addEventListener('click',function(){ video.play(); },false);
A quirk of Android.
There's some useful stuff here: Making HTML5 Video Work on Android Phones.
I would suggest adding a codec property to the source tag.
More information on possible values here :
http://www.w3.org/TR/html5/video.html
As per the current updates chrome is not supporting the H.264 and its subset codecs. If your mp4 file has the H.264 codec then chrome wont play that file in video. This is my personal experience.