[cvs-annodex] commit (/annodex):
AnnodexFirefoxExtension/trunk/chrome/afeview/content/MediaEngine.js
AnnodexFirefoxExtension/trunk/chrome/afeview/content/afeview.js
andre
nobody at lists.annodex.net
Wed Mar 9 15:32:20 EST 2005
Update of /annodex (new revision 1071)
Modified files:
AnnodexFirefoxExtension/trunk/chrome/afeview/content/MediaEngine.js
AnnodexFirefoxExtension/trunk/chrome/afeview/content/afeview.js
Log Message:
AnnodexFirefoxExtension
Modified: AnnodexFirefoxExtension/trunk/chrome/afeview/content/MediaEngine.js
===================================================================
--- AnnodexFirefoxExtension/trunk/chrome/afeview/content/MediaEngine.js 2005-03-09 04:21:52 UTC (rev 1070)
+++ AnnodexFirefoxExtension/trunk/chrome/afeview/content/MediaEngine.js 2005-03-09 04:32:19 UTC (rev 1071)
@@ -116,8 +116,12 @@
{
pluginObject.set_volume(aVolumeLevelBetween0And100);
}
+
+ this.internalName = function ()
+ {
+ return "VLC";
+ }
}
-
VLCMediaEngine.videoViewXULElementName = function ()
{
if (navigator.platform.match(/^Linux/))
@@ -209,8 +213,12 @@
{
return;
}
+
+ this.internalName = function ()
+ {
+ return "WMP7";
+ }
}
-
WindowsMedia7MediaEngine.videoViewXULElementName = function ()
{
return "windowsmediaplayer7view";
@@ -286,8 +294,12 @@
{
return;
}
+
+ this.internalName = function ()
+ {
+ return "WMP64";
+ }
}
-
WindowsMedia64MediaEngine.videoViewXULElementName = function ()
{
return "windowsmediaplayer64view";
@@ -407,8 +419,12 @@
{
return;
}
+
+ this.internalName = function ()
+ {
+ return "QuickTime";
+ }
}
-
QuickTimeMediaEngine.videoViewXULElementName = function ()
{
return "quicktimeview";
Modified: AnnodexFirefoxExtension/trunk/chrome/afeview/content/afeview.js
===================================================================
--- AnnodexFirefoxExtension/trunk/chrome/afeview/content/afeview.js 2005-03-09 04:21:52 UTC (rev 1070)
+++ AnnodexFirefoxExtension/trunk/chrome/afeview/content/afeview.js 2005-03-09 04:32:19 UTC (rev 1071)
@@ -113,7 +113,7 @@
alert("The Annodex viewer plugin ("
+ mediaEngineConstructor.videoViewXULElementName()
+ ") was not found. Please reinstall the Annodex Firefox "
- + "Extension.");
+ + "Extension.");
return;
}
@@ -178,6 +178,9 @@
var streamLengthInSeconds;
var active; // the active clip
+ var toc = document.getElementById("clips");
+ var followModeCheckbox = document.getElementById("follow-mode-checkbox");
+
// Set the current time and stream length labels
timeInSeconds = MediaEngine.getTimeInSeconds();
@@ -228,21 +231,15 @@
clip.setAttribute("style", "");
}
- var followModeCheckbox = document.getElementById("follow-mode-checkbox");
- var toc = document.getElementById("clips");
-
active = activeClip(timeInSeconds);
if (active != undefined)
{
active.setAttribute("style", "color: #0000ff;");
// Also select the active clip if follow mode is on
- if (followModeCheckbox.getAttribute("checked") == "true") toc.selectedItem = active;
+ if (followModeCheckbox.getAttribute("checked") == "true")
+ toc.selectedItem = active;
}
- else
- {
- if (followModeCheckbox.getAttribute("checked") == "true") toc.clearSelection();
- }
}
// Display the appropriate anchor text
@@ -266,6 +263,19 @@
var hyperlink = createHyperlink(activeAnchorHref, activeAnchorText);
activeAnchorTextDescription.replaceChild(hyperlink, activeAnchorTextDescription.firstChild);
PreviouslyActive = active;
+
+ // If follow mode is on, ensure that the newly selected clip is actually
+ // displayed on the screen.
+
+ if (followModeCheckbox.getAttribute("checked") == "true")
+ {
+ var indexOfFirstVisibleRow = toc.getIndexOfFirstVisibleRow();
+ var indexOfLastVisibleRow = indexOfFirstVisibleRow + toc.getNumberOfVisibleRows() - 1;
+ var clipIndex = activeClipIndex(timeInSeconds);
+
+ if (clipIndex < indexOfFirstVisibleRow || clipIndex > indexOfLastVisibleRow)
+ toc.scrollToIndex(activeClipIndex(timeInSeconds));
+ }
}
// If we're running on Mac OS X, handle video resizing here: see the comment
@@ -290,7 +300,7 @@
{
if (activeAnchorHref.indexOf(".anx") != -1)
MediaEngine.setHRef("chrome://afeview/content/afeview.xul?"
- + resolveURL(SourceURL, activeAnchorHref));
+ + resolveURL(SourceURL, activeAnchorHref));
else
MediaEngine.setHRef(activeAnchorHref);
}
@@ -324,14 +334,14 @@
// start time of that clip
for (var j = 0; j < Clips.length; j++)
{
- clip = document.getElementById(CLIP_ID_PREFIX + Clips[j]);
- var clipId = clip.getAttribute("clip-id");
+ clip = document.getElementById(CLIP_ID_PREFIX + Clips[j]);
+ var clipId = clip.getAttribute("clip-id");
- if (clipId == RequestedFragment)
- {
- secondsToGoTo = clip.getAttribute("clip-start");
- break;
- }
+ if (clipId == RequestedFragment)
+ {
+ secondsToGoTo = clip.getAttribute("clip-start");
+ break;
+ }
}
// If, after iterating through the clip list, we still haven't managed
@@ -339,7 +349,7 @@
// something else weirdass. Don't try searching any more!
if (isNaN(secondsToGoTo))
{
- RequestedFragment = undefined;
+ RequestedFragment = undefined;
}
}
@@ -349,7 +359,7 @@
{
if (seekTo(secondsToGoTo))
{
- RequestedFragment = undefined;
+ RequestedFragment = undefined;
}
}
}
@@ -386,6 +396,13 @@
if (!LoadedAllClips || timeInSeconds == undefined)
return undefined;
+ // XXX: The VLC media engine sometimes returns 0 instead of -1 when it
+ // doesn't know what the current time is (which may occur e.g. if it's
+ // in the middle of loading a new stream), so we should return undefined
+ // if the time is 0 for that ...
+ if (timeInSeconds == 0 && MediaEngine.internalName() == "VLC")
+ return undefined;
+
// We iterate _backward_ through the Clips array, comparing the current time
// against every clip. If the current time is greater than or equal to than
// the time of the current clip being compared again, then it's the active one
@@ -454,8 +471,8 @@
if (!LoadedAllClips)
{
var boohooOutput = ("There was a problem retrieving this movie file's " +
- "table of contents. The server returned an HTTP error code of " +
- CMMLRequest.status + " (" + CMMLRequest.statusText + ").");
+ "table of contents. The server returned an HTTP error code of " +
+ CMMLRequest.status + " (" + CMMLRequest.statusText + ").");
clipDescription.firstChild.nodeValue = boohooOutput;
}
@@ -511,13 +528,13 @@
// Found a <head> tag: search for <title>
for (j = 0; j < child.childNodes.length; j++)
{
- var subchild = child.childNodes[j];
+ var subchild = child.childNodes[j];
- if (subchild.tagName == "title")
- {
- var title = subchild.firstChild.nodeValue;
- document.title = title;
- }
+ if (subchild.tagName == "title")
+ {
+ var title = subchild.firstChild.nodeValue;
+ document.title = title;
+ }
}
}
else if (child.tagName == "clip")
@@ -537,36 +554,36 @@
// Look for an <import> tag
for (j = 0; j < child.childNodes.length; j++)
{
- var subchild = child.childNodes[j];
- var foundAtLeastOneImportSrc = false;
+ var subchild = child.childNodes[j];
+ var foundAtLeastOneImportSrc = false;
- if (subchild.tagName == "import")
- {
- // Found an <import> tag -- ensure we've found only one
- if (foundAtLeastOneImportSrc)
- {
- // We've found more than one <import> tag
- var errorOutput = "There is more than one <import> tag in the "
- + "CMML file. The Annodex Viewer for Firefox can currently "
- + "only process CMML files with exactly one <import> tag."
- var clipDescription = document
- .getElementById("toc-clip-description");
- clipDescription.firstChild.nodeValue = errorOutput;
+ if (subchild.tagName == "import")
+ {
+ // Found an <import> tag -- ensure we've found only one
+ if (foundAtLeastOneImportSrc)
+ {
+ // We've found more than one <import> tag
+ var errorOutput = "There is more than one <import> tag in the "
+ + "CMML file. The Annodex Viewer for Firefox can currently "
+ + "only process CMML files with exactly one <import> tag."
+ var clipDescription = document
+ .getElementById("toc-clip-description");
+ clipDescription.firstChild.nodeValue = errorOutput;
- // Return early: callers of this function should check the
- // LoadedAllClips global variable to see whether we were
- // successful or not. TODO: Maybe we should make this function
- // return a boolean instead, indicating success or failure?
- return;
- }
+ // Return early: callers of this function should check the
+ // LoadedAllClips global variable to see whether we were
+ // successful or not. TODO: Maybe we should make this function
+ // return a boolean instead, indicating success or failure?
+ return;
+ }
- var importSrc = subchild.getAttribute("src");
- MediaURL = resolveURL(SourceURL, importSrc);
+ var importSrc = subchild.getAttribute("src");
+ MediaURL = resolveURL(SourceURL, importSrc);
dump("***** Resolved MediaURL to " + MediaURL + "\n");
- foundAtLeastOneImportSrc = true;
- }
+ foundAtLeastOneImportSrc = true;
+ }
}
}
}
@@ -613,7 +630,7 @@
{
if (subchild.getAttribute("name") == "title")
{
- title = subchild.getAttribute("content");
+ title = subchild.getAttribute("content");
}
}
}
@@ -660,7 +677,7 @@
if (description.length > MAX_TITLE_LENGTH)
{
var shortenedDescription = description.slice(0, MAX_TITLE_LENGTH)
- + "\u2026" // ellipsis
+ + "\u2026" // ellipsis
createNamedResource("title", shortenedDescription);
}
else
@@ -941,6 +958,12 @@
function pageDidResize ()
{
updateVideoViewSize();
+
+ // Force the clip list to redraw itself (which is what the "invalidate"
+ // method does).
+ // -
+ // var clipsList = document.getElementById("clips");
+ // clipsList.invalidate();
}
function updateVideoViewSize ()
@@ -1033,10 +1056,10 @@
return ( aURL.indexOf("http" == 0)
&& ( aURL.indexOf(".anx") == aURL.length - 4
- || aURL.indexOf(".axv") == aURL.length - 4
- || aURL.indexOf(".axa") == aURL.length - 4
- )
- );
+ || aURL.indexOf(".axv") == aURL.length - 4
+ || aURL.indexOf(".axa") == aURL.length - 4
+ )
+ );
}
function createHyperlink (aHref, aAnchorText)
--
andre
More information about the cvs-annodex
mailing list