How to play a flv video in html5 - javascript

i have a video player
<video id="myMovie">
<source src="vids/flv640x480/4fa2ab38f9237e9f2515812ee7fec1961d9c78d1.flv">
</video>
Now this video is not able to play in my browser chrome because its unsupported therefore i know flash is the way out but what do i need to do with flash. Install it on my server or what ?
Please anyone is there with a good explanation and steps of how to play flv videos in any browser ?

flv videos is not compatible with video tag
You have 2 options from here:
1.You use flash based video players (i.e. Flowplayer) or create your own
Here's a sample usage of flow player:
<!-- player container-->
<a href="http://yourwebsite.com/yourflvvideourlhere.flv" class="player"
style="display:block;width:425px;height:300px;margin:10px auto"
id="player">
</a>
// install flowplayer
$f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf");
Convert your video file to a format that is compatible with video tag (i.e. mp4, webm)

Related

Change video source with Javascript in html without refreshing the page just the video

My team and I are making a custom html video player and I'm working on a setting panel
And the first option we are mainly worried about so I'm adding first is the video quality option.
<video id="video" class="nm" poster="the poster url">
<source src="video source url of the video at 480p" type="video/mp4" size="480">
<source src="video source url of the video at 720p" type="video/mp4" size="720">
<source src="video source url of the video at 1080p" type="video/mp4" size="1080">
</video>
And now what we want to do is when the user toggles on an option it will change the video source to the source that has the quality specified by the size attribute
Image reference here
PS: We are making a video player from scratch as It is on its own built with no APIs (e.g. Video.js, JWPlayer, Plyr) We are making all the things needed from scratch with pure javascript and html... and as we're making a website for streaming, and my team and I want to make a video player made by us for the website, and "maybe" later for distribution but for now we want to make a brand new video player and were just been putting this part off as we aren't sure of the best way to do this!
Edit
Also, we want the video to pause and change the quality and pick up off where it was paused
Note that for the native video the browser will decide which <source> to show and choose the first element it supports/understands (e.g. the first supported video file format): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#Usage_notes
To circumvent that and force the browser to show a certain video source url, put in only one <source> element and manipulate the source property with javascript.
To pause and play the video in the native HTML5 video player you may use the API of the HTMLMediaElement: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
It has the play and pause functions you're looking for.

Vimeo direct file source and playback quality on web

I recently upgraded my account on Vimeo to be able to get my direct source file on a MP4 extension. Vimeo showed me several quality available for each of my videos.
I was wondering if there is a way to serve the user a specific quality based on its connexion?
By default I serve a SD quality video.
In the same response as the MP4 video file direct links, you should see an .m3u8 link. This link is an HLS manifest file that is used for adaptive streaming. You'll need to check if the player you're using supports HLS.
HLS documentation can be found here: https://developer.apple.com/streaming/
Thank you Tommy.
I was able to finally combine videojs + http-streaming and my .m3u8 link from VIMEO.
Note: It's important for people to have a VIMEO pro account if you want to be able to get your video source URL. Also the type must be ="application/x-mpegURL" and not the default "video/mp4".
<video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
<source src="https://example.com/index.m3u8" type="application/x-mpegURL">
</video-js>
<script src="video.js"></script>
<script src="videojs-http-streaming.min.js"></script>
<script>
var player = videojs('vid1');
player.play();
</script>

How to control any embedded video?

I scraped some videos, and displayed them with iframes. That works well, however, I am now looking for a way to control these videos on my react app.
What i mean by control is for instance: pause, play, currentTime in video...etc.
I have tried several things so far.
html5 tags, but it does not work mp4 video link that I have.
A few packages, like jplayer or player.js.
I am pretty sure I can achieve my goal, I guess I just need to find the right tool.
EDIT: Here is a example of my code with video.js
<video
id="my-player"
class="video-js"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png"
data-setup='{}'>
<source src="https://openload.co/embed/myvideo" type="video/mp4"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
Take a look at video.js. It will give you a complete control over your video playback. Take a look at their advanced examples.
Also, you don't need iframes to work with videos. If that is a design decision then it's fine but you can do video embeds without iframes.
To control video player instance via js refer to following
JS
var myPlayer = videojs('example_video_1');
HTML
<video id="example_video_1" data-setup="{}" controls="">
<source src="my-source.mp4" type="video/mp4">
</video>
Then you can control the player instance like following
myPlayer.play();
myPlayer.pause();
myPlayer.currentTime(120);
Please look at the player API in the following link
https://docs.videojs.com/docs/api/player.html
Please look at react component implementation in the following link
https://docs.videojs.com/tutorial-react.html

HTML5 video tag doesn't work on mobile

I have TV video stream (which is apparently mpeg-ts stream), if I use html5 video tags it all works find on win/mac machines using Chrome.
<video id="player1" width="640" height="360" preload="none" controls playsinline webkit-playsinline>
<source src=""http://192.168.1.72:9981/stream/channelid/2013555866?ticket=388550710ddf21ad5c6ffd61fcd3d0dc24cf46d2&profile=matroska type="video/webm">
</video>
But that doesn't work on Android tablet nor on iOS.
I have tried installing multiple different JS player, such as mediaelement, plyr, video.js, mpegts... And I have installed like all three browsers on Android tablet - Chrome, Opera and Mozilla for testings. Every single JS player works fine if I watch the video from my laptop (Chrome), but none of them works when I access from Android device.
The furthest I can get is using Opera+plyr(or video.js) to get an audio playing fine, but with a black screen, no video.
add this as your video starting tag and it will autoplay for android and safari mobile :
<video autoplay="" muted="" loop="" playsinline="" id="vid" preload="auto" width="100%" height="100%">
you also need mp4, ogv and webm formats for crossbrowser
This might work for you. It works fine for me.
<video autoplay="autoplay" loop="loop" muted defaultMuted playsinline>
I would try enabling controls as on iOS if your video is supposed to start automatically it will not allow it.
Another thing is to try adding an HTTP Range Header, it helps to split video into byte ranges which is something to take into mind with mobile. This is more for iOS in general but take a look at this link: http://fdiv.net/2013/05/17/getting-html5-video-work-ios-mobile-safari
Also as mentioned by other check the format of your video you should ALWAYS have multiple types available.
Video tag doesn't work on mobile. What I've seen people do lately is use gif's as the poster of the video on mobile. I would also look into tools like Wistia for extra video support. Gifs work on mobile, but as the video assets, they take a while to load since they're usually big.
I don't recommend self-hosting as you won't have a ton of support such as slowly loading the video or dynamically switch from 320p version to HD version as it loads, etc.
For example https://wistia.com/learn/marketing/boost-engagement-with-gifs
If you're using a separate host for your files, its server should have a valid SSL certification like my case. My android video player did not work until I added a certification.

Play video in client side

I'm developing a website using MVC5-html5(actually it will only has a limited number of user,may be 5-10 ). Now, I play video through video tag in html5.
<video width="400" controls>
<source src="myVideo.webm" type="video/webm">
Your browser does not support HTML5 video.
</video>
But in order to load the video, It takes time to get the video file from my server to clients and sometime it gets lagging. I wonder is it possible for me to let my client save these videos in their PCs and for the next time, we read direct video from there(let's say from C:\temp folder). Don't need to download from the server again.
Thank you for any though/ suggestion.

Categories

Resources