TubePlayer 插件 视频当前时间与 jquery ui 滑块同步
只是一些资源可以帮助我找到解决方案:)
- 功能齐全的 Chromeless 播放器仅缺少 ui 滑块与视频当前时间的同步: http://jsfiddle.net/GR7Z2/45/
- jquery UI滑块文档http://jqueryui.com/demos/slider/#option-value
- 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 :)
- Fully functioning Chromeless player lacking only ui slider synchronisation with video current time : http://jsfiddle.net/GR7Z2/45/
- jquery UI slider documentation http://jqueryui.com/demos/slider/#option-value
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在寻找与您在这里构建完全相同的解决方案。
感谢您的滑块功能!
我通过这样做完成了脚本:
希望它有帮助!
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:
Hope it helps!