使用YouTube Iframe API内部的jquery插件来获取状态

Using YouTube Iframe API inside of jquery plugin to get state

本文关键字:插件 获取 状态 jquery YouTube Iframe API 内部 使用      更新时间:2023-09-26

我被困在使用我的jquery插件函数里面的Youtube API。它根本不起作用。我已经尝试了新的YT.player()方法,但它输出YT为不存在。

$videos = $('.video iframe');
$videos.each(function(){
    var id = $(this).attr('id');
    //use id to attach video state listener
});

如何将状态侦听器附加到每个视频以获得视频的状态?

非常感谢,我真的很感激你的帮助!
   var player = new YT.player()
    (function($, player) {
       $.fn.testPlugin= function(options) {
            console.log(player);
       }
    }) (jQuery,player);