summaryrefslogtreecommitdiff
path: root/public/js/lib/views/room/playlist.js
blob: 6d81bf0ec680767b0c1eeb9eb46e0019fa2ccb0e (plain)
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
var PlaylistView = View.extend({
  
  el: "#playlist",
  
  playlist: [],
  
  index: 0,
  video: null,
  
  initialize: function(opt){
    this.video = new VideoView ()

    opt.socket.on("add", function(){
    })
    opt.socket.on("position", function(){
    })
    opt.socket.on("remove", function(){
    })
  },
  
  load: function(data){
    this.playlist = data.playlist
  },  
  
  add: function(media){
    this.playlist.push(media)
  },
  remove: function(){
  },
  
  position: function(){
  },
  
  prev: function(){
    this.go( mod(this.index-1, playlist.length) )
  },
  next: function(){
    this.go( mod(this.index+1, playlist.length) )
  },
  
  go: function(n){
    this.index = isNaN(n) ? n : this.index
    this.video.load( playlist[this.index] )
  },
  
})