[xiph-commits] r3082 - liboggplay/trunk/plugin/test
tahn at svn.annodex.net
tahn at svn.annodex.net
Tue Jun 26 21:42:16 PDT 2007
Author: tahn
Date: 2007-06-26 21:42:16 -0700 (Tue, 26 Jun 2007)
New Revision: 3082
Modified:
liboggplay/trunk/plugin/test/test.html
Log:
Added scrolling output, prompt for movie and variable skip size (with a default of 1sec).
Modified: liboggplay/trunk/plugin/test/test.html
===================================================================
--- liboggplay/trunk/plugin/test/test.html 2007-06-27 04:22:35 UTC (rev 3081)
+++ liboggplay/trunk/plugin/test/test.html 2007-06-27 04:42:16 UTC (rev 3082)
@@ -14,17 +14,14 @@
<br>
<form name="api">
-<table border="0">
+<table>
<tr>
-<td colspan="2">
-Standard functions<hr>
-</td>
-<td width="30"></td>
-<td colspan="2">
-Playlist functions<hr>
-</td>
+<td colspan="2">Standard functions<hr></td>
+<td width="30"></td>
+<td colspan="2">Playlist functions<hr></td>
</tr>
-<tr valign="top"><td width="180">
+<tr valign="top">
+<td width="180">
<tt>p </tt><input type="button" value="Play" onclick='Play()'/><br>
<tt>q </tt><input type="button" value="Pause" onclick='Pause()'/><br>
<tt>r </tt><input type="button" value="Restart" onclick='Restart()'/><br>
@@ -42,7 +39,7 @@
<tt>b </tt><input type="button" value="Get buffered time" onclick='GetBufferedTime()'/><br>
<tt>l </tt><input type="button" value="Get movie length" onclick='GetMovieLength()'/><br>
</td><td>
-</td><td width="170">
+</td><td width="170">
<tt>f </tt><input type="button" value="Freeze PL" onclick='FreezePlaylistProgression()'/><br>
<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>
@@ -57,18 +54,25 @@
<tt>A </tt><input type="button" value="Retrieve annotations at" onclick='RetrieveAnnotationsAt()'/><br>
<tt>L </tt><input type="button" value="Get movie length at" onclick='GetMovieLengthAt()'/><br>
</td><td>
-</td></tr>
+</td>
+</tr>
</table>
<br>
-<table border=0>
-<tr valign="top"><td width="180">
-<i>Setting movies</i><br>
+<table>
+<tr>
+<td colspan="2"><i>Setting movies</i></td>
+<td><i>Callbacks</i></td>
+<td><i>Miscellanea</i></td>
+</tr>
+<tr valign="top"><td>
<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>
-<p style="margin-top:8;font-size:85%"><i>Use , and . to change</i></p>
-</td><td width="190">
-<i>Callbacks</i><br>
+</td><td width="180">
+<label for="r4"><input id="r4" type="radio" name="movie" value="DArt-Silvia_Pfeiffer"/>DArt-Silvia_Pfeiffer</label><br>
+<label for="r5"><input id="r5" type="radio" name="movie"/>Prompt for movie</label><br>
+<p style="margin-top:8;font-size:85%"><i> Use , and . to change</i></p>
+</td><td width="180">
<input type="button" value="Register:" onclick='RegisterCMMLCallback()'/>
<label for="c1"><input id="c1" type="checkbox" name="cbCMML" checked/>CMML</label><br>
<input type="button" value="Register:" onclick='RegisterEndPlayCallback()'/>
@@ -76,21 +80,22 @@
<input type="button" value="Register:" onclick='RegisterPlaylistCallback()'/>
<label for="c3"><input id="c3" type="checkbox" name="cbPlaylist" checked/>Playlist</label><br>
</td><td>
-</td><td>
-<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>
+<tt>] </tt><input type="button" value="Skip forward" onclick='skip(1)'/><br>
+<tt>[ </tt><input type="button" value="Skip back" onclick='skip(-1)'/><br>
+</td>
+</tr>
</table>
</form>
<form name="io">
-Input<br>
+Input
+<br>
<input type="text" name="input" size="20"/>
<br><br>
-Output<br>
-<textarea name="output" cols="70" rows="8"></textarea>
+Output <input type="button" value="Clear" onclick='setOutput("")'/>
+<br>
+<textarea name="output" cols="80" rows="9"></textarea>
</form>
<script>
@@ -100,56 +105,55 @@
var output = document.io.output;
function GetVersionString() {
- output.value = "Version: " + plugin.getVersionString();
+ addOutput("Version: " + plugin.getVersionString());
}
function Play() {
plugin.play();
- output.value = "Play!";
+ addOutput("Play!");
}
function Pause() {
plugin.pause();
- output.value = "Pause!";
+ addOutput("Pause!");
}
function Restart() {
plugin.restart();
- output.value = "Restart!";
+ addOutput("Restart!");
}
function GetCurrentState() {
var states = ["paused", "playing", "finished"];
var s = plugin.getCurrentState();
if (s == -1)
- output.value = "Current state call failed (returned -1)";
+ addOutput("Current state call failed");
else
- output.value = "Current state: " + states[s] + " (" + s + ")";
+ addOutput("Current state: " + states[s]);
}
function GetCurrentMovie() {
- output.value = "Current movie: " + plugin.getCurrentMovie();
+ addOutput("Current movie: " + plugin.getCurrentMovie());
}
function SetCurrentMovie() {
var movie = getSelectedMovie();
plugin.setCurrentMovie(movie);
- output.value = "Current movie set to " + movie;
+ addOutput("Current movie set to " + movie);
}
function GetPlayPosition() {
- output.value = "Play position: " + plugin.getPlayPosition() + " ms";
+ addOutput("Play position: " + plugin.getPlayPosition() + " ms");
}
function SetPlayPosition() {
var i = getInput();
- output.value =
- "Play position set to " + i + " ms\n" +
- (plugin.setPlayPosition(i) ? "Succeeded" : "Failed");
+ addOutput("Play position set to " + i + " ms - " +
+ (plugin.setPlayPosition(i) ? "succeeded" : "failed"));
}
function GetVolume() {
- output.value = "Volume: " + plugin.getVolume();
+ addOutput("Volume: " + plugin.getVolume());
}
function SetVolume() {
@@ -157,91 +161,87 @@
if (i < 0) i = 0;
if (i > 1) i = 1;
plugin.setVolume(i);
- output.value = "Volume set to " + i;
+ addOutput("Volume set to " + i);
}
function GetWindowSize() {
- output.value = "Window size: " +
- plugin.getWindowWidth() + " x " + plugin.getWindowHeight();
+ addOutput("Window size: " +
+ plugin.getWindowWidth() + " x " + plugin.getWindowHeight());
}
function GetBufferedTime() {
- output.value = "Buffered time: " + plugin.getBufferedTime() + " ms";
+ addOutput("Buffered time: " + plugin.getBufferedTime() + " ms");
}
function GetMovieLength() {
- output.value = "Movie length: " + plugin.getMovieLength() + " ms";
+ addOutput("Movie length: " + plugin.getMovieLength() + " ms");
}
function RetrieveAnnotations() {
- output.value = "-- Annotations --\n" + plugin.retrieveAnnotations();
+ setOutput("-- Annotations --\n" + plugin.retrieveAnnotations());
}
function FreezePlaylistProgression() {
plugin.freezePlaylistProgression();
- output.value = "Playlist frozen!";
+ addOutput("Playlist frozen!");
}
function UnfreezePlaylistProgression() {
plugin.unfreezePlaylistProgression();
- output.value = "Playlist thawed!";
+ addOutput("Playlist thawed!");
}
function GetPlaylistLength() {
- output.value = "Playlist length: " + plugin.getPlaylistLength();
+ addOutput("Playlist length: " + plugin.getPlaylistLength());
}
function GetCurrentPlaylistPosition() {
- output.value =
- "Current playlist position: " + plugin.getCurrentPlaylistPosition();
+ addOutput("Current playlist position: " + plugin.getCurrentPlaylistPosition());
}
function GetMovieAt() {
var i = getInput();
- output.value = "Movie at " + i + ": " + plugin.getMovieAt(i);
+ addOutput("Movie at " + i + ": " + plugin.getMovieAt(i));
}
function SetMovieAt() {
var i = getInput();
var movie = getSelectedMovie();
plugin.setMovieAt(i, movie);
- output.value = "Set movie at " + i + " to " + movie;
+ addOutput("Set movie at " + i + " to " + movie);
}
function AppendMovie() {
var movie = getSelectedMovie();
plugin.appendMovie(movie);
- output.value = "Appended " + movie;
+ addOutput("Appended " + movie);
}
function InsertMovieBefore() {
var i = getInput();
var movie = getSelectedMovie();
plugin.insertMovieBefore(i, movie);
- output.value = "Inserted " + movie + " before " + i;
+ addOutput("Inserted " + movie + " before " + i);
}
function GetPlayPositionWithinMovie() {
- output.value =
- "Current position in movie: " + plugin.getPlayPositionWithinMovie();
+ addOutput("Current position in movie: " + plugin.getPlayPositionWithinMovie());
}
function SetPlayPositionWithinMovie() {
var i = getInput();
- output.value =
- "Play position in movie set to " + i + " ms\n" +
- (plugin.setPlayPositionWithinMovie(i) ? "Succeeded" : "Failed");
+ addOutput("Play position in movie set to " + i + " ms - " +
+ (plugin.setPlayPositionWithinMovie(i) ? "succeeded" : "failed"));
}
function RetrieveAnnotationsAt() {
var i = getInput();
- output.value =
- "-- Annotations at " + i + " --\n" + plugin.retrieveAnnotationsAt(i);
+ setOutput("-- Annotations at " + i + " --\n" + plugin.retrieveAnnotationsAt(i));
}
function GetMovieLengthAt() {
var i = getInput();
- output.value = "Movie length at " + i + ": " + plugin.getMovieLengthAt(i);
+ addOutput("Movie length at " + i + ": " + plugin.getMovieLengthAt(i));
}
function RegisterCMMLCallback() {
@@ -251,10 +251,10 @@
call : function(s) {showCMML(s);}
}
);
- output.value = "Registered CMML callback";
+ addOutput("Registered CMML callback");
} else {
plugin.registerCMMLCallback(null);
- output.value = "Unregistered CMML callback";
+ addOutput("Unregistered CMML callback");
}
}
@@ -265,10 +265,10 @@
call : function() {endPlay();}
}
);
- output.value = "Registered EndPlay callback";
+ addOutput("Registered EndPlay callback");
} else {
plugin.registerEndPlayCallback(null);
- output.value = "Unregistered EndPlay callback";
+ addOutput("Unregistered EndPlay callback");
}
}
@@ -279,16 +279,16 @@
call : function() {trackChanged();}
}
);
- output.value = "Registered Playlist callback";
+ addOutput("Registered Playlist callback");
} else {
plugin.registerPlaylistCallback(null);
- output.value = "Unregistered Playlist callback";
+ addOutput("Unregistered Playlist callback");
}
}
function showCMML(data) {
/* clear the old CMML clip */
- output.value = data;
+ setOutput("-- CMML data --\n" + data);
var element = document.getElementById("cmml");
while (element.firstChild != null) {
element.removeChild(element.firstChild);
@@ -366,30 +366,44 @@
case "N": SetPlayPositionWithinMovie(); break;
case "A": RetrieveAnnotationsAt(); break;
case "L": GetMovieLengthAt(); break;
- case "]": skip(1000); break;
- case "[": skip(-1000); break;
+ case "]": skip(1); break;
+ case "[": skip(-1); break;
case ".": changeSelectedMovie(1); break;
case ",": changeSelectedMovie(-1); break;
}
}
-function getInput() {
- var i = parseInt(input.value);
- return isNaN(i) ? 0 : i;
+function skip(dir) {
+ var i = getInput();
+ if (i <= 0) i = 1000;
+ i = plugin.getPlayPosition() + i * dir;
+ addOutput("Skipping to " + i + " ms - " +
+ (plugin.setPlayPosition(i) ? "succeeded" : "failed"));
}
function getSelectedMovie() {
- for (i = 0; i < api.movie.length; i++) {
+ for (i = 0; i < api.movie.length - 1; i++) {
if (api.movie[i].checked) {
return "http://media.annodex.net/cmmlwiki/" + api.movie[i].value + ".axv";
}
}
+ var s = prompt("Enter the movie:", "");
+ if (s == null) {
+ return;
+ }
+ if (s.substr(0, 7) != "http://") {
+ s = "http://media.annodex.net/cmmlwiki/" + s;
+ }
+ if (s.substr(s.length - 4, 4) != ".axv") {
+ s = s + ".axv";
+ }
+ return s;
}
-function changeSelectedMovie(val) {
+function changeSelectedMovie(dir) {
for (i = 0; i < api.movie.length; i++) {
if (api.movie[i].checked) {
- i = i + val;
+ i = i + dir;
if (i < 0) i = 0;
if (i > api.movie.length - 1) i = api.movie.length - 1;
api.movie[i].checked = true;
@@ -398,13 +412,32 @@
}
}
-function skip(ms) {
- var t = plugin.getPlayPosition() + ms;
- output.value =
- "Skipping to " + t + " ms\n" +
- (plugin.setPlayPosition(t) ? "Succeeded" : "Failed");
+function getInput() {
+ var i = parseInt(input.value);
+ return isNaN(i) ? 0 : i;
}
+var outLines = 0;
+
+function addOutput(str) {
+ if (outLines == 0) {
+ output.value = str;
+ } else {
+ output.value = str + "\n" + output.value;
+ }
+ outLines++;
+ if (outLines == 11) {
+ var i = output.value.lastIndexOf("\n");
+ output.value = output.value.substr(0, i);
+ outLines--;
+ }
+}
+
+function setOutput(str) {
+ output.value = str;
+ outLines = 0;
+}
+
</script>
</center>
More information about the commits
mailing list