// Store track event history data
history: [],
+ // Stores ad-hoc state related data]
+ state: {
+ volume: this.media.volume
+ },
+
// Store track event object references by trackId
trackRefs: {},
// an object with defined methods
Popcorn.extend(Popcorn.p, (function() {
- var methods = "load play pause currentTime playbackRate mute volume duration preload playbackRate " +
+ var methods = "load play pause currentTime playbackRate volume duration preload playbackRate " +
"autoplay loop controls muted buffered readyState seeking paused played seekable ended",
ret = {};
return this;
},
+ // Mute the calling media, optionally toggle
+ mute: function( toggle ) {
+
+ var event = toggle == null ? "muted" : "unmuted";
+
+ // If `toggle` is explicitly `false`,
+ // unmute the media and restore the volume level
+ if ( toggle === false ) {
+ this.media.muted = false;
+ this.media.volume = this.data.state.volume;
+ }
+
+ // If `toggle` is either null or undefined,
+ // save the current volume and mute the media element
+ if ( toggle == null ) {
+ this.data.state.volume = this.media.volume;
+ this.media.muted = true;
+ }
+
+ // Trigger either muted|unmuted event
+ this.trigger( event );
+
+ return this;
+ },
+
+ // Convenience method, unmute the calling media
+ unmute: function() {
+ return this.mute( false );
+ },
+
// Get the client bounding box of an instance element
position: function() {
return Popcorn.position( this.media );