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] ) }, })