I've a simple html page which displays an RTMP stream from nginx server and it works without any issue. Here is the working html code:
<div id="middlebox">
<h2>RTMP Stream</h2>
<video
id="uav1-video"
class="video-js"
controls
preload="auto"
width="640"
height="480"
data-setup="{}">
<source src="/hls/stream1.m3u8" type="application/vnd.apple.mpegurl" />
</video>
</div>
Now I want to integrate this functionality into Vue3 application. I added the following in <template> and <script> tag of a view component:
<template>
<div id="app" class="container">
<div>
<h2>RTMP Stream</h2>
<video
id="my-video"
class="video-js"
controls
preload="auto"
width="320"
height="180"
data-setup="{}">
<source src="/hls/stream1.m3u8" type="application/vnd.apple.mpegurl" />
</video>
</div>
</div>
</template>
<script>
export default {
name : 'View',
data() {
return{
}
},
mounted() {
let videoScript = document.createElement('script')
videoScript.setAttribute('src', './js/video.js')
document.head.appendChild(videoScript)
},
}
</script>
With the above code only video player appears on the html page but I'm unable to play the stream. I don't see the big play button which I see in the html page.
When I check the html page in the browser, I see the following exception:
Uncaught SyntaxError: Unexpected token '<' js/video.js:1
I'm not sure how to resolve this issue. Can anyone please help. Thanks
Videojs has a pretty specific way of being setup. I haven’t been able to adapt it to fully customize in Vue3 yet. But, if you look at the videojs website and navigate to the Vue instructions follow them exactly as it says and setup a component then load that component into your page it will work.
Related
I wanna set a fallback image or message if the video link is deleted or not working.
I'm not looking for a fallback image if the browser does not support tags,
is there an easy way to do so? I'm working on a page with so many videos,
thought I'd send an HTTP request using JS for each video but I might end up sending so many.
This method does work if you provide an invalid link but will will display the error message if the browser does not support the video
<video controls>
<source src="myVideo.webm" type="video/webm">
<source src="myVideo.mp4" type="video/mp4">
<p>
Your browser doesn't support HTML video. Here is
a link to the video instead.
</p>
</video>
reference from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
Update: solution using javascript FETCH API
<body>
<video controls>
<source class="link" src="<video link>" type="video/webm">
<p>
Your browser doesn't support HTML video
</p>
</video>
<p class="videoalt" style="display: none;">
Error: video link not found
</p>
<script>
const link = document.querySelector('.link')
const video = document.querySelector('video')
const videoalt = document.querySelector('.videoalt')
const linkSrc = link.src;
fetch(linkSrc).then((response) => {
if (!response.ok) {
video.style.display = 'none'
videoalt.style.display = 'block'
}
})
</script>
</body>
I want to hide the video play button which is shown in the screen , is there any way for that ? I am using html5 video player.
I am unable to add image of that here . Please check the link button , there is a image and video button is highlighted by red circle.
http://awesomescreenshot.com/02c4ocr318
Is there any way to complete this ?
Edit: code:
<div class="v" id="player">
<video id="myVideo" width="100%" height="100%" poster="1.png" controls >
<source src="nrgmom.mp4?title=0&byline=0&portrait=0" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
</video>
<!-- <iframe frameborder="0" allowfullscreen="" src="youtube.com/embed/nMehBNvN_PM"></iframe>-->;
</div>
Remove controls attribute from video element.See this documentation for further information related to video element.
mozilla video element documentation
I would recommend You to use basic html element instead of any jquery/js plugins as it does not show any play overlay by default and works just fine in all browsers with html5 support. U can also customize is via css/js.
Check out: http://www.w3schools.com/html/html5_video.asp
I want my html email videos to be responsive. So what will be the procedure for that? Please let me know.
In your HTML file , make div and paste below code there...
<object class="responsiv-video">
<video autoplay >
<source src="file_name.mp4" />
<source src="file_name.3gp" />
</video>
</object>
it is to my understanding that you want to embed a video on your site that:
Is responsive
Allows both autoplay and loop
Uses Bootstrap
This Demo Here should do just that. You have to place another embed class outside of the object/embed/iframe tag as per the the instructions here - but you're also able to use a video tag instead of the object tag even though it's not specified.
<div align="center" class="embed-responsive embed-responsive-16by9">
<video autoplay loop class="embed-responsive-item">
<source src=http://techslides.com/demos/sample-videos/small.mp4 type=video/mp4>
</video>
</div>
Responsive mp4-video
I am using a HTML video TAG to be able to show video on my website, I had enabled the function autoplay, but then the video would play on page reload. So I removed the autoplay function and I have:
<video width="600" height="315" style=" margin-bottom: 20px;" controls >
<source src="video/handi.mp4" type="video/mp4">
</video>
<script>
$('body').on('hidden.bs.modal', '.modal', function () {
$('video').trigger('pause');
});
</script>
This works well, but now when U open a modal to watch a video it will play but you have to click on start playing button and when u close the modal it will pause the video when you stopped it, if you open the same modal you can resume the video from when it was stopped.
Is there any function like auto play that when you open the modal it opens it and the video is played automatically and also I want to know if there is any reload function that when you u open any modal to watch the video it starts from the beginning not from where you stopped t.
With Refernce to the answers in this page,i've tried this for you..
Please try it..
HTML
<div id="simpleModal" class="modal">
<video id="videoContainer" controls autoplay width="560" height="315">
<source src="video/arch_1.mp4" type="video/mp4">
</video>
Close
</div>
Script
$(document).ready(function(){
$("#showSimpleModal").click(function() {
$("div#simpleModal").addClass("show");
$("#videoContainer")[0].play();
return false;
});
$("#closeSimple").click(function() {
$("div#simpleModal").removeClass("show");
$("#videoContainer")[0].pause();
return false;
});
});
Hi according to w3schools.com if you remove the autoplay, it will stop the auto play. Here's the link to the school and code.
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_video_autoplay
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
I'm facing this problem with skrollr: everything goes fine, then when adding a video, it continues playing if out of viewport, even if the div has a display:none declaration. I tried searching here and Google but couldn't find anything and at this point I'm really lost.
For reference, this is the code I'm using:
<div id="seventh" class="view" data-0="display:none;top:0%;" data-27000="display:block;opacity:0;" data-29000="opacity:1;" data-32000="opacity:0;" >
<video id="video" class="video-js vjs-default-skin" controls preload="none" width="1223" height="611" poster="img/poster.jpg" data-setup="{}">
<source src="videos/vid.webm" type='video/webm' />
<source src="videos/vid.mp4" type='video/mp4' />
</video>
</div>
any help on how to achieve this really appreciated
Use
skrollr.init({
render: function(data) {
//get current element opacity and position then play or pause the video
}
});
See http://jsfiddle.net/ybP6b/ for a working example