[xiph-commits] r3055 - liboggplay/trunk/plugin/test
tahn at svn.annodex.net
tahn at svn.annodex.net
Tue Jun 26 01:09:34 PDT 2007
Author: tahn
Date: 2007-06-26 01:09:34 -0700 (Tue, 26 Jun 2007)
New Revision: 3055
Modified:
liboggplay/trunk/plugin/test/test.html
Log:
Improved keyboard handling.
Modified: liboggplay/trunk/plugin/test/test.html
===================================================================
--- liboggplay/trunk/plugin/test/test.html 2007-06-26 08:08:24 UTC (rev 3054)
+++ liboggplay/trunk/plugin/test/test.html 2007-06-26 08:09:34 UTC (rev 3055)
@@ -31,8 +31,8 @@
<tt>s </tt><input type="button" value="Get current state" onclick='GetCurrentState()'/><br>
<tt>z </tt><input type="button" value="Get version string" onclick='GetVersionString()'/><br>
<tt>a </tt><input type="button" value="Retrieve annotations" onclick='RetrieveAnnotations()'/><br>
-<tt>m </tt><input type="button" value="Get current movie" onclick='GetCurrentMovie()'/><br>
-<tt>M </tt><input type="button" value="Set current movie" onclick='SetCurrentMovie()'/><br>
+<tt>M </tt><input type="button" value="Get current movie" onclick='GetCurrentMovie()'/><br>
+<tt>m </tt><input type="button" value="Set current movie" onclick='SetCurrentMovie()'/><br>
</td><td>
<tt>t </tt><input type="button" value="Get play position" onclick='GetPlayPosition()'/><br>
<tt>T </tt><input type="button" value="Set play position" onclick='SetPlayPosition()'/><br>
@@ -47,8 +47,8 @@
<tt>F </tt><input type="button" value="Unfreeze PL" onclick='UnfreezePlaylistProgression()'/><br>
<tt>g </tt><input type="button" value="Get PL length" onclick='GetPlaylistLength()'/><br>
<tt>c </tt><input type="button" value="Get current PL pos" onclick='GetCurrentPlaylistPosition()'/><br>
-<tt>o </tt><input type="button" value="Get movie at" onclick='GetMovieAt()'/><br>
-<tt>O </tt><input type="button" value="Set movie at" onclick='SetMovieAt()'/><br>
+<tt>O </tt><input type="button" value="Get movie at" onclick='GetMovieAt()'/><br>
+<tt>o </tt><input type="button" value="Set movie at" onclick='SetMovieAt()'/><br>
</td><td>
<tt>e </tt><input type="button" value="Append movie" onclick='AppendMovie()'/><br>
<tt>i </tt><input type="button" value="Insert movie before" onclick='InsertMovieBefore()'/><br>
@@ -61,12 +61,13 @@
</table>
<br>
<table border=0>
-<tr valign="top"><td width="150">
+<tr valign="top"><td width="180">
<i>Setting movies</i><br>
<label for="r1"><input id="r1" type="radio" name="movie" value="OSSForum-Intro" checked/>OSSForum-Intro</label><br>
<label for="r2"><input id="r2" type="radio" name="movie" value="CCFilm"/>CCFilm</label><br>
<label for="r3"><input id="r3" type="radio" name="movie" value="MarcinCanoe"/>MarcinCanoe</label><br>
-</td><td width="170">
+<p style="margin-top:8;font-size:85%"><i>Use , and . to change</i></p>
+</td><td width="190">
<i>Callbacks</i><br>
<input type="button" value="Register:" onclick='RegisterCMMLCallback()'/>
<label for="c1"><input id="c1" type="checkbox" name="cbCMML" checked/>CMML</label><br>
@@ -76,13 +77,15 @@
<label for="c3"><input id="c3" type="checkbox" name="cbPlaylist" checked/>Playlist</label><br>
</td><td>
</td><td>
-<i>Non-plugin functions</i><br>
-<input type="button" value="Clear CMML" onclick='clearCMML()'/><br>
+<i>Miscellanea</i><br>
+<tt> </tt><input type="button" value="Clear CMML" onclick='clearCMML()'/><br>
+<tt>] </tt><input type="button" value="Skip +1 sec" onclick='Skip(1000)'/><br>
+<tt>[ </tt><input type="button" value="Skip -1 sec" onclick='Skip(-1000)'/><br>
</td></tr>
</table>
</form>
-<form name="io" onkeypress='blockKeyPressedEvent(event)'>
+<form name="io">
Input<br>
<input type="text" name="input" size="20"/>
<br><br>
@@ -139,14 +142,10 @@
}
function SetPlayPosition() {
- var v = +input.value;
- if (isNaN(v)) {
- output.value = "Enter an integer value";
- } else {
- var res = plugin.setPlayPosition(v);
- output.value =
- "Play position set to " + v + " ms\n" + (res ? "Succeeded" : "Failed");
- }
+ var i = getInput();
+ output.value =
+ "Play position set to " + i + " ms\n" +
+ (plugin.setPlayPosition(i) ? "Succeeded" : "Failed");
}
function GetVolume() {
@@ -154,13 +153,11 @@
}
function SetVolume() {
- var v = +input.value;
- if (isNaN(v) || v < 0 || v > 1) {
- output.value = "Enter a value from 0 to 1";
- } else {
- plugin.setVolume(v);
- output.value = "Volume set to " + v;
- }
+ var i = getInput() / 100.0;
+ if (i < 0) i = 0;
+ if (i > 1) i = 1;
+ plugin.setVolume(i);
+ output.value = "Volume set to " + i;
}
function GetWindowSize() {
@@ -177,7 +174,7 @@
}
function RetrieveAnnotations() {
- output.value = "Annotations:\n" + plugin.retrieveAnnotations();
+ output.value = "-- Annotations --\n" + plugin.retrieveAnnotations();
}
function FreezePlaylistProgression() {
@@ -195,28 +192,20 @@
}
function GetCurrentPlaylistPosition() {
- output.value = "Current playlist position: " + plugin.getCurrentPlaylistPosition();
+ output.value =
+ "Current playlist position: " + plugin.getCurrentPlaylistPosition();
}
function GetMovieAt() {
- var v = +input.value;
- if (isNaN(v)) {
- output.value = "Enter an integer value";
- } else {
- plugin.getMovieAt(v);
- output.value = "Movie at " + v + ": " + plugin.getMovieAt(v);
- }
+ var i = getInput();
+ output.value = "Movie at " + i + ": " + plugin.getMovieAt(i);
}
function SetMovieAt() {
- var pos = +input.value;
- if (isNaN(pos)) {
- output.value = "Enter an integer value";
- } else {
- var movie = getSelectedMovie();
- plugin.setMovieAt(pos, movie);
- output.value = "Set movie at " + pos + " to " + movie;
- }
+ var i = getInput();
+ var movie = getSelectedMovie();
+ plugin.setMovieAt(i, movie);
+ output.value = "Set movie at " + i + " to " + movie;
}
function AppendMovie() {
@@ -226,49 +215,43 @@
}
function InsertMovieBefore() {
- var pos = +input.value;
- if (isNaN(pos)) {
- output.value = "Enter an integer value";
- } else {
- var movie = getSelectedMovie();
- plugin.insertMovieBefore(pos, movie);
- output.value = "Inserted " + movie + " before " + pos;
- }
+ var i = getInput();
+ var movie = getSelectedMovie();
+ plugin.insertMovieBefore(i, movie);
+ output.value = "Inserted " + movie + " before " + i;
}
function GetPlayPositionWithinMovie() {
- output.value = "Current position in movie: " + plugin.getPlayPositionWithinMovie();
+ output.value =
+ "Current position in movie: " + plugin.getPlayPositionWithinMovie();
}
function SetPlayPositionWithinMovie() {
- var v = +input.value;
- if (isNaN(v)) {
- output.value = "Enter an integer value";
- } else {
- var res = plugin.setPlayPositionWithinMovie(v);
- output.value =
- "Play position in movie set to " + v + " ms\n" + (res ? "Succeeded" : "Failed");
- }
+ var i = getInput();
+ output.value =
+ "Play position in movie set to " + i + " ms\n" +
+ (plugin.setPlayPositionWithinMovie(i) ? "Succeeded" : "Failed");
}
function RetrieveAnnotationsAt() {
- var v = +input.value;
- if (isNaN(v)) {
- output.value = "Enter an integer value";
- } else {
- output.value = "Annotations at " + v + ":\n" + plugin.retrieveAnnotationsAt(v);
- }
+ var i = getInput();
+ output.value =
+ "-- Annotations at " + i + " --\n" + plugin.retrieveAnnotationsAt(i);
}
function GetMovieLengthAt() {
- var v = +input.value;
- if (isNaN(v)) {
- output.value = "Enter an integer value";
- } else {
- output.value = "Movie length at " + v + ": " + plugin.getMovieLengthAt(v);
- }
+ var i = getInput();
+ output.value = "Movie length at " + i + ": " + plugin.getMovieLengthAt(i);
}
+function Skip(ms) {
+ var t = plugin.getPlayPosition() + ms;
+ if (t < 0) t = 0;
+ output.value =
+ "Skipping to " + t + " ms\n" +
+ (plugin.setPlayPosition(t) ? "Succeeded" : "Failed");
+}
+
function RegisterCMMLCallback() {
if (api.cbCMML.checked) {
plugin.registerCMMLCallback(
@@ -362,14 +345,6 @@
}
}
-function getSelectedMovie() {
- for (i = 0; i < api.movie.length; i++) {
- if (api.movie[i].checked) {
- return "http://media.annodex.net/cmmlwiki/" + api.movie[i].value + ".axv";
- }
- }
-}
-
function keyPressed(e) {
switch (String.fromCharCode(e.which)) {
case "p": Play(); break;
@@ -378,8 +353,8 @@
case "s": GetCurrentState(); break;
case "z": GetVersionString(); break;
case "a": RetrieveAnnotations(); break;
- case "m": GetCurrentMovie(); break;
- case "M": SetCurrentMovie(); break;
+ case "M": GetCurrentMovie(); break;
+ case "m": SetCurrentMovie(); break;
case "t": GetPlayPosition(); break;
case "T": SetPlayPosition(); break;
case "v": GetVolume(); break;
@@ -391,20 +366,43 @@
case "F": UnfreezePlaylistProgression(); break;
case "g": GetPlaylistLength(); break;
case "c": GetCurrentPlaylistPosition(); break;
- case "o": GetMovieAt(); break;
- case "O": SetMovieAt(); break;
+ case "O": GetMovieAt(); break;
+ case "o": SetMovieAt(); break;
case "e": AppendMovie(); break;
case "i": InsertMovieBefore(); break;
case "n": GetPlayPositionWithinMovie(); break;
case "N": SetPlayPositionWithinMovie(); break;
case "A": RetrieveAnnotationsAt(); break;
case "L": GetMovieLengthAt(); break;
+ case ".": changeSelectedMovie(1); break;
+ case ",": changeSelectedMovie(-1); break;
}
}
-function blockKeyPressedEvent(e){
- e.stopPropagation();
+function getInput() {
+ var i = parseInt(input.value);
+ return isNaN(i) ? 0 : i;
}
+
+function getSelectedMovie() {
+ for (i = 0; i < api.movie.length; i++) {
+ if (api.movie[i].checked) {
+ return "http://media.annodex.net/cmmlwiki/" + api.movie[i].value + ".axv";
+ }
+ }
+}
+
+function changeSelectedMovie(val) {
+ for (i = 0; i < api.movie.length; i++) {
+ if (api.movie[i].checked) {
+ i = i + val;
+ if (i < 0) i = 0;
+ if (i > api.movie.length - 1) i = api.movie.length - 1;
+ api.movie[i].checked = true;
+ return;
+ }
+ }
+}
</script>
</center>
More information about the commits
mailing list