Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Kimmax I do not want to depend on that, plus I want to do it the custom way, if that's possible,
the desktop version works just fine with &autoplay=1 but for some reasons it does not works for mobile devices -
@LastDigitOfPi this is the YouTube video, z-index it you can see a fallback image and an svg button, now if you click on that button it'll show YouTube play button,
The video should be played when svg is clicked but it shows YouTube play button
On desktop the desired behaviour works but on Mobile devices it doesn't
I want to do the same for mobile devices
&autoplay=1 doesn't works on mobile -
@LastDigitOfPi That would do the job, but I want to do with iframe
secondly, $('.ytp-cued-thumbnail-overlay button').click();
this works sometimes in console and sometimes doesn't -
Kimmax111066y@dextel2 it doesn't work because that btn is inside the iframe and therefore isn't included in your usual document scope. You need to grab the scope of the iframe and than call it in there.
Try something like this:
var iframe = document.getElementById("ytFrame");
var btn = iframe.contentWindow.document.getElementById('somePlayBtn');
btn.SomeFunction(); -
Kimmax111066y@dextel2 in the (chrome) devTools console you can specify the scope of the console, maybe it's set to the iframe when it works and to the site when it doesn't?
-
@Kimmax yeah that's really odd, btw you'll need to spoon feed me that code ? Because I'm really really new to js
I'm worried that this question will probably get downvoted on SO and I cannot post from my account as well, so here it is..
How to play youtube embedded video in mobile over a custom button / svg / image ?
One idea I'm currently working on is to trigger &autoplay=1 onclick but it is only appending that parameter to existing URL?
Please let me know if you have any thoughts, and I'm doing this for only mobile devices only
P.S I cannot use YouTube API
question