|
991
|
1 |
/* This is a fake player, for when no video is available */ |
|
|
2 |
|
|
|
3 |
IriSP.Widgets.PlaceholderPlayer = function(player, config) { |
|
|
4 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
5 |
}; |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.PlaceholderPlayer.prototype = new IriSP.Widgets.Widget(); |
|
|
8 |
|
|
|
9 |
IriSP.Widgets.PlaceholderPlayer.prototype.defaults = { |
|
|
10 |
} |
|
|
11 |
|
|
|
12 |
IriSP.Widgets.PlaceholderPlayer.prototype.template = '<div class="Ldt-PlaceholderPlayer">(loading)</div>'; |
|
|
13 |
|
|
|
14 |
IriSP.Widgets.PlaceholderPlayer.prototype.draw = function() { |
|
|
15 |
|
|
|
16 |
this.renderTemplate(); |
|
|
17 |
|
|
|
18 |
var paused = true, |
|
|
19 |
timeDelta = 0, |
|
|
20 |
currentTime = new IriSP.Model.Time(0), |
|
|
21 |
media = this.media, |
|
|
22 |
sel = this.$.find(".Ldt-PlaceholderPlayer"); |
|
|
23 |
|
|
|
24 |
function updateTime() { |
|
|
25 |
if (!paused) { |
|
|
26 |
currentTime = new IriSP.Model.Time(new Date().valueOf() - timeDelta); |
|
|
27 |
if (currentTime <= media.duration) { |
|
|
28 |
media.trigger("timeupdate", currentTime); |
|
|
29 |
setTimeout(updateTime, 100); |
|
|
30 |
} else { |
|
|
31 |
currentTime = media.duration; |
|
|
32 |
media.pause(); |
|
|
33 |
} |
|
|
34 |
} |
|
|
35 |
sel.text(currentTime.toString(true)); |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
// Binding functions to Popcorn |
|
|
40 |
media.on("setcurrenttime", function(_milliseconds) { |
|
|
41 |
timeDelta = new Date().valueOf() - _milliseconds; |
|
|
42 |
currentTime = new IriSP.Model.Time(_milliseconds); |
|
|
43 |
media.trigger("seeked"); |
|
|
44 |
media.trigger("timeupdate", currentTime); |
|
|
45 |
sel.text(currentTime.toString(true)); |
|
|
46 |
}); |
|
|
47 |
|
|
|
48 |
media.on("setplay", function() { |
|
|
49 |
paused = false; |
|
|
50 |
timeDelta = new Date().valueOf() - currentTime |
|
|
51 |
media.trigger("play"); |
|
|
52 |
updateTime(); |
|
|
53 |
}); |
|
|
54 |
|
|
|
55 |
media.on("setpause", function() { |
|
|
56 |
paused = true; |
|
|
57 |
media.trigger("pause"); |
|
|
58 |
updateTime(); |
|
|
59 |
}); |
|
|
60 |
|
|
|
61 |
media.trigger("loadedmetadata"); |
|
|
62 |
|
|
|
63 |
} |