| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 2 | <html> |
|---|
| 3 | <head> |
|---|
| 4 | <title>Mute() Unit Tester</title> |
|---|
| 5 | <script type="text/javascript" src="../../bin-debug/jwplayer.js"> |
|---|
| 6 | </script> |
|---|
| 7 | <script type="text/javascript" src="settings.js"> |
|---|
| 8 | </script> |
|---|
| 9 | </head> |
|---|
| 10 | <body> |
|---|
| 11 | <script type="text/javascript"> |
|---|
| 12 | document.write("<h1>" + document.title + "</h1>"); |
|---|
| 13 | </script> |
|---|
| 14 | <p> |
|---|
| 15 | This tests adding listeners to the player and responding to events. Video should play on FF, Chrome, Safari, and Opera but will fail in IE. |
|---|
| 16 | </p> |
|---|
| 17 | <div height="270" id="player" width="480"> |
|---|
| 18 | </div> |
|---|
| 19 | <h2>Result</h2> |
|---|
| 20 | <p id="result"> |
|---|
| 21 | Running... |
|---|
| 22 | </p> |
|---|
| 23 | <script type="text/javascript"> |
|---|
| 24 | jwplayer("player").setup({ |
|---|
| 25 | players: settings.players(window.location.href), |
|---|
| 26 | levels: [{ |
|---|
| 27 | file: "http://content.bitsontherun.com/videos/gSzpo2wh-486405.mp4" |
|---|
| 28 | }, { |
|---|
| 29 | file: "http://content.bitsontherun.com/videos/gSzpo2wh-604476.ogv" |
|---|
| 30 | }], |
|---|
| 31 | image: "http://content.bitsontherun.com/thumbs/gSzpo2wh-480.jpg", |
|---|
| 32 | mute: false |
|---|
| 33 | }); |
|---|
| 34 | |
|---|
| 35 | var scriptPos = -1; |
|---|
| 36 | jwplayer().onTime(startScript); |
|---|
| 37 | jwplayer().play(); |
|---|
| 38 | |
|---|
| 39 | var script = [{ |
|---|
| 40 | action: function() { |
|---|
| 41 | }, |
|---|
| 42 | getter: function() { |
|---|
| 43 | return jwplayer().getState(); |
|---|
| 44 | }, |
|---|
| 45 | expectedValue: jwplayer.api.events.state.PLAYING |
|---|
| 46 | },{ |
|---|
| 47 | action: function() { |
|---|
| 48 | }, |
|---|
| 49 | getter: function() { |
|---|
| 50 | return jwplayer().getMute(); |
|---|
| 51 | }, |
|---|
| 52 | expectedValue: false |
|---|
| 53 | },{ |
|---|
| 54 | action: function() { |
|---|
| 55 | jwplayer().setMute(); |
|---|
| 56 | }, |
|---|
| 57 | getter: function() { |
|---|
| 58 | return jwplayer().getMute(); |
|---|
| 59 | }, |
|---|
| 60 | expectedValue: true |
|---|
| 61 | }, { |
|---|
| 62 | action: function() { |
|---|
| 63 | jwplayer().setMute(); |
|---|
| 64 | }, |
|---|
| 65 | getter: function() { |
|---|
| 66 | return jwplayer().getMute(); |
|---|
| 67 | }, |
|---|
| 68 | expectedValue: false |
|---|
| 69 | }, { |
|---|
| 70 | action: function() { |
|---|
| 71 | jwplayer().setMute(); |
|---|
| 72 | }, |
|---|
| 73 | getter: function() { |
|---|
| 74 | return jwplayer().getMute(); |
|---|
| 75 | }, |
|---|
| 76 | expectedValue: true |
|---|
| 77 | }, { |
|---|
| 78 | action: function() { |
|---|
| 79 | jwplayer().setMute(); |
|---|
| 80 | }, |
|---|
| 81 | getter: function() { |
|---|
| 82 | return jwplayer().getMute(); |
|---|
| 83 | }, |
|---|
| 84 | expectedValue: false |
|---|
| 85 | },{ |
|---|
| 86 | action: function() { |
|---|
| 87 | jwplayer().setMute("false"); |
|---|
| 88 | }, |
|---|
| 89 | getter: function() { |
|---|
| 90 | return jwplayer().getMute(); |
|---|
| 91 | }, |
|---|
| 92 | expectedValue: false |
|---|
| 93 | }, { |
|---|
| 94 | action: function() { |
|---|
| 95 | jwplayer().setMute("false"); |
|---|
| 96 | }, |
|---|
| 97 | getter: function() { |
|---|
| 98 | return jwplayer().getMute(); |
|---|
| 99 | }, |
|---|
| 100 | expectedValue: false |
|---|
| 101 | }, { |
|---|
| 102 | action: function() { |
|---|
| 103 | jwplayer().setMute("true"); |
|---|
| 104 | }, |
|---|
| 105 | getter: function() { |
|---|
| 106 | return jwplayer().getMute(); |
|---|
| 107 | }, |
|---|
| 108 | expectedValue: true |
|---|
| 109 | }, { |
|---|
| 110 | action: function() { |
|---|
| 111 | jwplayer().setMute("true"); |
|---|
| 112 | }, |
|---|
| 113 | getter: function() { |
|---|
| 114 | return jwplayer().getMute(); |
|---|
| 115 | }, |
|---|
| 116 | expectedValue: true |
|---|
| 117 | },{ |
|---|
| 118 | action: function() { |
|---|
| 119 | jwplayer().setMute(false); |
|---|
| 120 | }, |
|---|
| 121 | getter: function() { |
|---|
| 122 | return jwplayer().getMute(); |
|---|
| 123 | }, |
|---|
| 124 | expectedValue: false |
|---|
| 125 | }, { |
|---|
| 126 | action: function() { |
|---|
| 127 | jwplayer().setMute(false); |
|---|
| 128 | }, |
|---|
| 129 | getter: function() { |
|---|
| 130 | return jwplayer().getMute(); |
|---|
| 131 | }, |
|---|
| 132 | expectedValue: false |
|---|
| 133 | }, { |
|---|
| 134 | action: function() { |
|---|
| 135 | jwplayer().setMute(true); |
|---|
| 136 | }, |
|---|
| 137 | getter: function() { |
|---|
| 138 | return jwplayer().getMute(); |
|---|
| 139 | }, |
|---|
| 140 | expectedValue: true |
|---|
| 141 | }, { |
|---|
| 142 | action: function() { |
|---|
| 143 | jwplayer().setMute(true); |
|---|
| 144 | }, |
|---|
| 145 | getter: function() { |
|---|
| 146 | return jwplayer().getMute(); |
|---|
| 147 | }, |
|---|
| 148 | expectedValue: true |
|---|
| 149 | } |
|---|
| 150 | ]; |
|---|
| 151 | |
|---|
| 152 | function startScript() { |
|---|
| 153 | if (scriptPos == -1) { |
|---|
| 154 | scriptPos++; |
|---|
| 155 | runScript(); |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | function runScript() { |
|---|
| 161 | if (scriptPos == script.length) { |
|---|
| 162 | jwplayer().stop(); |
|---|
| 163 | document.getElementById("result").innerHTML = "Success!"; |
|---|
| 164 | return; |
|---|
| 165 | } |
|---|
| 166 | script[scriptPos].action(); |
|---|
| 167 | if (script[scriptPos].getter() == script[scriptPos].expectedValue) { |
|---|
| 168 | document.getElementById("result").innerHTML = Math.round((scriptPos / script.length) * 100) + "% complete"; |
|---|
| 169 | scriptPos++; |
|---|
| 170 | setTimeout(function() { |
|---|
| 171 | runScript(); |
|---|
| 172 | }, 250); |
|---|
| 173 | } else { |
|---|
| 174 | document.getElementById("result").innerHTML = "Error at step " + (scriptPos + 1) + ": Got " + script[scriptPos].getter() + " and expected " + script[scriptPos].expectedValue; |
|---|
| 175 | if (console && console.log) console.log(script[scriptPos].action); |
|---|
| 176 | } |
|---|
| 177 | } |
|---|
| 178 | </script> |
|---|
| 179 | <h3>HTML code</h3> |
|---|
| 180 | </body> |
|---|
| 181 | </html> |
|---|