pupunzi / jquery.mb.YTPlayer

use a custom yutube player for a video as background on jQuery framework
https://pupunzi.com/mb.components/mb.YTPlayer/demo/demo.html
1.3k stars 431 forks source link

Videos not playing on mobile browsers #487

Open KrysCrannor opened 2 years ago

KrysCrannor commented 2 years ago

I'm using a template which uses YTPlayer. While everything works on the desktop version of the site, it doesn't on mobile. I'm using version 3.3.9 and useOnMobile is set on true. Js files are untouched. The properties used are:

ratio: 16/9, containment: 'self', quality: 'default', startAt: 0, stopAt: 36, autoPlay: true, loop: true, mute: true, showControls: false, showYTLogo: false, realfullscreen: true, addRaster: false, optimizeDisplay: true, stopMovieOnBlur: true, useOnMobile: true,

jaydeete commented 1 year ago

The only way I was able to fix this was to hack the library itself. On line 702 of this file you will see that the param playsinline being set. It must be set to 1 for this to work in iPhones. For some reason the code that determines the value always evaluates to 0 ... so my solution was just to hard-code it to 1. So replace : 'playsinline' : jQuery.mbBrowser.mobile && !YTPlayer.isPlayer ? 1 : 0, with: 'playsinline' : 1,

KrysCrannor commented 1 year ago

For some reasons it still doesn't work on both my android phone and every chromium based browser on desktop when using the console in mobile mode

lchhieu commented 1 year ago

The same issue @pupunzi Do you have any idea to resolve this issue

pravingaikwad07 commented 1 year ago

its working in latest version and build. refer: https://github.com/pupunzi/jquery.mb.YTPlayer/blob/master/dist/jquery.mb.YTPlayer.js