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
|
ClipPlay.Models.Sample = Backbone.Model.extend({
defaults: {
'url': '',
'start': '3',
'stop': '4',
'duration': '',
'key': '',
'player': '',
'iframe': '',
'timeout' : '',
'thumbnail' : '',
'playing' : false
},
initialize: function() {
var a = ClipPlay.Config['key_defaults'].shift();
if(a){
this.set('key', a);
}
},
in_minutes_and_seconds: function(seconds) {
var minutes = Math.floor(seconds / 60);
seconds = Math.floor(seconds);
var seconds = seconds - minutes * 60;
if (seconds < 10) {
seconds = '0' + seconds;
}
return {
minutes: minutes,
seconds: seconds
};
},
start_in_minutes_and_seconds: function() {
return this.in_minutes_and_seconds(this.get('start'));
},
stop_in_minutes_and_seconds: function() {
return this.in_minutes_and_seconds(this.get('stop'));
},
play: function() {
console.log('playing');
//play then pause
window.clearTimeout(this.get('timeout'));
this.set('playing',false);
this.get('player').pause();
this.get('player').seekTo(this.get('start'));
this.get('player').play();
this.set('playing',true);
var that = this;
var length = Math.abs(this.get('stop') - this.get('start'));
console.log(length);
this.set('timeout',setTimeout(function(){
that.get('player').pause();
that.set('playing',false);
}, length*1000 ));
}
});
|