Insert video using <object> element - html

I'm new to HTML and need to insert a video from youtube onto my page using an element. I've tried different ways but just cannot get it to work. This is the link: https://www.youtube.com/watch?v=ZSM3w1v-A_Y
<!DOCTYPE HTML>
<HTML>
<head> <title> video </title> </head>
<body>
<object> </object>
</body> </html>

You should not use <object> to display a video. Using <object> for videos is an outdated approach. Use <video> instead
<video controls>
<source src="video.mp4" type="video/mp4">
</video>
if you really want to use <object>
<object data="video.mp4"></object>
Of course, all of this assumes you have the video downloaded. If you want to display the youtube video directly from the youtube link like your example, you will have to just embed the youtube player in your webpage with an iframe. You cannot access the raw video directly from youtube.
<iframe src="https://www.youtube.com/watch?v=ZSM3w1v-A_Y">
EDIT: For clarification, you can link to a video from another source, but YouTube does not expose the raw video itself so this is not applicable to YouTube. Also, you can technically put the YouTube link directly in an <object> as you described, but this will cause a CORS violation and therefore will not load. This also still essentially just embeds the youtube player

Related

Video source is not playing in html video tag

I have some video sources as I stated below
Sample Video Source: https://r1---sn-5hne6nsr.c.2mdn.net/videoplayback/id/be1889e136a157dd/itag/37/source/doubleclick_dmm/ctier/L/acao/yes/ip/0.0.0.0/ipbits/0/expire/3747290803/sparams/acao,ctier,expire,id,ip,ipbits,itag,mh,mip,mm,mn,ms,mv,mvi,pl,source/signature/388EE84E16EB00C9F843F9A73533592875F7AC21.4849C933939EDFCC5C988E8F948B2DACD1A5505E/key/cms1/cms_redirect/yes/mh/NQ/mip/83.162.138.194/mm/42/mn/sn-5hne6nsr/ms/onc/mt/1609252593/mv/m/mvi/1/pl/14/file/file.mp4
When I copied and pasted in the browser it is working seamlessly but when I give it to an HTML Video tag like below, it does not work.
<!DOCTYPE html>
<html>
<body>
<video controls="" autoplay="" name="media">
<source src="https://r1---sn-5hne6nsr.c.2mdn.net/videoplayback/id/be1889e136a157dd/itag/37/source/doubleclick_dmm/ctier/L/acao/yes/ip/0.0.0.0/ipbits/0/expire/3747290803/sparams/acao,ctier,expire,id,ip,ipbits,itag,mh,mip,mm,mn,ms,mv,mvi,pl,source/signature/388EE84E16EB00C9F843F9A73533592875F7AC21.4849C933939EDFCC5C988E8F948B2DACD1A5505E/key/cms1/cms_redirect/yes/mh/NQ/mip/83.162.138.194/mm/42/mn/sn-5hne6nsr/ms/onc/mt/1609252593/mv/m/mvi/1/pl/14/file/file.mp4" type="video/mp4">
</video>
</body>
</html>
What am I missing? Any idea?
I figured out why your video tag was not playing, run your HTML with all your browser extensions off, The video tag is being blocked by my adblocker. After I turned it off it was working as regular.
The reason behind it because adblockers run in a privileged mode, their operation does not trigger events in the nonprivileged script space.
To work around it you have to Detect adblockers.

Play videos with iframe in html

I want to play a video, but it is only downloading.
Here is my code:
<iframe src="videos/1.mp4" width="540" height="310"></iframe>
The Result when the page load is:
How can I play the video with iframe and not with the video tag?
Although some browsers might support this way of importing a video(Using an <iframe>) some browsers will act towards the video as a file and attempt to download it. The correct way to display a video is using the <video> tag:
<video width="540" height="310" controls>
<source src="videos/1.mp4" type="video/mp4">
</video>
See W3Schools tutorial here: video tag simple tutorial
Actually there's nothing wrong with your code!
But the problem is with IDM (Internet Download Manager) as it hooks every link that your browser is requesting and finds whether the destination you're trying to access matches what is in IDM's extensions list, so the first thing would execute after the file being requested is IDM as it has higher priority than your browser and its anyway serving as a listener inside your browser.
you either have to exclude "localhost" from the hook
or you have to remove the mp4 extension from IDM's extension list (which isnt efficient)
Just use the <video><source src="..." type="video/mp4"></video> tags.
An iframe tag is used to display another page, not used to play video. You can not play a video with that tag, whether or vimeo youtube or any other company lets you add video using a "iframe" is because they have previously configured some options on that page and have put a video. And that's why you can insert a video through an iframe.
Now if you want to force this, you should do the following:
Create a html-and in that html implement a video with the
Then from the other page write the <iframe src = "yourwebcontentvideo.html" />
And that would be it.
An iframe is an HTML element that allows an external website or webpage or document(like word, pdf) or video to be embedded in an HTML document.
Here is an example for loading an Youtube video through iframe tag on your site
<iframe width="560" height="315" src="https://www.youtube.com/embed/2d2rfsm3ApU" allowfullscreen></iframe>
Output:
<pre>
<code>
https://jsfiddle.net/anjaneyulu15/og64djL0/7/
</code>
</pre>
Original content is taken from iframeinhtml.com
You can use this, you can use the mp4 url as url parameters and return HTML VideoJS player.
https://simplevideoplayer.bubbleapps.io/
You can generate dynamic content like that:
let ifTest = document.getElementById('if-test');
let videoPath = 'https://file-examples.com/storage/fe63ea2155630fa7ba2b829/2017/04/file_example_MP4_480_1_5MG.mp4';
let videoHtml = '<html><body><video width="100%" autoplay="true" loop="true" muted="true" ><source src="' + videoPath + '" type="video/mp4" /></video></body></html>';
ifTest.setAttribute('srcdoc', videoHtml);
ifTest.setAttribute('style', 'width:264px; height:150px;')
<iframe id="if-test" srcdoc=""></iframe>

Does the html5 video tag work with windows hta?

I am writing a simple game using HTML5 and JS, to run on my own machine. I want to be able to play a video and to know when the video has finished, and I want to be able to write to a file on an external drive as a backup.
I was going to use Adobe Air, but it doesn't support the HTML5 video tag, so I tried HTA. I can't find anything on the web saying definitely if the video tag is supported or not.
<html>
<head>
<title>Test page</title>
</head>
<body>
<video id="vid_1" width="720" height="480" autoplay><source src="videos/intro.mp4" type="video/mp4"></video>
</body>
</html>
works fine in a browser, but just a blank screen as a .hta
Is the video tag supported in HTA? Or is it the video format that's the problem?
I have tried mpeg and flv, and I have tried an absolute path for the video source.
added later: using windows 7, IE11
So that HTA supports HTML5 elements, you need to add the<meta http-equiv="x-ua-compatible" content="ie=edge" /> tag. But this may not be a very good solution because then elements like frames or the <hta:application> tag don't work. Instead of the <video> tag, you can use the <embed> tag, like this:
<embed src="videos/intro.mp4" width="720" height="480" autostart="true" type="video/mp4">

YouTube URL in Video Tag

I am using the <video> tag, and I want to use any URL from YouTube in it.
I have this http://jsfiddle.net/wCrNw/ but it's not working.
I have checked this Show Youtube video source into HTML5 video tag? but that is not solving my problem.
<video controls="controls"
class="video-stream"
x-webkit-airplay="allow"
data-youtube-id="N9oxmRT2YWw"
src="http://www.youtube.com/watch?v=OmxT8a9RWbE"
></video>
MediaElement YouTube API example
Wraps the YouTube API in an HTML5 Media API wrapper, so that it can be programmed against as if it was true HTML5 <video>.
<script src="jquery.js"></script>
<script src="mediaelement-and-player.min.js"></script>
<link rel="stylesheet" href="mediaelementplayer.css" />
<video width="640" height="360" id="player1" preload="none">
<source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" />
</video>
<script>
var player = new MediaElementPlayer('#player1');
</script>
Video tag supports only video formats (like mp4 etc). Youtube does not expose its raw video files - it only exposes the unique id of the video. Since that id does not correspond to the actual file, video tag cannot be used.
If you do get hold of the actual source file using one of the youtube download sites or soft wares, you will be able to use the video tag. But even then, the url of the actual source will cease to work after a set time. So your video also will work only till then.
The most straight forward answer to this question is: You can't.
Youtube doesn't output their video's in the right format, thus they can't be embedded in a
<video/> element.
There are a few solutions posted using javascript, but don't trust on those, they all need a fallback, and won't work cross-browser.
This would be easy to do :
<iframe width="420" height="345"
src="http://www.youtube.com/embed/XGSy3_Czz8k">
</iframe>
Is just an example.
This will give you the answer you need. The easiest way to do it is with the youTube-provided methods. How to Embed Youtube Videos into HTML5 <video> Tag?
According to a YouTube blog post from June 2010, the "video" tag "does not currently meet all the needs of a website like YouTube" http://apiblog.youtube.com/2010/06/flash-and-html5-tag.html
Try this solution for the perfectly working
new YouTubeToHtml5();

Video tag in HTML5 deos not works when youtube url is given

HTML code :
<!DOCTYPE HTML>
<html>
<body>
<form>
<video width="320" height="240" controls >
<source src="http://www.youtube.com/watch?feature=player_detailpage&v=kalbVE9QgMs" type="video/mp4">
no support
</video>
</form>
</body>
</html>
Getting this:
The Browser is chrome. The youtube url is accesible but not works when put inside video tag.
You must include the URL of an actual video file within a <video> tag. A YouTube URL like the one in your example is not the URL for a file but rather a webpage containing an embedded player, comments, links to other videos, etc.
With YouTube videos, you must use their embed code on your page for it to work reliably over the long term.
<iframe width="560" height="315" src="//www.youtube.com/embed/kalbVE9QgMs" frameborder="0" allowfullscreen></iframe>
You need to use some external js library like MediaElement.js
Here is the example http://mediaelementjs.com/examples/?name=youtube