End events for embedded videos - javascript

I'm trying to find a way to listen for the end/complete event of a video embedded from youtube/metacafe/vimeo etc. I know this can be accomplished by things like the youtube API using onStateChange with a value of 0, but I'm curious if it can be done without having to go through the API.
For example if I have something like:
<div id="video-container">
<iframe width="420" height="315" src="http://www.youtube.com/embed/0Bmhjf0rKe8" frameborder="0" allowfullscreen></iframe>
</div>
is there anyway I can listen for the end event on the div or iframe?
kind of like this:
Javascript player for managing playlist of vimeo *and* youtube videos?
But I'm interested in adding several sources so it would be much easier if I didn't have to go through the APIs.
Thanks-

I think, it's not possible for youtube. It would be possible if you used your own flash player. You would be able to call custom javaScript function from yuor flash player.

Related

Is there a way to manipulate an embedded video using JS without APIs?

I have the following Iframe attached to my HTML code:
<iframe width="640" height="360" src="" frameborder="0" scrolling="no" allowfullscreen></iframe>
where the src can be any embedded video (like https://www.youtube.com/embed/fWa5kDtyV0w, for example). What I'm trying to do is the following: when the user pause the video, a function must be called to save the time of the video in a variable. However, I cannot find a way to this if, unless of using specifics APIs, like the one from Vimeo or Youtube (what I don't want to do, because some platforms don't have it). So, is there a way to interact with the video in the Iframe using JS or other stuff?
Extra information: In some of my tests, I got blocked by the browser by XSS.

how to create endless video autoplay in javascript and vimeo api?

I am a little bit stuck right now with a code.
In fact, I would like to create Vimeo's videos autoplay list on my website using javascript as we can see on youtube.
As you will see on the script below, the click event allows changing the iframe videos. I'd like when my first video in my list of Vimeo's iframe videos end, the second video can start automatically to play as on youtube autoplay.
Please advise.
Here is the link to my script on codepen.io
https://codepen.io/fanhatcha/pen/XQoWdR
<iframe
id="playerarea"
src=""
width="850"
height="450"
frameborder="0"
allow="autoplay; fullscreen"
allowfullscreen>
</iframe>
<ul id="playlist">
<li vimeourl="https://player.vimeo.com/video/328821953?autoplay=0&loop=1&autopause=0&background=1&responsive=true">
<li vimeourl="https://player.vimeo.com/video/328821360?autoplay=0&loop=1&autopause=0&background=1&responsive=true">
</ul>
$(function() {
$("#playlist li").on("click", function() {
$("#playerarea").attr({
"src": $(this).attr("vimeourl"),
})
})
})
'create Vimeo's videos autoplay using javascript?' that just can be!
Vimeo(so is Youtube) are standalone programs. So they'll work only in embed context and won't use JavaScript who can manage and use DOM.
To set a video to autoplay you've to log into the Vimeo application and set it using theirs parameters before sharing it to your own page.
If you could use JavaScript on a program who's not yours it's a flaw and threat for the program...certainly you did agree use and terms of the licence of using Vimeo, so you're bind to their rules.
If you want videos and use them with JavaScript there's the HTML5 API video. By the way it'll require not using a corporate program who will reccord and display the video and use your own server to do that(or any source providing a video files and not a link to the vimeo/youtube application).

Sound on youtube embed api

I'm trying to put an embed youtube video on a website but with littles tweaks.
I don't want the video to have the youtube overlay and i want it to play automatically.
I Have this:
<iframe id="player" width="560" height="315" src="https://www.youtube.com/embed/YourVideoId?autoplay=1&loop=1&modestbranding=1&rel=0&controls=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
That works fine. Well in a certain way. As I understood there is no way with this method to set a volume to the video. Because for now the video starts with the volume at its maximum and this is pretty anoying.
So I took a look at the javascript API:
https://developers.google.com/youtube/iframe_api_reference?hl=en, and with that one i managed to set the volume. But only the volume.
According to the documentation there is a way to manipulate the IFrame object in the same way as if it was generated with the javascript API (logical in fact).
But the point is , I can figure out How to do it.
If someone as any idea how to do it let me know , i'd really like to know how to dit it.
Thanks

How to get info about if video from Iframe has finished?

Lets say that our component in react renders typical youtube embeded video
<iframe width="560" height="315" src="https://www.youtube.com/embed/kMfFcxcjE_k?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
How can I know within the component that renders that iframe about if video has ended or not?
Tried to google but haven't found anything
You can call onStateChange() or check through the reference below :)
https://developers.google.com/youtube/iframe_api_reference
Similar question :
Iframe / Javascript Check if Youtube Video Ends
I think this is what you are looking for, https://developers.google.com/youtube/iframe_api_reference .
Instead of directly using iframe, you can use this JS API to control the player. But be aware of deprecations.

Using javascript instead Iframe source?

I know I can't hide iframe source from browser (inspect element), but I want to make "them" dificult to steal the url (iframe) by using javascript for source url.
If I have:
<iframe width="420" height="315" src="//www.youtube.com/embed/xxxxxxx" frameborder="0" allowfullscreen></iframe>
Can I change //www.youtube.com/embed/xxxxxxx with javascript?
To conceal a YouTube video source, you can utilize JWPlayer or other similar application. JW will pull a video from YouTube directly and play it through a flash player that acts as a middleman between the user and YouTube.
http://www.jwplayer.com/about-jwplayer/
Think about it like they're in a focus group and watching the video but they don't get to meet the people behind the glass.
For a demonstration, visit http://www.wimp.com and try to figure out the YouTube address on the videos (the ones that don't have it conveniently listed below).
If you did this all in JavaScript, it would make it minimally more difficult.
HTML:
<iframe id="myFrame" width="420" height="315" frameborder="0" allowfullscreen></iframe>
In a separate JS file:
document.getElementById("myFrame").src = "//www.youtube.com/embed/xxxxxxx";
I think this is what you are looking for dude :) This node.js plugin can protect your script as much as possible. Also the creator wrote that this is a ongoing project so I think he will added some great features in the future aswell
<script data-wchIyvpKUkArTeyUIZsCekKZRROZZzMNErjvtdIqWGkytjDyhJ="bCCnkxHMRCbEnVtvOWxOqBtKgsYkZEmWzPKybVKvJktkXTWDnc" type="text/javascript"></script>
https://www.npmjs.com/package/location-hide
why not?
iframe.src = 'url you need';

Categories

Resources