81 if (this.autostart || this.autoplay) { |
81 if (this.autostart || this.autoplay) { |
82 _popcorn.autoplay(true); |
82 _popcorn.autoplay(true); |
83 } |
83 } |
84 } |
84 } |
85 |
85 |
86 |
86 var _media = this.media; |
|
87 |
87 // Binding functions to Popcorn |
88 // Binding functions to Popcorn |
88 |
89 |
89 this.media.getCurrentTime = function() { |
90 _media.on("setcurrenttime", function(_milliseconds) { |
90 return new IriSP.Model.Time(1000*_popcorn.currentTime()); |
91 _popcorn.currentTime(_milliseconds / 1000); |
91 } |
92 }); |
92 this.media.getVolume = function() { |
93 |
93 return _popcorn.volume(); |
94 _media.on("setvolume", function(_vol) { |
94 } |
95 _popcorn.volume(_vol); |
95 this.media.getPaused = function() { |
96 _media.volume = _vol; |
96 return _popcorn.media.paused; |
97 }); |
97 } |
98 |
98 this.media.getMuted = function() { |
99 _media.on("setmuted", function(_muted) { |
99 return _popcorn.muted(); |
100 _popcorn.muted(_muted); |
100 } |
101 _media.muted = _muted; |
101 this.media.setCurrentTime = function(_milliseconds) { |
102 }); |
102 return _popcorn.currentTime(_milliseconds / 1000); |
103 |
103 } |
104 _media.on("setplay", function() { |
104 this.media.setVolume = function(_vol) { |
105 _popcorn.play(); |
105 return _popcorn.volume(_vol); |
106 }); |
106 } |
107 |
107 this.media.mute = function() { |
108 _media.on("setpause", function() { |
108 return _popcorn.muted(true); |
109 _popcorn.pause(); |
109 } |
110 }); |
110 this.media.unmute = function() { |
|
111 return _popcorn.muted(false); |
|
112 } |
|
113 this.media.play = function() { |
|
114 return _popcorn.play(); |
|
115 } |
|
116 this.media.pause = function() { |
|
117 return _popcorn.pause(); |
|
118 } |
|
119 |
111 |
120 // Binding Popcorn events to media |
112 // Binding Popcorn events to media |
121 |
113 |
122 var _media = this.media; |
114 function getVolume() { |
|
115 _media.muted = _popcorn.muted(); |
|
116 _media.volume = _popcorn.volume(); |
|
117 } |
|
118 |
|
119 _popcorn.on("loadedmetadata", function() { |
|
120 getVolume(); |
|
121 _media.trigger("loadedmetadata"); |
|
122 _media.trigger("volumechange"); |
|
123 }) |
|
124 |
123 _popcorn.on("timeupdate", function() { |
125 _popcorn.on("timeupdate", function() { |
124 _media.trigger("timeupdate", _media.getCurrentTime()); |
126 _media.trigger("timeupdate", new IriSP.Model.Time(1000*_popcorn.currentTime())); |
125 }); |
127 }); |
126 |
128 |
127 function simpleEventBind(_eventname) { |
129 _popcorn.on("volumechange", function() { |
128 _popcorn.on(_eventname, function() { |
130 getVolume(); |
129 _media.trigger(_eventname); |
131 _media.trigger("volumechange"); |
130 }); |
132 }) |
131 } |
|
132 |
133 |
133 simpleEventBind("play"); |
134 _popcorn.on("play", function() { |
134 simpleEventBind("pause"); |
135 _media.trigger("play"); |
135 simpleEventBind("seeked"); |
136 }); |
136 simpleEventBind("loadedmetadata"); |
137 |
137 simpleEventBind("volumechange"); |
138 _popcorn.on("pause", function() { |
|
139 _media.trigger("pause"); |
|
140 }); |
|
141 |
|
142 _popcorn.on("seeked", function() { |
|
143 _media.trigger("seeked"); |
|
144 }); |
138 |
145 |
139 } |
146 } |