I really tried to find an answer but couldn't.
Google have changed their Autoplay Policy .
I am loading an iframe with Src to independent code, like this:
<iframe frameBorder="0" scrolling="no" allow="autoplay"
src="myurl"
width="640" height="480">
</iframe>
myurl is a path the a video player.
I want to check if 'allow="autoplay"' was passed as iframe attribute where the player code is, and the decide if to set auto play or not.
Note, that the site where the iframe is loaded is a different site' with different code and it even sites on a different server then the myurl site.
How can I do it?
It can not been done.
You need to use a promises to check if the auto play succeeded.
I used googles way of doing it.
Hope it will saves some time to someone :)
Related
Unable to play openload videos under Iframe Sandbox allow script
My Code :
<iframe sandbox="allow-scripts" scrolling="no"
src="https://oload.stream/embed/kxDLfFZqpX0"></iframe>
Yeah, they've put a mechanism against it.
sandbox="allow-scripts" would block their ads :)
Hello I'm trying to do an chrome extension,
my main purpose is detect videos on the page, and check if user watch 80% of video, some sites using iframe for videos openload, king, vk, mail.ru etc.
The main question is, am I supposed to write a specific function for every source or can I detect videos with simple tricks?
Many of sources using sort of hashing or whatever for security reasons, I can't find an specific dom element with jquery.
example site html:
<iframe id="episode_player" src="http://hqq.tv/player/embed_player.php?vid=264230257263260272277221239235213255194271217261258&autoplay=no" scrolling="no" frameborder="0" width="100%" height="495" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
my plugin:
var iframeR = $("iframe#episode_player").contents().find("video").get(0);
console.log(iframeR);
returns undefined.
for sources who use object tag, I tried this
var zazi = $("iframe#episode_player").contents().find("object").length;
console.log(zazi);
it returns 0
any idea, which can help me to find a way?
thanks.
If I understand this correctly, you can simply use Javascript for this:
W3Schools rocks
If not, correct me!
How can I remove the watch later and share buttons from youtube iframe embed player. Using the following embed code for embedding video clips.
<iframe width="854" height="480" src="https://www.youtube.com/embed/cPVgwz5aN1o" frameborder="0" allowfullscreen></iframe>
Using showinfo=0 removes the full Header which also contains the Video Title.
Is it possible to only remove "Watch Later" and "Share" buttons from the header?
Using YouTube embed's privacy-enhanced mode (youtube-nocookie), it will hide "Watch later" button, but not "Share" button.
<iframe width="854" height="480" src="https://www.youtube-nocookie.com/embed/cPVgwz5aN1o" frameborder="0" allowfullscreen></iframe>
This parameter is deprecated and will be ignored after September 25, 2018.
As an example, this is what you're trying to do:
document.getElementsByTagName('iframe')[0].contentWindow.getElementsByClassName('ytp-watch-later-button')[0].style.display = 'none';
But, short answer, there is no simple way to do this, because YouTube is on a different domain:
'Not possible from client side . A javascript error will be raised "Error: Permission denied to access property "document"" since the Iframe is not part of your domaine...'
https://stackoverflow.com/a/30545122/2488877
Though, you might find an answer suitable to your needs if you're tech-savvy in the answers to the question above.
I don't think it is possible with the iframe method.
My reasons for thinking that is:
It is not an option listed on their parameters page
I found this thread where a member of their team said it was not possible at the time (2012), and they had no plans to add the ability.
You could probably achieve something similar by turning showinfo off, and using the other methods to grab the video title.
Add this line after link
https://www.youtube.com/embed/c5cHjtspa7M?mode=opaque&rel=0&autohide=1&showinfo=0&wmode=transparent
It will disable the share and watch later option
showinfo
Note: This parameter is deprecated and will be ignored after September 25, 2018.
Supported values are 0 and 1.
Setting the parameter's value to 0 causes the player to not display information like the video title and uploader before the video starts playing.
If the player is loading a playlist, and you explicitly set the parameter value to 1, then, upon loading, the player will also display thumbnail images for the videos in the playlist.
https://developers.google.com/youtube/player_parameters
In the url params put the params : showinfo=0.
Like this : https://www.youtube.com/embed/youidvideo?autoplay=1&rel=0&showinfo=0
It will remove share and watch later button!
Use a url query string ?controls=0 to control what is shown:
<iframe
src="https://www.youtube-nocookie.com/embed/j8xbAwurfgo?controls=0&rel=0&modestbranding=1&origin=https://key.bio"
frameborder="0"
allow="encrypted-media;"
allowfullscreen>
</iframe>
YouTube Player API Reference for iframe Embeds
https://developers.google.com/youtube/iframe_api_reference
Note: this only worked for me on Chrome, not Firefox! Took me a while to figure this out because I use FF for webdev
<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=false' frameborder='0'></iframe>
after this code I have next error
Refused to display 'https://docs.google.com/a/myrussiaonline.ru/viewer?url=https://docs.google.…ormat%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=false' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
If I set
<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=true' frameborder='0'></iframe>
Then, all fine
Can I set &embedded=false and have correct render without error?
Thanks
The only way I've found to get the Google Docs Viewer to work in an iframe is:
<iframe src="https://docs.google.com/viewer?srcid=[YOUR_FILE'S_ID_HERE]&pid=explorer&efh=false&a=v&chrome=false&embedded=true" width="800" height="600" style="border: none;"></iframe>
Try this tutorial-
https://www.youtube.com/embed/A5SkbcId-v0
U should have your answer.
Update-
According to Google Policy, if u like to have your document viewed with a iFrame, then embedded=true should be in the URL.
Demo Code-
<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=true' frameborder='0'></iframe>
First you should go to your document on google drive :
click file
publish to the web
embed
publish
You will get the code of the iframe you can use it to visualize your spreadsheet without the possibility to edit it
No, you can not, this parameter is specify that source would be embedded. And the idea behind using it is to avoid clickjacking attacks
Problem
I'm working with a site where the developer coded an embedded youtube video to change via a script altering the iframe's src tag.
I need to mute this element, and while I'm aware that a few libraries allow me to embed a video via script with the option of muting, I'm unaware of any way to use those methods without having to rescript everything that has been done on the youtube player. What's the best option here?
element
<iframe id="tv" width="100%" height="100%" src="http://www.youtube.com/embed/9NFUgVa68hw?autoplay=1&rel=0&controls=0&showinfo=0&disablekb=1&iv_load_policy=3&modestbranding=1" frameborder="0" allowfullscreen></iframe>
script
var channel1 = "http://www.youtube.com/embed/dFU6Cy4Hd5A?autoplay=1&rel=0&controls=0&showinfo=0&disablekb=1&iv_load_policy=3&modestbranding=1";
$("#channel-1").click(function(){
$("#tv").attr("src", channel1);
$(".mid-bar").text("TNT");
});
The above is just one module of the script; there are 22 channels.
Again, I'm trying to mute the embedded video without having to rescript the src changes. How can this be done?
I understand you don't wish to change the src, however, if you append enablejsapi=1 you can then use javascript to mute the video by calling object.mute()
Reference: https://developers.google.com/youtube/js_api_reference#Playback_controls