}
},
createDefaultContainer = function( context ) {
-
- // clear this function from future calls; we are done
- createDefaultContainer = Popcorn.nop;
+
+ var ctxContainer = context.container = document.createElement( "div" ),
+ style = ctxContainer.style,
+ media = context.media;
var updatePosition = function() {
var position = context.position();
setTimeout( updatePosition, 10 );
};
- var ctxContainer = context.container = document.createElement( "div" ),
- style = ctxContainer.style,
- media = context.media;
-
- ctxContainer.id = "subtitlediv";
+ ctxContainer.id = Popcorn.guid();
style.position = "absolute";
style.color = "white";
style.textShadow = "black 2px 2px 6px";
i++;
// Creates a div for all subtitles to use
- ( !this.container && !options.target || options.target === "subtitle-container" ) &&
+ ( !this.container && ( !options.target || options.target === "subtitle-container" ) ) &&
createDefaultContainer( this );
// if a target is specified, use that
// use shared default container
options.container = this.container;
}
-
+
document.getElementById( options.container.id ).appendChild( newdiv );
options.innerContainer = newdiv;
<p>Your user agent does not support the HTML5 Video element.</p>
+ </video>
+ <video id='video2'
+ controls preload='none'
+ width= '250px'
+ poster="../../test/poster.png">
+
+ <source id='mp4'
+ src="../../test/trailer.mp4"
+ type='video/mp4; codecs="avc1, mp4a"'>
+
+ <source id='ogv'
+ src="../../test/trailer.ogv"
+ type='video/ogg; codecs="theora, vorbis"'>
+
+ <p>Your user agent does not support the HTML5 Video element.</p>
+
</video>
<h2>Choose your language</h2>
<select id="language">
test("Popcorn Subtitle Plugin", function () {
var popped = Popcorn( "#video" ),
- expects = 14,
+ popped2 = Popcorn( "#video2" ),
+ expects = 16,
count = 0,
subTop = 9001,
subLeft = 9001,
- subtitlediv;
+ subtitlediv,
+ subtitle2div;
expect(expects);
}
}
- stop();
+ stop( 12000 );
ok ( 'subtitle' in popped, "subtitle is a method of the popped instance" );
plus();
popped.subtitle({
start: 0,
- end: 1,
+ end: 2,
text: 'this is the first subtitle of 2011',
language: "en",
languagesrc: "language",
accessibilitysrc: "accessibility"
} )
.subtitle({
- start: 1,
- end: 2,
+ start: 2,
+ end: 4,
text: 'this is the second subtitle of 2011',
language: "en",
languagesrc: "language",
accessibilitysrc: "accessibility"
} )
.subtitle({
- start: 3,
- end: 4,
+ start: 5,
+ end: 7,
text: 'this is the third subtitle of 2011',
language: "en",
languagesrc: "language",
} )
.volume(0)
.play();
-
- subtitlediv = document.getElementById( 'subtitlediv' );
- popped.exec( 0.5, function() {
+ subtitlediv = popped.getTrackEvent( popped.getLastTrackEventId() ).container;
+
+ popped.subtitle({
+ start: 7,
+ end: 9,
+ text: 'instance one test'
+ });
+
+ popped2.subtitle({
+ start: 7,
+ end: 9,
+ text: 'instance two test'
+ })
+ .volume(0)
+ .play().pause();
+
+ subtitle2div = popped2.getTrackEvent( popped2.getLastTrackEventId() ).container;
+
+ popped.exec( 1, function() {
popped.media.pause();
equals( subtitlediv.children[ 0 ].innerHTML, "this is the first subtitle of 2011", "subtitle displaying correct information" );
});
- popped.exec( 1.5, function() {
+ popped.exec( 3, function() {
popped.media.pause();
});
- popped.exec( 2.5, function() {
+ popped.exec( 4, function() {
popped.media.pause();
equals (subtitlediv.children[ 1 ].innerHTML, "", "subtitle is clear" );
});
- popped.exec( 3.5, function() {
+ popped.exec( 6, function() {
popped.media.play();
});
- popped.exec( 5, function() {
+ popped.exec( 8, function() {
+ popped.pause();
+ popped2.currentTime( 8 );
+ });
+
+ popped2.exec( 8, function() {
+ popped2.media.pause();
+
+ equals (subtitlediv.children[ 3 ].innerHTML, "instance one test", "subtitle displaying correct information" );
+ plus();
+ equals (subtitle2div.children[ 0 ].innerHTML, "instance two test", "subtitle displaying correct information" );
+ plus();
+
+ popped.media.play();
+ });
+
+ popped.exec( 10, function() {
ok ( document.getElementById( 'subtitle-0' ).style.display === "none" &&
document.getElementById( 'subtitle-1' ).style.display === "none" &&
document.getElementById( 'subtitle-2' ).style.display === "none", "All subtitles are no longer visible" );