TubePlayer 插件 视频当前时间与 jquery ui 滑块同步

发布于 2024-12-25 02:28:56 字数 3209 浏览 1 评论 0原文

只是一些资源可以帮助我找到解决方案:)

  1. 功能齐全的 Chromeless 播放器仅缺少 ui 滑块与视频当前时间的同步: http://jsfiddle.net/GR7Z2/45/
  2. jquery UI滑块文档http://jqueryui.com/demos/slider/#option-value
  3. tikku chromeless 播放器插件文档 http://www.tikku.com/jquery-youtube-tubeplayer-plugin#tubeplayer_tutorial_3

我遇到的问题having 是将jquery滑块值设置为当前时间(以秒为单位)并与当前时间保持同步 我已经尝试过:

  var seektime = $("#youtube-player-container").tubeplayer("data").currentTime;
                $( "#slider" ).slider( "option", "value", seektime );

尽管我已经想出了如何使用滑块寻找视频中的时间 jquery 又长又乱,所以我建议在 jsfiddle http://jsfiddle.net/GR7Z2/45/ 上查看它 为了更清楚地理解,但这里是任何方式

$(".pause").hide();
$(".unmute").hide();
jQuery("#youtube-player-container").tubeplayer({
    width: 600,
    height: 450,
    showControls: 0,
    allowFullScreen: "true", 
    modestbranding: false,
    initialVideo: "Y70rcfQEK7U",
    preferredQuality: "default",
    onPlay: function(id){$(".play").hide();}, 
    onPause: function(){$(".pause").hide();$(".play").show();},
    onStop: function(){$(".pause").hide();$(".play").show();},
    onSeek: function(time){},
    onMute: function(){$(".mute").hide();$(".unmute").show();},
    onUnMute: function(){$(".unmute").hide();$(".mute").show();},
    onPlayerUnstarted: function(){},
    onPlayerPlaying: function(){$(".play").hide();$(".pause").show();},
    onPlayerBuffering: function(){$(".pause").show();}
});
$(".play").click(function(){
    $("#youtube-player-container").tubeplayer("play");
});
$(".pause").click(function(){
    $("#youtube-player-container").tubeplayer("pause");
}); 
$(".stop").click(function(){
    $("#youtube-player-container").tubeplayer("stop");
});
$(".mute").click(function(){
    $("#youtube-player-container").tubeplayer("mute");
}); 
$(".unmute").click(function(){
    $("#youtube-player-container").tubeplayer("unmute");
});

        function getYouTubeInfo() {
                $.ajax({
                        url: "http://gdata.youtube.com/feeds/api/videos/Y70rcfQEK7U?v=2&alt=jsonc",
                        dataType: "json",
                        success: function (data) {parseresults(data)}
                });
        }

        function parseresults(result) {
                console.log(result);    
                var vidlength = result.data.duration;   

                $('#vidlength').html(vidlength); 
            $(function() {
        $( "#slider" ).slider({ max: vidlength });
 $( "#slider" ).bind( "slidechange", function(event, ui) {
  var viseekto = $('#slider').slider('value');
     jQuery("#youtube-player-container")
       .tubeplayer("seek", viseekto);
});
  var seektime = $("#youtube-player-container").tubeplayer("data").currentTime;
                $( "#slider" ).slider( "option", "value", seektime );

    });
        }
$(document).ready(function () {
        getYouTubeInfo();
});

Just some resources to help to help me find a solution :)

  1. Fully functioning Chromeless player lacking only ui slider synchronisation with video current time : http://jsfiddle.net/GR7Z2/45/
  2. jquery UI slider documentation http://jqueryui.com/demos/slider/#option-value
  3. tikku chromless player plugins documentation http://www.tikku.com/jquery-youtube-tubeplayer-plugin#tubeplayer_tutorial_3

The problem I am having is setting the jquery slider value to the current time in seconds and keep in sync with the current time
i have tried:

  var seektime = $("#youtube-player-container").tubeplayer("data").currentTime;
                $( "#slider" ).slider( "option", "value", seektime );

ALTHOUGH i have already figured how to seek to a time in the video using the slider
the jquery is very long and messy soo i reccomend viewing it on jsfiddle http://jsfiddle.net/GR7Z2/45/ for a clearer understanding but here it is any way

$(".pause").hide();
$(".unmute").hide();
jQuery("#youtube-player-container").tubeplayer({
    width: 600,
    height: 450,
    showControls: 0,
    allowFullScreen: "true", 
    modestbranding: false,
    initialVideo: "Y70rcfQEK7U",
    preferredQuality: "default",
    onPlay: function(id){$(".play").hide();}, 
    onPause: function(){$(".pause").hide();$(".play").show();},
    onStop: function(){$(".pause").hide();$(".play").show();},
    onSeek: function(time){},
    onMute: function(){$(".mute").hide();$(".unmute").show();},
    onUnMute: function(){$(".unmute").hide();$(".mute").show();},
    onPlayerUnstarted: function(){},
    onPlayerPlaying: function(){$(".play").hide();$(".pause").show();},
    onPlayerBuffering: function(){$(".pause").show();}
});
$(".play").click(function(){
    $("#youtube-player-container").tubeplayer("play");
});
$(".pause").click(function(){
    $("#youtube-player-container").tubeplayer("pause");
}); 
$(".stop").click(function(){
    $("#youtube-player-container").tubeplayer("stop");
});
$(".mute").click(function(){
    $("#youtube-player-container").tubeplayer("mute");
}); 
$(".unmute").click(function(){
    $("#youtube-player-container").tubeplayer("unmute");
});

        function getYouTubeInfo() {
                $.ajax({
                        url: "http://gdata.youtube.com/feeds/api/videos/Y70rcfQEK7U?v=2&alt=jsonc",
                        dataType: "json",
                        success: function (data) {parseresults(data)}
                });
        }

        function parseresults(result) {
                console.log(result);    
                var vidlength = result.data.duration;   

                $('#vidlength').html(vidlength); 
            $(function() {
        $( "#slider" ).slider({ max: vidlength });
 $( "#slider" ).bind( "slidechange", function(event, ui) {
  var viseekto = $('#slider').slider('value');
     jQuery("#youtube-player-container")
       .tubeplayer("seek", viseekto);
});
  var seektime = $("#youtube-player-container").tubeplayer("data").currentTime;
                $( "#slider" ).slider( "option", "value", seektime );

    });
        }
$(document).ready(function () {
        getYouTubeInfo();
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笏见 2025-01-01 02:28:56

我正在寻找与您在这里构建完全相同的解决方案。

感谢您的滑块功能!

我通过这样做完成了脚本:

$( "#slider" ).slider({ 
    max: $("#video").tubeplayer("data").duration,
    stop: function(event, ui) {
        var viseekto = $('#slider').slider('value');
        jQuery("#video").tubeplayer("seek", viseekto);
    },
});
window.setInterval(function() {
    var seektime = $("#video").tubeplayer("data").currentTime;
    $( "#slider" ).slider( "option", "value", seektime );
}, 1000);

希望它有帮助!

Im looking at the exact same solution as you are building here.

Thank you for the slider function!

I've finished the script by doing this:

$( "#slider" ).slider({ 
    max: $("#video").tubeplayer("data").duration,
    stop: function(event, ui) {
        var viseekto = $('#slider').slider('value');
        jQuery("#video").tubeplayer("seek", viseekto);
    },
});
window.setInterval(function() {
    var seektime = $("#video").tubeplayer("data").currentTime;
    $( "#slider" ).slider( "option", "value", seektime );
}, 1000);

Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文