-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscripts.js
103 lines (91 loc) · 4.43 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(function($){
'use strict';
$(document).ready(function(){
$("#jplayer_viewport").jPlayer({
ready: function (event) {
var self = this;
var $this = $(this);
$this.jPlayer("setMedia", {
title: "Гацуурхан",
mp3: "media/gatsuurhan.mp3",
poster: "jplayer/viewport.jpg"
});
$this.append($('<div id="karaoke_lyrics" data-index="-1"><span class="word">jPlayer, HTML, CSS3 Karaoke</span></div>'));
$.post( $this.jPlayer("option", "lyrics"), {}, function(data){
window.karaoke_stimes = [];
window.karaoke_etimes = [];
window.karaoke_current_index = -1;
window.karaoke = $(data);
$(data).find('karaoke > add').each(function(index){
var st = $(this).attr('startTime');
var et = $(this).attr('endTime');
var sts = st.split(':');
st = parseFloat(sts[0], 10)*60*60 + parseFloat(sts[1], 10)*60 + parseFloat(sts[2]);
$(this).attr('startTime' , st);
window.karaoke_stimes.push(st);
var ets = et.split(':');
et = parseFloat(ets[0], 10)*60*60 + parseFloat(ets[1], 10)*60 + parseFloat(ets[2]);
$(this).attr('endTime' , et);
window.karaoke_etimes.push(et);
});
$this.jPlayer("play");
setTimeout(function(){
$('#karaoke_lyrics').html($(data).find('details singer').text() + ' - ' + $(data).find('details name').text());
}, 3000);
});
},
lyrics: "media/gatsuurhan.xml",
swfPath: "jplayer/",
supplied: "mp3",
size: {
width: "570px",
height: "340px",
cssClass: "jp-video-360p"
},
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true,
timeupdate: function(event){
var $karaoke = window.karaoke;
var currentTime = event.jPlayer.status.currentTime;
if( $karaoke!==null && window.karaoke_stimes ){
var md = parseInt(window.karaoke_stimes.length/2);
var si = 0;
if( currentTime>window.karaoke_stimes[md] ){
si = md;
md = window.karaoke_stimes.length;
}
else{
si = 0;
md = md+1;
}
for( var i=si; i<md; i++ ){
if( currentTime>=window.karaoke_stimes[i] && currentTime<=window.karaoke_etimes[i] && i>window.karaoke_current_index ){
$('#karaoke_lyrics').html("");
var sumDuration = 0;
$karaoke.find('karaoke > add').eq(i).find('entry').each(function(){
var $layer = $('<span></span>').text( $(this).text() );
var $text = $('<span class="word"></span>').text( $(this).text() ).append($layer);
var duration = parseInt($(this).attr('duration'))/1000;
$text.css({
'-webkit-transition-duration': duration+"s",
'-moz-transition-duration': duration+"s",
'-ms-transition-duration': duration+"s",
'-o-transition-duration': duration+"s",
'transition-duration': duration+"s"
});
setTimeout(function(){$text.addClass('animate');}, sumDuration);
sumDuration += duration*1000;
$('#karaoke_lyrics').append($text);
});
window.karaoke_current_index = i;
}
}
}
}
});
});
})(jQuery);