[xiph-commits] r3042 - liboggplay/trunk/plugin/test
tahn at svn.annodex.net
tahn at svn.annodex.net
Sun Jun 24 23:02:39 PDT 2007
Author: tahn
Date: 2007-06-24 23:02:39 -0700 (Sun, 24 Jun 2007)
New Revision: 3042
Modified:
liboggplay/trunk/plugin/test/test.html
Log:
Added playlist functions and shortcut keys.
Modified: liboggplay/trunk/plugin/test/test.html
===================================================================
--- liboggplay/trunk/plugin/test/test.html 2007-06-25 04:00:11 UTC (rev 3041)
+++ liboggplay/trunk/plugin/test/test.html 2007-06-25 06:02:39 UTC (rev 3042)
@@ -3,12 +3,10 @@
<title>Liboggplay Plug-in Test Page</title>
</head>
-<body onkeypress='KeyPressed(event)'>
+<body onkeypress='keyPressed(event)'>
<center>
-<h1>Example Liboggplay Plug-in</h1>
-Hooray, it's a movie in a box!
-<br><br>
+<h3>Example Liboggplay Plug-in</h3>
<embed type="application/liboggplay" src="http://media.annodex.net/cmmlwiki/OSSForum-Intro.axv" width=320 height=240>
<div id="cmml"></div>
@@ -16,49 +14,80 @@
<br>
<form name="api">
-<table>
-<tr><td width="160">
-<input type="button" value="Play" onclick='Play()'/><br>
-<input type="button" value="Pause" onclick='Pause()'/><br>
-<input type="button" value="Restart" onclick='Restart()'/><br>
-<input type="button" value="Get current state" onclick='GetCurrentState()'/><br>
-<input type="button" value="Get version string" onclick='GetVersionString()'/><br>
-</td><td width="180">
-<input type="button" value="Retrieve annotations" onclick='RetrieveAnnotations()'/><br>
-<input type="button" value="Get current movie" onclick='GetCurrentMovie()'/><br>
-<input type="button" value="Set play position" onclick='SetPlayPosition()'/><br>
-<input type="button" value="Get play position" onclick='GetPlayPosition()'/><br>
+<table border="0">
+<tr>
+<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">
+<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>
+<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>
</td><td>
-<input type="button" value="Set volume" onclick='SetVolume()'/><br>
-<input type="button" value="Get volume" onclick='GetVolume()'/><br>
-<input type="button" value="Get window size" onclick='GetWindowSize()'/><br>
-<input type="button" value="Get buffered time" onclick='GetBufferedTime()'/><br>
-<input type="button" value="Get movie length" onclick='GetMovieLength()'/><br>
+<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>
+<tt>v </tt><input type="button" value="Get volume" onclick='GetVolume()'/><br>
+<tt>V </tt><input type="button" value="Set volume" onclick='SetVolume()'/><br>
+<tt>w </tt><input type="button" value="Get window size" onclick='GetWindowSize()'/><br>
+<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">
+<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>
+<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>
+</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>
+<tt>n </tt><input type="button" value="Get play pos in movie" onclick='GetPlayPositionWithinMovie()'/><br>
+<tt>N </tt><input type="button" value="Set play pos in movie" onclick='SetPlayPositionWithinMovie()'/><br>
+<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>
-<tr><td><br></td></tr>
-<tr valign="top"><td>
-<input type="button" value="Set movie:" onclick='SetCurrentMovie()'/><br>
+</table>
+<br>
+<table border=0>
+<tr valign="top"><td width="150">
+<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>
+</td><td width="170">
+<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>
<input type="button" value="Register:" onclick='RegisterEndPlayCallback()'/>
<label for="c2"><input id="c2" type="checkbox" name="cbEndPlay" checked/>EndPlay</label><br>
+<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>Non-plugin functions</i><br>
<input type="button" value="Clear CMML" onclick='clearCMML()'/><br>
</td></tr>
</table>
</form>
-<form name="io">
+<form name="io" onkeypress='blockKeyPressedEvent(event)'>
Input<br>
-<input type="text" name="input" size="20">
+<input type="text" name="input" size="20"/>
<br><br>
Output<br>
-<textarea name="output" cols="60" rows="8"></textarea>
+<textarea name="output" cols="70" rows="8"></textarea>
</form>
<script>
@@ -73,49 +102,55 @@
function Play() {
plugin.play();
+ output.value = "Play!";
}
function Pause() {
plugin.pause();
+ output.value = "Pause!";
}
function Restart() {
plugin.restart();
+ output.value = "Restart!";
}
function GetCurrentState() {
var states = ["paused", "playing", "finished"];
var s = plugin.getCurrentState();
- output.value = "Current state: " + states[s] + " (" + s + ")";
+ if (s == -1)
+ output.value = "Current state call failed (returned -1)";
+ else
+ output.value = "Current state: " + states[s] + " (" + s + ")";
}
+function GetCurrentMovie() {
+ output.value = "Current movie: " + plugin.getCurrentMovie();
+}
+
function SetCurrentMovie() {
- for (i = 0; i < api.movie.length; i++) {
- if (api.movie[i].checked) {
- var s = "http://media.annodex.net/cmmlwiki/" + api.movie[i].value + ".axv";
- plugin.setCurrentMovie(s);
- output.value = "Current movie set to " + s;
- return;
- }
- }
+ var movie = getSelectedMovie();
+ plugin.setCurrentMovie(movie);
+ output.value = "Current movie set to " + movie;
}
-function GetCurrentMovie() {
- output.value = "Current movie: " + plugin.getCurrentMovie();
+function GetPlayPosition() {
+ output.value = "Play position: " + plugin.getPlayPosition() + " ms";
}
function SetPlayPosition() {
var v = +input.value;
if (isNaN(v)) {
- output.value = "Enter a numeric value";
+ output.value = "Enter an integer value";
} else {
- plugin.setPlayPosition(v);
- output.value = "Play position set to " + v + " ms";
+ var res = plugin.setPlayPosition(v);
+ output.value =
+ "Play position set to " + v + " ms\n" + (res ? "Succeeded" : "Failed");
}
}
-function GetPlayPosition() {
- output.value = "Play position: " + plugin.getPlayPosition() + " ms";
+function GetVolume() {
+ output.value = "Volume: " + plugin.getVolume();
}
function SetVolume() {
@@ -128,10 +163,6 @@
}
}
-function GetVolume() {
- output.value = "Volume: " + plugin.getVolume();
-}
-
function GetWindowSize() {
output.value = "Window size: " +
plugin.getWindowWidth() + " x " + plugin.getWindowHeight();
@@ -149,6 +180,95 @@
output.value = "Annotations:\n" + plugin.retrieveAnnotations();
}
+function FreezePlaylistProgression() {
+ plugin.freezePlaylistProgression();
+ output.value = "Playlist frozen!";
+}
+
+function UnfreezePlaylistProgression() {
+ plugin.unfreezePlaylistProgression();
+ output.value = "Playlist thawed!";
+}
+
+function GetPlaylistLength() {
+ output.value = "Playlist length: " + plugin.getPlaylistLength();
+}
+
+function 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);
+ }
+}
+
+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;
+ }
+}
+
+function AppendMovie() {
+ var movie = getSelectedMovie();
+ plugin.appendMovie(movie);
+ output.value = "Appended " + movie;
+}
+
+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;
+ }
+}
+
+function 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");
+ }
+}
+
+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);
+ }
+}
+
+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);
+ }
+}
+
function RegisterCMMLCallback() {
if (api.cbCMML.checked) {
plugin.registerCMMLCallback(
@@ -177,6 +297,20 @@
}
}
+function RegisterPlaylistCallback() {
+ if (api.cbPlaylist.checked) {
+ plugin.registerPlaylistCallback(
+ {
+ call : function() {trackChanged();}
+ }
+ );
+ output.value = "Registered Playlist callback";
+ } else {
+ plugin.registerPlaylistCallback(null);
+ output.value = "Unregistered Playlist callback";
+ }
+}
+
function showCMML(data) {
/* clear the old CMML clip */
output.value = data;
@@ -217,6 +351,10 @@
alert("End of play callback!");
}
+function trackChanged() {
+ alert("Playlist callback!");
+}
+
function clearCMML() {
var element = document.getElementById("cmml");
while (element.firstChild != null) {
@@ -224,28 +362,49 @@
}
}
-function KeyPressed(e) {
- if (String.fromCharCode(e.which) == " ")
- alert(plugin.getPlayPosition());
-
- if (String.fromCharCode(e.which) == "p") {
- var state = plugin.getCurrentState();
- switch (state) {
- case 0: //PAUSED
- plugin.play();
- break;
- case 1: //PLAYING
- plugin.pause();
- break;
- case 2: //FINISHED
- plugin.restart();
- break;
- default:
- alert("getCurrentState returned " + state);
- break;
+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;
+ case "q": Pause(); break;
+ case "r": Restart(); break;
+ case "s": GetCurrentState(); break;
+ case "z": GetVersionString(); break;
+ case "a": RetrieveAnnotations(); break;
+ case "m": GetCurrentMovie(); break;
+ case "M": SetCurrentMovie(); break;
+ case "t": GetPlayPosition(); break;
+ case "T": SetPlayPosition(); break;
+ case "v": GetVolume(); break;
+ case "V": SetVolume(); break;
+ case "w": GetWindowSize(); break;
+ case "b": GetBufferedTime(); break;
+ case "l": GetMovieLength(); break;
+ case "f": FreezePlaylistProgression(); break;
+ case "F": UnfreezePlaylistProgression(); break;
+ case "g": GetPlaylistLength(); break;
+ case "c": GetCurrentPlaylistPosition(); 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;
+ }
+}
+
+function blockKeyPressedEvent(e){
+ e.stopPropagation();
+}
</script>
</center>
More information about the commits
mailing list