[xiph-commits] r3119 - liboggplay/trunk/plugin/test
tahn at svn.annodex.net
tahn at svn.annodex.net
Thu Jun 28 06:03:23 PDT 2007
Author: tahn
Date: 2007-06-28 06:03:23 -0700 (Thu, 28 Jun 2007)
New Revision: 3119
Modified:
liboggplay/trunk/plugin/test/test.html
Log:
Cool new playlist display panel, some API changes. You know, stuff.
Modified: liboggplay/trunk/plugin/test/test.html
===================================================================
--- liboggplay/trunk/plugin/test/test.html 2007-06-28 12:29:38 UTC (rev 3118)
+++ liboggplay/trunk/plugin/test/test.html 2007-06-28 13:03:23 UTC (rev 3119)
@@ -6,8 +6,6 @@
<body onkeypress='keyPressed(event)'>
<center>
-<h3>Example Liboggplay Plug-in</h3>
-
<table>
<tr>
<td>
@@ -18,9 +16,9 @@
<label for="r3"><input id="r3" type="radio" name="list" value="MarcinCanoe"/>MarcinCanoe</label><br>
<label for="r4"><input id="r4" type="radio" name="list" value="DArt-Silvia_Pfeiffer"/>DArt-Silvia_Pfeiffer</label><br>
<label for="r5"><input id="r5" type="radio" name="list" value="A_New_Computer"/>A_New_Computer</label><br>
-<label for="r6"><input id="r6" type="radio" name="list"/>Prompt for movie</label><br>
+<label for="r6"><input id="r6" type="radio" name="list" value="prompt?"/>Prompt for movie</label><br>
</form>
-<p style="margin-left:5;margin-top:10;font-size:85%"><i>Use , and . to change</i></p>
+<p style="margin-left:5;margin-top:-5;font-size:85%"><i>Use , and . to change</i></p>
</td>
<td width="30"></td>
<td>
@@ -78,14 +76,15 @@
<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>n </tt><input type="button" value="Play movie at" onclick='PlayMovieAt()'/><br>
+<tt>k </tt><input type="button" value="Playlist next" onclick='PlaylistNext()'/><br>
+<tt>j </tt><input type="button" value="Playlist prev" onclick='PlaylistPrev()'/><br>
+</td><td>
<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>x </tt><input type="button" value="Remove movie at" onclick='RemoveMovieAt()'/><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>
@@ -95,25 +94,49 @@
<table>
<tr>
-<td></td>
-<td colspan="2"><i>Miscellanea</i></td>
+<td colspan="2"></td>
+<td colspan="3"><i>Miscellanea</i><hr></td>
</tr>
-<tr><td width="300">
+<tr valign="top">
+<td>
Input<br>
-<input type="text" name="ifield" size="20"/>
-</td><td width="140">
+<input type="text" name="ifield" size="20"/><br>
+<p style="margin-top:5;font-size:85%"><i>Space sets focus here</i></p>
+</td>
+<td width="50"></td>
+<td width="140">
<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><td>
+</td><td width="150">
<tt>= </tt><input type="button" value="Volume up" onclick='changeVolume(1)'/><br>
<tt>- </tt><input type="button" value="Volume down" onclick='changeVolume(-1)'/><br>
-</td></tr>
+</td><td>
+<input type="button" value="Autofill PL" onclick='autofillPlaylist()'/><br>
+</td>
+</tr>
</table>
<br>
-Output <input type="button" value="Clear" onclick='setOutput("")'/><br>
-<textarea name="ofield" cols="80" rows="9"></textarea>
+<table>
+<tr>
+<td align="center">
+Output
+
+<input type="button" value="Clear" onclick='setOutput("")'/>
+</td>
+<td align="right">
+Playlist
+
+<input type="button" value="Poll" onclick='togglePLTimer()'/><tt> *<tt>
+
+</td>
+</tr>
+<tr>
+<td><textarea name="ofield" cols="60" rows="9"></textarea></td>
+<td><textarea name="pfield" cols="20" rows="9"></textarea></td>
+</tr>
+</table>
</form>
<script>
@@ -142,8 +165,8 @@
}
function GetCurrentState() {
- var states = ["paused", "playing", "finished"];
- var s = plugin.getCurrentState();
+ states = ["paused", "playing", "finished"];
+ s = plugin.getCurrentState();
if (s == -1)
addOutput("Current state call failed");
else
@@ -155,7 +178,7 @@
}
function SetCurrentMovie() {
- var movie = getSelectedMovie();
+ movie = getSelectedMovie();
plugin.setCurrentMovie(movie);
addOutput("Current movie set to " + movie);
}
@@ -165,8 +188,8 @@
}
function SetPlayPosition() {
- var i = getInput();
- addOutput("Play position set to " + i + " ms - " +
+ i = getInput();
+ addOutput("Setting play position to " + i + " ms - " +
(plugin.setPlayPosition(i) ? "succeeded" : "failed"));
}
@@ -175,7 +198,7 @@
}
function SetVolume() {
- var i = getInput() / 10.0;
+ i = getInput() / 10.0;
if (i < 0) i = 0;
if (i > 1) i = 1;
plugin.setVolume(i);
@@ -217,34 +240,50 @@
addOutput("Current playlist position: " + plugin.getCurrentPlaylistPosition());
}
+function PlayMovieAt() {
+ i = getInput();
+ addOutput("Playing movie at " + i + " - " +
+ (plugin.playMovieAt(i) ? "succeeded" : "failed"));
+}
+
+function PlaylistNext() {
+ addOutput("Playing next movie - " +
+ (plugin.playlistNext() ? "succeeded" : "failed"));
+}
+
+function PlaylistPrev() {
+ addOutput("Playing prev movie - " +
+ (plugin.playlistPrev() ? "succeeded" : "failed"));
+}
+
function GetMovieAt() {
- var i = getInput();
+ i = getInput();
addOutput("Movie at " + i + ": " + plugin.getMovieAt(i));
}
function SetMovieAt() {
- var i = getInput();
- var movie = getSelectedMovie();
- plugin.setMovieAt(i, movie);
- addOutput("Set movie at " + i + " to " + movie);
+ i = getInput();
+ movie = getSelectedMovie();
+ addOutput("Setting movie at " + i + " to " + movie + " - " +
+ (plugin.setMovieAt(i, movie) ? "succeeded" : "failed"));
}
function AppendMovie() {
- var movie = getSelectedMovie();
+ movie = getSelectedMovie();
plugin.appendMovie(movie);
addOutput("Appended " + movie);
}
function InsertMovieBefore() {
- var i = getInput();
- var movie = getSelectedMovie();
- plugin.insertMovieBefore(i, movie);
- addOutput("Inserted " + movie + " before " + i);
+ i = getInput();
+ movie = getSelectedMovie();
+ addOutput("Inserting " + movie + " before " + i + " - " +
+ (plugin.insertMovieBefore(i, movie) ? "succeeded" : "failed"));
}
function RemoveMovieAt() {
- var i = getInput();
- addOutput("Removed movie at " + i + " - " +
+ i = getInput();
+ addOutput("Removing movie at " + i + " - " +
(plugin.removeMovieAt(i) ? "succeeded" : "failed"));
}
@@ -253,18 +292,18 @@
}
function SetPlayPositionWithinMovie() {
- var i = getInput();
+ i = getInput();
addOutput("Play position in movie set to " + i + " ms - " +
(plugin.setPlayPositionWithinMovie(i) ? "succeeded" : "failed"));
}
function RetrieveAnnotationsAt() {
- var i = getInput();
+ i = getInput();
setOutput("-- Annotations at " + i + " --\n" + plugin.retrieveAnnotationsAt(i));
}
function GetMovieLengthAt() {
- var i = getInput();
+ i = getInput();
addOutput("Movie length at " + i + ": " + plugin.getMovieLengthAt(i));
}
@@ -313,55 +352,59 @@
function showCMML(data) {
/* clear the old CMML clip */
setOutput("-- CMML data --\n" + data);
- var element = document.getElementById("cmml");
+ element = document.getElementById("cmml");
while (element.firstChild != null) {
element.removeChild(element.firstChild);
}
/* parse the data as XML */
document.implementation.createDocument("", "clip", null);
- var xmlDoc = (new DOMParser()).parseFromString(data, "application/xml");
+ xmlDoc = (new DOMParser()).parseFromString(data, "application/xml");
/* extract the description */
- var descs = xmlDoc.getElementsByTagName("desc");
+ descs = xmlDoc.getElementsByTagName("desc");
if (descs.length > 0) {
- var desc = descs.item(0);
+ desc = descs.item(0);
desc.normalize();
- var newpar = document.createElement("p");
+ newpar = document.createElement("p");
newpar.appendChild(desc.cloneNode(true));
element.appendChild(newpar);
}
/* extract the link tag and convert it to an HTML href */
- var links = xmlDoc.getElementsByTagName("a");
+ links = xmlDoc.getElementsByTagName("a");
if (links.length > 0) {
- var link = links.item(0);
+ link = links.item(0);
link.normalize();
- var newlink = document.createElement("a");
+ newlink = document.createElement("a");
newlink.setAttribute("href", link.getAttribute("href"));
newlink.appendChild(link.firstChild.cloneNode(true));
- var newpar = document.createElement("p");
+ newpar = document.createElement("p");
newpar.appendChild(newlink);
element.appendChild(newpar);
}
}
function endPlay() {
- alert("End of play callback!");
+ addOutput("End of play callback received!");
}
function trackChanged() {
- alert("Playlist callback!");
+ addOutput("Playlist callback received!");
}
function clearCMML() {
- var element = document.getElementById("cmml");
+ element = document.getElementById("cmml");
while (element.firstChild != null) {
element.removeChild(element.firstChild);
}
}
function keyPressed(e) {
+ // unused letters:
+ // ---d---h------------u---y-
+ // -BCDE-GHIJK--N-PQRS-U-WXYZ
+
switch (String.fromCharCode(e.which)) {
case "p": Play(); break;
case "q": Pause(); break;
@@ -387,8 +430,9 @@
case "e": AppendMovie(); break;
case "i": InsertMovieBefore(); break;
case "x": RemoveMovieAt(); break;
- case "n": GetPlayPositionWithinMovie(); break;
- case "N": SetPlayPositionWithinMovie(); break;
+ case "n": PlayMovieAt(); break;
+ case "k": PlaylistNext(); break;
+ case "j": PlaylistPrev(); break;
case "A": RetrieveAnnotationsAt(); break;
case "L": GetMovieLengthAt(); break;
case ".": changeSelectedMovie(1); break;
@@ -397,44 +441,46 @@
case "[": skip(-1); break;
case "=": changeVolume(1); break;
case "-": changeVolume(-1); break;
+ case " ": input.focus(); break;
+ case "*": togglePLTimer(); break;
}
}
-function changeSelectedMovie(dir) {
- for (i = 0; i < movies.length; i++) {
- if (movies[i].checked) {
- i = i + dir;
- if (i < 0) i = 0;
- if (i > movies.length - 1) i = movies.length - 1;
- movies[i].checked = true;
- return;
- }
- }
-}
-
function skip(dir) {
- var i = getInput();
+ i = getInput();
if (i <= 0) i = 1000;
- var t = plugin.getPlayPosition() + i * dir;
+ t = plugin.getPlayPosition() + i * dir;
addOutput("Skipping by " + i + " to " + t + " ms - " +
(plugin.setPlayPosition(t) ? "succeeded" : "failed"));
}
function changeVolume(dir) {
- var v = plugin.getVolume() + 0.1 * dir;
+ v = plugin.getVolume() + 0.1 * dir;
if (v < 0) v = 0;
if (v > 1) v = 1;
plugin.setVolume(v);
addOutput("Volume set to " + v);
}
+function changeSelectedMovie(dir) {
+ for (i = 0; i < movies.length; i++) {
+ if (movies[i].checked) {
+ i = i + dir;
+ if (i < 0) i = 0;
+ if (i > movies.length - 1) i = movies.length - 1;
+ movies[i].checked = true;
+ return;
+ }
+ }
+}
+
function getSelectedMovie() {
for (i = 0; i < movies.length - 1; i++) {
if (movies[i].checked) {
return "http://media.annodex.net/cmmlwiki/" + movies[i].value + ".axv";
}
}
- var s = prompt("Enter the movie:", "");
+ s = prompt("Enter the movie:");
if (s == null) {
return;
}
@@ -448,12 +494,18 @@
}
function getInput() {
- var i = parseInt(input.value);
+ i = parseInt(input.value);
return isNaN(i) ? 0 : i;
}
+
var outLines = 0;
+function setOutput(str) {
+ output.value = str;
+ outLines = 0;
+}
+
function addOutput(str) {
if (outLines == 0) {
output.value = str;
@@ -462,17 +514,51 @@
}
outLines++;
if (outLines == 11) {
- var i = output.value.lastIndexOf("\n");
+ i = output.value.lastIndexOf("\n");
output.value = output.value.substr(0, i);
outLines--;
}
}
-function setOutput(str) {
- output.value = str;
- outLines = 0;
+
+var plTimerId = -1;
+
+function togglePLTimer() {
+ if (plTimerId == -1) {
+ plTimerId = setInterval("playlistTimer()", 200);
+ } else {
+ clearInterval(plTimerId);
+ document.api.pfield.value = "";
+ plTimerId = -1;
+ }
}
+function playlistTimer() {
+ len = plugin.getPlaylistLength();
+ if (len == 0) {
+ setOutput("Playlist is empty");
+ } else {
+ list = "";
+ cur = plugin.getCurrentPlaylistPosition();
+ for (i = 0; i < len; i++) {
+ s = plugin.getMovieAt(i);
+ s = s.substr(s.lastIndexOf("/") + 1);
+ x = s.lastIndexOf(".");
+ if (x > -1) {
+ s = s.substr(0, x);
+ }
+ list = list + ((i == cur) ? ">" : " ") + i + ": " + s + "\n";
+ }
+ document.api.pfield.value = list;
+ }
+}
+
+function autofillPlaylist() {
+ for (i = 0; i < movies.length - 1; i++) {
+ plugin.appendMovie("http://media.annodex.net/cmmlwiki/" + movies[i].value + ".axv");
+ }
+}
+
</script>
</center>
More information about the commits
mailing list