5

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

Comments
  • 1
    use the player api
  • 0
    @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
  • 0
    @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
  • 0
    @LastDigitOfPi didn't found anything yet
  • 0
    @LastDigitOfPi I know, right?
  • 0
    @LastDigitOfPi I don't follow
  • 0
    @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
  • 1
    @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();
  • 0
    @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?
  • 0
    @Kimmax yeah that's really odd, btw you'll need to spoon feed me that code ? Because I'm really really new to js
  • 0
    Fucking CORS is blocking my frame to be accessed by contentWindow
Add Comment