Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[t1443] Add setter method for duration on NullVideo #295

Open
wants to merge 2 commits into from

1 participant

This page is out of date. Refresh to see the latest.
View
14 popcorn.js
@@ -245,6 +245,20 @@
// Check for no duration info (NaN)
videoDurationPlus = duration != duration ? Number.MAX_VALUE : duration + 1;
+ self.on( "durationchange", function() {
+ var byEnd = self.data.trackEvents.byEnd,
+ byStart = self.data.trackEvents.byStart,
+ newDuration = self.duration(),
+ newEndPaddingDuration = newDuration != newDuration ? Number.MAX_VALUE : newDuration + 1;
+
+ byEnd.splice( byEnd.length - 1, 1 );
+ byStart.splice( byStart.length - 1, 1 );
+ Popcorn.addTrackEvent( self, {
+ start: newEndPaddingDuration,
+ end: newEndPaddingDuration
+ });
+ });
+
Popcorn.addTrackEvent( self, {
start: videoDurationPlus,
end: videoDurationPlus
View
6 wrappers/null/popcorn.HTMLNullVideoElement.js
@@ -371,6 +371,12 @@
duration: {
get: function() {
return getDuration();
+ },
+ set: function( val ) {
+ if ( !isNaN( val ) ) {
+ player.duration = val;
+ self.dispatchEvent( "durationchange" );
+ }
}
},
View
20 wrappers/null/popcorn.HTMLNullVideoElement.unit.js
@@ -6,6 +6,26 @@ var testData = {
createMedia: function( id ) {
return Popcorn.HTMLNullVideoElement( id );
+ },
+
+ playerSpecificAsyncTests: function() {
+
+ asyncTest( "NullVideo 01 - durationchange fired after setting duration", 1, function() {
+
+ var video = testData.createMedia( "#video" );
+
+ video.src = testData.videoSrc;
+
+ video.addEventListener( "durationchange", function onDurationChange() {
+ video.removeEventListener( "durationchange", onDurationChange, false );
+
+ equal( video.duration, 35, "Null video properly had it's new duration set." );
+ start();
+ }, false );
+
+ video.duration = 35;
+ });
+
}
};
Something went wrong with that request. Please try again.