how to observe embedded youtube video - javascript

I want to embed a youtube video on my own website and I want this youtube video not to be skipped in any way, but not to adjust its speed and to track the time it watches, but I could not find any source.
I tried to use the youtube iframe api, but I can't follow the stats without stopping or starting the youtube video there.

I would suggest that you should first download the video, and then put it onto your site through a <video> tag. The youtube iframe api is designed only for having videos that function exactly like they do on the youtube website, which includes the things you don't want.

Related

Embedded YouTube videos may not play

I have created a website that plays YouTube videos using the IFrame Player API.
Most videos played fine, but some videos didn't load properly.
One of the videos that causes problems is:
https://www.youtube.com/watch?v=mBqt_QO01bA
Website with embedded video
https://uta.inui-dondon-sukininaru.net/?sid=233
Some sites have been successfully embedded.
https://cn.noxinfluencer.com/youtube/video-analytics/mBqt_QO01bA
Therefore, you can be sure that the channel allows embedded playback of the video.
What could be the cause of embedded playback failure?

Content script for pausing youtube videos

I am currently working on a google chrome extension that features a content script for altering youtube pages. I have done some work with altering the DOM already and all of that works, however, I have been looking for solutions to have the youtube video pause when the page loads.
I initially thought perhaps I could simulate a keystroke as the spacebar pauses youtube videos. I also tried using javascript to pause the video but I don't think it works with Youtube's custom video player.
Don't feel obligated to write any code for this but if someone could point me in the right direction I would be very grateful.
On the main page of a video, the HTML5 video element playing the video has a specific class, so you can target that; and as an HTML5 video element, it has the play() and pause() methods already.
document.querySelectorAll('.html5-main-video').forEach(vid => vid.pause());
That will pause all HTML5 main videos on the page. Helpfully enough, that's the same class used by the little autoplaying video on some channel pages, so it should work for those as well :)
(Don't worry about Flash videos; YouTube hasn't supported those for years now.)

Embed YouTube Video as Background with No Ads

I know its said in Embed YouTube Video with No Ads that it is up to the content owner if ads are shown or not.
However, I think there must be a workaround if you use a YouTube video as background in HTML5.
I discovered this website http://www.lifealignmentor.com/ after checking the source code I realized its using this YouTube video. The video on YouTube has ads enabled. However on the website http://www.lifealignmentor.com/ I never saw the ads.
So is the website using a forbidden hack or is there actually a way to embed a YouTube video as background without seeing the ads?
I don't know if it helps, but I also found that the website is using the Onetone MageeWP Theme.

Embedding HTML5 video in Tumblr (dashboard and blog)

Bit curios about the possibility to embed a custom HTML5 video player into Tumblr.
How it works now is basically that you put in an URL or embed code to Youtube or any other service and it'll load up the video and show it in the dashboard feed and on your blog.
I just checked with Vimeo, and in that case it seems like it fetches a vimeo iframe with the video (I guess it's their embed code) and inject it into the DOM when the play button is pressed.
Would it be possible to mimic this behaviour with a custom iframe of my own? Make Tumblr accept my own embed code (iframe based) that leads to a HTMl5 video and also serve up a preview image before the video is actually played.
So when I'd input for example, www.mydomain.com/video1 it would recognize it as a video and have it behave like any other video service out there.
Or would it otherwise be possible to do via their API?
Just to clarify: I would not want to use the Tumblr HTML5 video player, but a player of my own chosing.
The Tumblr dashboard will only play video previews for Video Posts. Anything embed in a caption or body will not get the preview treatment.
AFAIK, the only way to get a custom video to have a preview would be for Tumblr to work with your own platform / API. Tumblr pulls in the preview thumbs when you make the Video Post, if they support the platform.
There is a list of tested video platforms / providers here: Video Posts with Auto Thumbnail(Like in Facebook) in Tumblr.com
OK
So on this tumblr the 3 posts along the top are ones I have tried.
http://nativecitizenstest.tumblr.com/
First is a Video type post but simply passing the url to tumblr.
Second is a text post but passing custom embed html from vine (this included a script which I did not know would work).
Third is a text post with an iframe in that I hand coded.
I think metcalf seems to be flash video and I don't know if that is supported, but a little googling should tell us.

Is it possible to determine if a user finished to see an embedded youtube video with the api?

I need to check if a user has actually seen an embedded youtube video (meaning that he pressed play and saw until the end). Is it possible to do this with the youtube api (javascript)?
Thank you very much
Regards
Using the Youtube API is the most easiest way determining if the user clicked the play button.
For starters check out the Google Youtube Api:
https://developers.google.com/youtube/js_api_reference
You will be needing to use the Swfobject.js to load the video to use the Youtube API controls
on loading the video don't forget to add a listener (addListener)
when the API or the video was loaded you will able to see the state of the videos , here are those:
"-1" - video is ready to play
"1" - the video is playing (it clicked the play button)
"2" - the video is paused
"0" - end of the video
Sample coding on checking the current state of the loaded video:
https://developers.google.com/youtube/js_api_reference#SubscribingEvents
If it is a chromeless YouTube player or if you embedded the video via JW Player, then it is possible.
The chromeless player will strip out the coding and allow you to embed
the YouTube video like javascript, once done, then you can embed a
Google Analytics extension snippet/code to the address of the video
and track the hits that way. Another way is installing JW Player which
allows you to easily track analytics for YouTube videos by
incorporating your Google Analytics UPI.

Categories