YouTube iframe player - trigger fullscreen on iOS

前端 未结 3 2013
旧时难觅i
旧时难觅i 2021-02-20 04:44

Using the YouTube iframe embed player, is there a way to trigger fullscreen programatically? I want to remove the default controls (using controls=0) but then have the ability t

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 05:01

    Try the following in Webkit browsers:

    if (typeof iframe.webkitRequestFullScreen === 'function') {
        button.addEventListener('click', function () {
            iframe.webkitRequestFullScreen();
        }, false);
    }
    

    Note that this won't work without a user gesture (in this case, 'click').

提交回复
热议问题