From bc645c772daea080c040d16d4fa593c719d017c1 Mon Sep 17 00:00:00 2001 From: Anna Sobiepanek Date: Wed, 9 Mar 2011 19:35:10 -0500 Subject: [PATCH] Merged dan's ad4737147aa13c93 into 4.0 --- plugins/subtitle/popcorn.subtitle.js | 2 +- plugins/subtitle/popcorn.subtitle.unit.html | 50 +++++++++++++ plugins/subtitle/popcorn.subtitle.unit.js | 83 +++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 plugins/subtitle/popcorn.subtitle.unit.html create mode 100644 plugins/subtitle/popcorn.subtitle.unit.js diff --git a/plugins/subtitle/popcorn.subtitle.js b/plugins/subtitle/popcorn.subtitle.js index 0cad282..2dbfaae 100644 --- a/plugins/subtitle/popcorn.subtitle.js +++ b/plugins/subtitle/popcorn.subtitle.js @@ -108,7 +108,7 @@ // Creates a div for all subtitles to use if ( !this.container ) { this.container = document.createElement('div'); - + this.container.id = "subtitlediv"; this.container.style.position = "absolute"; this.container.style.color = "white"; this.container.style.textShadow = "black 2px 2px 6px"; diff --git a/plugins/subtitle/popcorn.subtitle.unit.html b/plugins/subtitle/popcorn.subtitle.unit.html new file mode 100644 index 0000000..1a02e3e --- /dev/null +++ b/plugins/subtitle/popcorn.subtitle.unit.html @@ -0,0 +1,50 @@ + + + + Popcorn Subtitle Plug-in Test + + + + + + + + + + +

Popcorn Subtitle Plugin

+

+
+

+
    +
    + + +

    Choose your language

    + +
    + with help from Google Translate
    + All subtitles (accessibility) +
    + + diff --git a/plugins/subtitle/popcorn.subtitle.unit.js b/plugins/subtitle/popcorn.subtitle.unit.js new file mode 100644 index 0000000..9e7c58b --- /dev/null +++ b/plugins/subtitle/popcorn.subtitle.unit.js @@ -0,0 +1,83 @@ +test("Popcorn Subtitle Plugin", function () { + + var popped = Popcorn("#video"), + expects = 5, + count = 0, + interval, + interval2, + interval3, + interval4, + subtitlediv; + + expect(expects); + + function plus() { + if ( ++count===expects) { + start(); + } + } + + stop(); + + ok ('subtitle' in popped, "subtitle is a method of the popped instance"); + plus(); + + popped.subtitle({ + start: 3, + text: 'this is the first subtitle of 2011', + language: "en", + languagesrc: "language", + accessibilitysrc: "accessibility" + } ) + .subtitle({ + start: 10, + end: 15, + text: 'this is the second subtitle of 2011', + language: "en", + languagesrc: "language", + accessibilitysrc: "accessibility" + } ) + .subtitle({ + start: 20, + text: 'this is the third subtitle of 2011', + language: "en", + languagesrc: "language", + accessibilitysrc: "accessibility" + } ) + .volume(0) + .play(); + + interval = setInterval( function() { + if( popped.currentTime() >= 3 && popped.currentTime() < 10 ) { + subtitlediv = document.getElementById('subtitlediv'); // this div has only now been created + equals (subtitlediv.innerHTML, "this is the first subtitle of 2011", "subtitle displaying correct information" ); + plus(); + clearInterval( interval ); + } + }, 500); + + interval2 = setInterval( function() { + if( popped.currentTime() >= 10 && popped.currentTime() < 15 ) { + equals (subtitlediv.innerHTML, "this is the second subtitle of 2011", "subtitle displaying correct information" ); + plus(); + clearInterval( interval2 ); + } + }, 500); + + interval3 = setInterval( function() { + if( popped.currentTime() >= 15 && popped.currentTime() < 20 ) { + equals (subtitlediv.innerHTML, "" ); + plus(); + clearInterval( interval3 ); + } + }, 500); + + interval4 = setInterval( function() { + if( popped.currentTime() > 20) { + equals (subtitlediv.innerHTML, "this is the third subtitle of 2011", "subtitle displaying correct information" ); + plus(); + clearInterval( interval4 ); + } + }, 500); + +}); \ No newline at end of file -- 2.43.0