<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tahn</id>
	<title>XiphWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tahn"/>
	<link rel="alternate" type="text/html" href="https://wiki.xiph.org/Special:Contributions/Tahn"/>
	<updated>2026-04-24T02:35:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7082</id>
		<title>OggPlayJavascriptAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7082"/>
		<updated>2007-07-09T12:39:18Z</updated>

		<summary type="html">&lt;p&gt;Tahn: Added description for passing callback functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This is a &#039;&#039;&#039;draft API&#039;&#039;&#039; for the OggPlay Firefox plugin.&lt;br /&gt;
&lt;br /&gt;
We want the OggPlay plugin to support both a simple individual movie mode, and a more fully-featured playlist mode.  All of the functions supported in individual movie mode are still useful in playlist mode; however additional functions also become useful.&lt;br /&gt;
&lt;br /&gt;
Note that the amount of available information for an internet-cast Ogg stream depends upon the type of server providing that stream.  In particular, an Apache server with [http://www.annodex.net/software/mod_annodex/index.html mod_annodex] installed provides the following information that is not available for live-streamed or raw file-streamed movies:&lt;br /&gt;
* length of the movie&lt;br /&gt;
* [[CMML]] annotations for the entire movie in advance&lt;br /&gt;
&lt;br /&gt;
Furthermore, mod_annodex provides remote seeking functionality across the entire movie.  Hence, OggPlay allows arbitrary seeking on mod_annodex supported movies.  On the other hand, raw streams and live streams are only seekable within the region that has already been buffered by the player.&lt;br /&gt;
&lt;br /&gt;
== Individual movies ==&lt;br /&gt;
&lt;br /&gt;
=== OggPlayState ===&lt;br /&gt;
&lt;br /&gt;
 enum OggPlayState { PAUSED = 0; PLAYING = 1; FINISHED = 2 };&lt;br /&gt;
&lt;br /&gt;
These are fairly self-evident: the plugin begins in PAUSED or PLAYING state depending on the settings provided through the params tags, and changes to FINISHED state when the movie finishes playback.&lt;br /&gt;
&lt;br /&gt;
=== getCurrentState ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the state:&lt;br /&gt;
&lt;br /&gt;
 int &amp;lt;- getCurrentState()&lt;br /&gt;
&lt;br /&gt;
=== pause ===&lt;br /&gt;
&lt;br /&gt;
 pause()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PLAYING or FINISHED states to PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== play ===&lt;br /&gt;
&lt;br /&gt;
 play()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PAUSED state to PLAYING or FINISHED depending upon the current position within the movie.&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
 restart()&lt;br /&gt;
&lt;br /&gt;
This function will convert any state to PLAYING, and start the movie again from the beginning&lt;br /&gt;
&lt;br /&gt;
=== getCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the currently playing (or just played, or about to play) movie:&lt;br /&gt;
&lt;br /&gt;
 string URL &amp;lt;- getCurrentMovie()&lt;br /&gt;
&lt;br /&gt;
=== setCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To set a new movie:&lt;br /&gt;
&lt;br /&gt;
 setCurrentMovie(string URL)&lt;br /&gt;
&lt;br /&gt;
This will automatically begin playing at the beginning if the state is PLAYING or FINISHED, but will remain paused ready to play at the beginning if the state is PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== getPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To get the current play position (in milliseconds) from the movie:&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getPlayPosition()&lt;br /&gt;
&lt;br /&gt;
=== setPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To set the current play position (in milliseconds):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setPlayPosition(int milliseconds)&lt;br /&gt;
&lt;br /&gt;
Note that if you set a position past the end of the movie then the result will be a play position at the end of the movie, and the player in FINISHED mode.&lt;br /&gt;
&lt;br /&gt;
Note also that certain servers (e.g. plain Ogg files, no mod-annodex installed, etc.) will prevent seeking from being able to occur past the buffered portion of the file; in this case, false will be returned and the play position will be updated as far forward as possible.&lt;br /&gt;
&lt;br /&gt;
=== registerCMMLCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method as each CMML annotation is encountered (i.e. as movie playback reaches the point where the annotation needs to be inserted):&lt;br /&gt;
&lt;br /&gt;
 registerCMMLCallback(function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See [[#Callback_functions|Callback functions]] for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotations ===&lt;br /&gt;
&lt;br /&gt;
To retrieve all of the CMML annotations for a movie:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- retrieveAnnotations(function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See [[#Callback_functions|Callback functions]] for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is an asynchronous call; the plugin will create a new http connection to retrieve the annotations. The callback function will be invoked with the annotation string after the annotations have been retrieved.&lt;br /&gt;
&lt;br /&gt;
This function will return false if a previous attempt at retrieving annotations is still being processed.&lt;br /&gt;
&lt;br /&gt;
Note that this won&#039;t return all annotations from some servers, e.g. if mod-annodex is not installed.  In this case, you will still be able to retrieve CMML as each annotation is encountered using registerCMMLCallback.&lt;br /&gt;
&lt;br /&gt;
=== registerEndPlayCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method when the movie finishes:&lt;br /&gt;
&lt;br /&gt;
 registerEndPlayCallback(function callback(void))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See [[#Callback_functions|Callback functions]] for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== setVolume ===&lt;br /&gt;
&lt;br /&gt;
 setVolume(float volume)&lt;br /&gt;
&lt;br /&gt;
Use this function to set the playback volume.  A value of 0.0 is equivalent to muting; a value of 1.0 is maximum volume.&lt;br /&gt;
&lt;br /&gt;
=== getVolume ===&lt;br /&gt;
&lt;br /&gt;
 float volume &amp;lt;- getVolume()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the current playback volume.&lt;br /&gt;
&lt;br /&gt;
=== getWindowWidth ===&lt;br /&gt;
&lt;br /&gt;
 int width &amp;lt;- getWindowWidth()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the width of the window in pixels (The width is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getWindowHeight ===&lt;br /&gt;
&lt;br /&gt;
 int height &amp;lt;- getWindowHeight()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the height of the window in pixels (The height is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTime ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getBufferedTime()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how many milliseconds of the current movie are buffered for display.  Note that this is the amount downloaded past the currently playing point, not just the amount decoded past the currently playing point.&lt;br /&gt;
&lt;br /&gt;
=== getMovieLength ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLength()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how long in milliseconds a movie is.  Note that this value will not be available for some movies, depending on the server.  If no value is available, then this function will return a length of -1.&lt;br /&gt;
&lt;br /&gt;
=== getVersionString ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a human-readable version string:&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getVersionString()&lt;br /&gt;
&lt;br /&gt;
This string will be of the format:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;liboggplay (a.b) Annodex Media Plugin (API x.y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where a.b is the liboggplay version, and x.y is the API version.  Once accepted, this API will be version 1.0.  Minor changes of the API can add functions but not modify existing functions.&lt;br /&gt;
&lt;br /&gt;
=== getPluginVersion ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a version string for the plugin alone (&amp;quot;a.b&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getPluginVersion()&lt;br /&gt;
&lt;br /&gt;
=== getAPIVersion ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a version string for the Javascript interface alone (&amp;quot;x.y&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getAPIVersion()&lt;br /&gt;
&lt;br /&gt;
== Playlists ==&lt;br /&gt;
&lt;br /&gt;
If you wish to use playlists instead of individual movies, then the above function calls still exist, with the following caveats:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentState&amp;lt;/tt&amp;gt; will not return FINISHED until the last movie in the playlist has completed playback&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; retrieves the currently playing movie - i.e. the movie at the current playlist position&lt;br /&gt;
* &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; sets the currently playing movie (and playback will begin from the beginning of the newly set movie, not the beginning of the playlist)&lt;br /&gt;
* &amp;lt;tt&amp;gt;retrieveAnnotations&amp;lt;/tt&amp;gt; will retrieve the annotations for the current movie only&lt;br /&gt;
* &amp;lt;tt&amp;gt;registerEndPlayCallback&amp;lt;/tt&amp;gt; will call back at the end of the playlist (i.e. at the end of the last movie) only.  Use &amp;lt;tt&amp;gt;registerPlaylistCallback&amp;lt;/tt&amp;gt; to receive notifications per movie.&lt;br /&gt;
* &amp;lt;tt&amp;gt;getMovieLength&amp;lt;/tt&amp;gt; will retrieve the movie length for the current movie only.  Use &amp;lt;tt&amp;gt;getMovieLengthAt&amp;lt;/tt&amp;gt; to retrieve the length for movies in the playlist that are not currently playing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The plugin does not actually recognise separate &amp;quot;single movie&amp;quot; and &amp;quot;playlist&amp;quot; modes - instead, single movies are actually just playlists with length 1.  The interface has been arranged so that the functions above &amp;quot;just work&amp;quot; for what looks like a single movie mode, but are also useful when multiple movies are inserted into the playlist.&lt;br /&gt;
&lt;br /&gt;
The following additional functions are also available for manipulation of the playlist.  These functions are also available when there is only one movie in the playlist, but don&#039;t provide much in the way of useful features.&lt;br /&gt;
&lt;br /&gt;
=== freezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 freezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
This function does not stop the current movie from playing, but does prevent the plugin from progressing to the next movie in the playlist.  Use this and unfreezePlayPosition for &amp;quot;atomic&amp;quot; operations on the playlist.&lt;br /&gt;
&lt;br /&gt;
=== unfreezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 unfreezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
See documentation for freezePlaylistProgression.&lt;br /&gt;
&lt;br /&gt;
=== registerPlaylistCallback ===&lt;br /&gt;
&lt;br /&gt;
 registerPlaylistCallback(function callback(void))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See [[#Callback_functions|Callback functions]] for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use this function to register a javascript function that will get called by the plugin at the end of each movie in the playlist - i.e. when the playlist changes tracks. The last track does &#039;&#039;&#039;not&#039;&#039;&#039; trigger a call; the end play callback, if registered, will be invoked instead.&lt;br /&gt;
&lt;br /&gt;
=== getPlaylistLength ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the length of the playlist:&lt;br /&gt;
&lt;br /&gt;
 int length &amp;lt;- getPlaylistLength()&lt;br /&gt;
&lt;br /&gt;
=== getCurrentPlaylistPosition ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the position in the playlist of the current movie:&lt;br /&gt;
&lt;br /&gt;
 int position &amp;lt;- getCurrentPlaylistPosition()&lt;br /&gt;
&lt;br /&gt;
=== getMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To get the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 string url &amp;lt;- getMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return null if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; can be used to retrieve the movie at the current position.&lt;br /&gt;
&lt;br /&gt;
=== setMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To set the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setMovieAt(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; can be used to change the currently playing movie.&lt;br /&gt;
&lt;br /&gt;
=== appendMovie ===&lt;br /&gt;
&lt;br /&gt;
To append a movie to the end of the playlist:&lt;br /&gt;
&lt;br /&gt;
 appendMovie(string url)&lt;br /&gt;
&lt;br /&gt;
=== insertMovieBefore ===&lt;br /&gt;
&lt;br /&gt;
To insert a movie before a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- insertMovieBefore(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== removeMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To remove a movie from the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- removeMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To start playing a movie at a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playlistNext ===&lt;br /&gt;
&lt;br /&gt;
To start playing the next movie in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playlistNext()&lt;br /&gt;
&lt;br /&gt;
This function will return false if the the current movie is the last one in the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playlistPrev ===&lt;br /&gt;
&lt;br /&gt;
To start playing the previous movie in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playlistPrev()&lt;br /&gt;
&lt;br /&gt;
This function will return false if the the current movie is the first one in the playlist.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotationsAt ===&lt;br /&gt;
&lt;br /&gt;
To retrieve all of the CMML annotations for a movie at a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- retrieveAnnotationsAt(int position, function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See [[#Callback_functions|Callback functions]] for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As per retrieveAnnotations, this function is an asynchronous call and will not return any annotations if the server does not support out-of-band annotation retrieval.&lt;br /&gt;
&lt;br /&gt;
This function will return false if a previous attempt at retrieving annotations is still being processed, or if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== getMovieLengthAt ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This is currently unimplemented.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLengthAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function retrieves the length of the movie at the specified position in the playlist.  The function will return -1 if the movie length can not be determined.&lt;br /&gt;
&lt;br /&gt;
== Callback functions ==&lt;br /&gt;
&lt;br /&gt;
Since Javascript functions are not first-class objects, you can&#039;t pass one directly to the plugin as a callback. You need to wrap your callback in an anonymous object with a single member, &#039;call&#039;:&lt;br /&gt;
&lt;br /&gt;
 // Use this form for callbacks with a string argument, shown as &#039;&#039;function callback(string)&#039;&#039;:&lt;br /&gt;
 plugin.registerCMMLCallback(&lt;br /&gt;
   {&lt;br /&gt;
     call: function(s) { yourCMLLCallback(s); }&lt;br /&gt;
   }&lt;br /&gt;
 );&lt;br /&gt;
 &lt;br /&gt;
 // Use this form for callbacks with no arguments, shown as &#039;&#039;function callback(void)&#039;&#039;:&lt;br /&gt;
 plugin.registerEndPlayCallback(&lt;br /&gt;
   {&lt;br /&gt;
     call: function() { yourEndPlayCallback(); }&lt;br /&gt;
   }&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
Technically, you can inline your callback handling code directly in the &#039;call&#039; function, but it&#039;s much cleaner to just redirect to a stand-alone function for each callback, as shown above.&lt;br /&gt;
&lt;br /&gt;
Deregistering a callback is quite simple:&lt;br /&gt;
&lt;br /&gt;
 plugin.registerPlaylistCallback(null);&lt;br /&gt;
&lt;br /&gt;
= Suggested modifications =&lt;br /&gt;
==Individual Movies==&lt;br /&gt;
== states ==&lt;br /&gt;
 add state LOADING and NULL or uninitialized state &lt;br /&gt;
&lt;br /&gt;
== play ==&lt;br /&gt;
  function play()&lt;br /&gt;
if current state is NULL set state to LOADING else if already in loading state than a second call to play will force playback of what is available. &lt;br /&gt;
&lt;br /&gt;
when a user hits play internally we store a separate state that reports as LOADING but is really LOAD_TO_PLAY state which uses download rate control to predict when we should switch into playing mode. ie if the clip&#039;s duration is 60 seconds and after one second we have buffered 10 seconds of the clip we can safely immediately switch to play mode. In a different instance if after 10 seconds we have downloaded 5 seconds of the clip we should wait until we have buffered 40 seconds as it will take around 40 seconds to download the last 20 seconds of video. &lt;br /&gt;
&lt;br /&gt;
if the clip is a LIVE stream then it will begin playback after a few seconds have been buffered. Controllable by:&lt;br /&gt;
  setLiveBuffer(ms) sets the amount of the clip to buffer for a live stream.&lt;br /&gt;
&lt;br /&gt;
== load ==&lt;br /&gt;
  function load() //possible options include NOCACHE (to load from server even if its cached locally) &lt;br /&gt;
a function to begin loading the current clip without playing it back. &lt;br /&gt;
&lt;br /&gt;
== getDuration ==&lt;br /&gt;
  get the clips duration &lt;br /&gt;
 &lt;br /&gt;
== getBufferedTime ==&lt;br /&gt;
Its unclear if get Buffered time gives you the milliseconds buffered from the beaning of the clip, but thats what it should do. To enable the display of a progress bar for the full clip. Ie getBufferedTime / getDuration&lt;br /&gt;
&lt;br /&gt;
if playing back a live stream it could report amount buffered ahead of current playback point&lt;br /&gt;
&lt;br /&gt;
==playlist==&lt;br /&gt;
&lt;br /&gt;
=== loadMovieAt ===&lt;br /&gt;
to start downloading/buffering a clip later in playlist&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTimeAt === &lt;br /&gt;
to get the amount Buffered for a clip in the playlist.&lt;br /&gt;
&lt;br /&gt;
==Applications Preferences ==&lt;br /&gt;
How much disk space to use to store cached clips. Used for syncing and fast page reload on browser back. Also would be ideal if it looked for &#039;&#039;&#039;response headers&#039;&#039;&#039; that invalidate the cache. default 100megs or maybe use firefox preferences... It should uses last accessed first out cacheting. &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
* another point of comparison: [http://mplayerplug-in.cvs.sourceforge.net/mplayerplug-in/mplayerplug-in/DOCS/tech/javascript.txt?view=markup] (e.g. getDuration)&lt;br /&gt;
&lt;br /&gt;
* suggestion: Include audio capture (and Speex encoding) in the API&lt;/div&gt;</summary>
		<author><name>Tahn</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7081</id>
		<title>OggPlayJavascriptAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7081"/>
		<updated>2007-07-09T12:14:05Z</updated>

		<summary type="html">&lt;p&gt;Tahn: Updated to match the released liboggplay 1.0 api, plus some extra versioning functions that will be added real soon now&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This is a &#039;&#039;&#039;draft API&#039;&#039;&#039; for the OggPlay Firefox plugin.&lt;br /&gt;
&lt;br /&gt;
We want the OggPlay plugin to support both a simple individual movie mode, and a more fully-featured playlist mode.  All of the functions supported in individual movie mode are still useful in playlist mode; however additional functions also become useful.&lt;br /&gt;
&lt;br /&gt;
Note that the amount of available information for an internet-cast Ogg stream depends upon the type of server providing that stream.  In particular, an Apache server with [http://www.annodex.net/software/mod_annodex/index.html mod_annodex] installed provides the following information that is not available for live-streamed or raw file-streamed movies:&lt;br /&gt;
* length of the movie&lt;br /&gt;
* [[CMML]] annotations for the entire movie in advance&lt;br /&gt;
&lt;br /&gt;
Furthermore, mod_annodex provides remote seeking functionality across the entire movie.  Hence, OggPlay allows arbitrary seeking on mod_annodex supported movies.  On the other hand, raw streams and live streams are only seekable within the region that has already been buffered by the player.&lt;br /&gt;
&lt;br /&gt;
== Individual movies ==&lt;br /&gt;
&lt;br /&gt;
=== OggPlayState ===&lt;br /&gt;
&lt;br /&gt;
 enum OggPlayState { PAUSED = 0; PLAYING = 1; FINISHED = 2 };&lt;br /&gt;
&lt;br /&gt;
These are fairly self-evident: the plugin begins in PAUSED or PLAYING state depending on the settings provided through the params tags, and changes to FINISHED state when the movie finishes playback.&lt;br /&gt;
&lt;br /&gt;
=== getCurrentState ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the state:&lt;br /&gt;
&lt;br /&gt;
 int &amp;lt;- getCurrentState()&lt;br /&gt;
&lt;br /&gt;
=== pause ===&lt;br /&gt;
&lt;br /&gt;
 pause()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PLAYING or FINISHED states to PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== play ===&lt;br /&gt;
&lt;br /&gt;
 play()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PAUSED state to PLAYING or FINISHED depending upon the current position within the movie.&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
 restart()&lt;br /&gt;
&lt;br /&gt;
This function will convert any state to PLAYING, and start the movie again from the beginning&lt;br /&gt;
&lt;br /&gt;
=== getCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the currently playing (or just played, or about to play) movie:&lt;br /&gt;
&lt;br /&gt;
 string URL &amp;lt;- getCurrentMovie()&lt;br /&gt;
&lt;br /&gt;
=== setCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To set a new movie:&lt;br /&gt;
&lt;br /&gt;
 setCurrentMovie(string URL)&lt;br /&gt;
&lt;br /&gt;
This will automatically begin playing at the beginning if the state is PLAYING or FINISHED, but will remain paused ready to play at the beginning if the state is PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== getPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To get the current play position (in milliseconds) from the movie:&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getPlayPosition()&lt;br /&gt;
&lt;br /&gt;
=== setPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To set the current play position (in milliseconds):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setPlayPosition(int milliseconds)&lt;br /&gt;
&lt;br /&gt;
Note that if you set a position past the end of the movie then the result will be a play position at the end of the movie, and the player in FINISHED mode.&lt;br /&gt;
&lt;br /&gt;
Note also that certain servers (e.g. plain Ogg files, no mod-annodex installed, etc.) will prevent seeking from being able to occur past the buffered portion of the file; in this case, false will be returned and the play position will be updated as far forward as possible.&lt;br /&gt;
&lt;br /&gt;
=== registerCMMLCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method as each CMML annotation is encountered (i.e. as movie playback reaches the point where the annotation needs to be inserted):&lt;br /&gt;
&lt;br /&gt;
 registerCMMLCallback(function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See the &amp;quot;Callback functions&amp;quot; section for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotations ===&lt;br /&gt;
&lt;br /&gt;
To retrieve all of the CMML annotations for a movie:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- retrieveAnnotations(function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See the &amp;quot;Callback functions&amp;quot; section for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is an asynchronous call; the plugin will create a new http connection to retrieve the annotations. The callback function will be invoked with the annotation string after the annotations have been retrieved.&lt;br /&gt;
&lt;br /&gt;
This function will return false if a previous attempt at retrieving annotations is still being processed.&lt;br /&gt;
&lt;br /&gt;
Note that this won&#039;t return all annotations from some servers, e.g. if mod-annodex is not installed.  In this case, you will still be able to retrieve CMML as each annotation is encountered using registerCMMLCallback.&lt;br /&gt;
&lt;br /&gt;
=== registerEndPlayCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method when the movie finishes:&lt;br /&gt;
&lt;br /&gt;
 registerEndPlayCallback(function callback(void))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See the &amp;quot;Callback functions&amp;quot; section for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== setVolume ===&lt;br /&gt;
&lt;br /&gt;
 setVolume(float volume)&lt;br /&gt;
&lt;br /&gt;
Use this function to set the playback volume.  A value of 0.0 is equivalent to muting; a value of 1.0 is maximum volume.&lt;br /&gt;
&lt;br /&gt;
=== getVolume ===&lt;br /&gt;
&lt;br /&gt;
 float volume &amp;lt;- getVolume()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the current playback volume.&lt;br /&gt;
&lt;br /&gt;
=== getWindowWidth ===&lt;br /&gt;
&lt;br /&gt;
 int width &amp;lt;- getWindowWidth()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the width of the window in pixels (The width is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getWindowHeight ===&lt;br /&gt;
&lt;br /&gt;
 int height &amp;lt;- getWindowHeight()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the height of the window in pixels (The height is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTime ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getBufferedTime()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how many milliseconds of the current movie are buffered for display.  Note that this is the amount downloaded past the currently playing point, not just the amount decoded past the currently playing point.&lt;br /&gt;
&lt;br /&gt;
=== getMovieLength ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLength()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how long in milliseconds a movie is.  Note that this value will not be available for some movies, depending on the server.  If no value is available, then this function will return a length of -1.&lt;br /&gt;
&lt;br /&gt;
=== getVersionString ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a human-readable version string:&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getVersionString()&lt;br /&gt;
&lt;br /&gt;
This string will be of the format:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;liboggplay (a.b) Annodex Media Plugin (API x.y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where a.b is the liboggplay version, and x.y is the API version.  Once accepted, this API will be version 1.0.  Minor changes of the API can add functions but not modify existing functions.&lt;br /&gt;
&lt;br /&gt;
=== getPluginVersion ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a version string for the plugin alone (&amp;quot;a.b&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getPluginVersion()&lt;br /&gt;
&lt;br /&gt;
=== getAPIVersion ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a version string for the Javascript interface alone (&amp;quot;x.y&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getAPIVersion()&lt;br /&gt;
&lt;br /&gt;
== Playlists ==&lt;br /&gt;
&lt;br /&gt;
If you wish to use playlists instead of individual movies, then the above function calls still exist, with the following caveats:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentState&amp;lt;/tt&amp;gt; will not return FINISHED until the last movie in the playlist has completed playback&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; retrieves the currently playing movie - i.e. the movie at the current playlist position&lt;br /&gt;
* &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; sets the currently playing movie (and playback will begin from the beginning of the newly set movie, not the beginning of the playlist)&lt;br /&gt;
* &amp;lt;tt&amp;gt;retrieveAnnotations&amp;lt;/tt&amp;gt; will retrieve the annotations for the current movie only&lt;br /&gt;
* &amp;lt;tt&amp;gt;registerEndPlayCallback&amp;lt;/tt&amp;gt; will call back at the end of the playlist (i.e. at the end of the last movie) only.  Use &amp;lt;tt&amp;gt;registerPlaylistCallback&amp;lt;/tt&amp;gt; to receive notifications per movie.&lt;br /&gt;
* &amp;lt;tt&amp;gt;getMovieLength&amp;lt;/tt&amp;gt; will retrieve the movie length for the current movie only.  Use &amp;lt;tt&amp;gt;getMovieLengthAt&amp;lt;/tt&amp;gt; to retrieve the length for movies in the playlist that are not currently playing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The plugin does not actually recognise separate &amp;quot;single movie&amp;quot; and &amp;quot;playlist&amp;quot; modes - instead, single movies are actually just playlists with length 1.  The interface has been arranged so that the functions above &amp;quot;just work&amp;quot; for what looks like a single movie mode, but are also useful when multiple movies are inserted into the playlist.&lt;br /&gt;
&lt;br /&gt;
The following additional functions are also available for manipulation of the playlist.  These functions are also available when there is only one movie in the playlist, but don&#039;t provide much in the way of useful features.&lt;br /&gt;
&lt;br /&gt;
=== freezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 freezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
This function does not stop the current movie from playing, but does prevent the plugin from progressing to the next movie in the playlist.  Use this and unfreezePlayPosition for &amp;quot;atomic&amp;quot; operations on the playlist.&lt;br /&gt;
&lt;br /&gt;
=== unfreezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 unfreezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
See documentation for freezePlaylistProgression.&lt;br /&gt;
&lt;br /&gt;
=== registerPlaylistCallback ===&lt;br /&gt;
&lt;br /&gt;
 registerPlaylistCallback(function callback(void))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See the &amp;quot;Callback functions&amp;quot; section for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use this function to register a javascript function that will get called by the plugin at the end of each movie in the playlist - i.e. when the playlist changes tracks. The last track does &#039;&#039;&#039;not&#039;&#039;&#039; trigger a call; the end play callback, if registered, will be invoked instead.&lt;br /&gt;
&lt;br /&gt;
=== getPlaylistLength ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the length of the playlist:&lt;br /&gt;
&lt;br /&gt;
 int length &amp;lt;- getPlaylistLength()&lt;br /&gt;
&lt;br /&gt;
=== getCurrentPlaylistPosition ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the position in the playlist of the current movie:&lt;br /&gt;
&lt;br /&gt;
 int position &amp;lt;- getCurrentPlaylistPosition()&lt;br /&gt;
&lt;br /&gt;
=== getMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To get the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 string url &amp;lt;- getMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return null if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; can be used to retrieve the movie at the current position.&lt;br /&gt;
&lt;br /&gt;
=== setMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To set the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setMovieAt(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; can be used to change the currently playing movie.&lt;br /&gt;
&lt;br /&gt;
=== appendMovie ===&lt;br /&gt;
&lt;br /&gt;
To append a movie to the end of the playlist:&lt;br /&gt;
&lt;br /&gt;
 appendMovie(string url)&lt;br /&gt;
&lt;br /&gt;
=== insertMovieBefore ===&lt;br /&gt;
&lt;br /&gt;
To insert a movie before a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- insertMovieBefore(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== removeMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To remove a movie from the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- removeMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To start playing a movie at a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playlistNext ===&lt;br /&gt;
&lt;br /&gt;
To start playing the next movie in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playlistNext()&lt;br /&gt;
&lt;br /&gt;
This function will return false if the the current movie is the last one in the playlist.&lt;br /&gt;
&lt;br /&gt;
=== playlistPrev ===&lt;br /&gt;
&lt;br /&gt;
To start playing the previous movie in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- playlistPrev()&lt;br /&gt;
&lt;br /&gt;
This function will return false if the the current movie is the first one in the playlist.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotationsAt ===&lt;br /&gt;
&lt;br /&gt;
To retrieve all of the CMML annotations for a movie at a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- retrieveAnnotationsAt(int position, function callback(string))&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;See the &amp;quot;Callback functions&amp;quot; section for details on setting up a Javascript callback function.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As per retrieveAnnotations, this function is an asynchronous call and will not return any annotations if the server does not support out-of-band annotation retrieval.&lt;br /&gt;
&lt;br /&gt;
This function will return false if a previous attempt at retrieving annotations is still being processed, or if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== getMovieLengthAt ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This is currently unimplemented.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLengthAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function retrieves the length of the movie at the specified position in the playlist.  The function will return -1 if the movie length can not be determined.&lt;br /&gt;
&lt;br /&gt;
== Callback functions ==&lt;br /&gt;
&lt;br /&gt;
(to do)&lt;br /&gt;
&lt;br /&gt;
= Suggested modifications =&lt;br /&gt;
==Individual Movies==&lt;br /&gt;
== states ==&lt;br /&gt;
 add state LOADING and NULL or uninitialized state &lt;br /&gt;
&lt;br /&gt;
== play ==&lt;br /&gt;
  function play()&lt;br /&gt;
if current state is NULL set state to LOADING else if already in loading state than a second call to play will force playback of what is available. &lt;br /&gt;
&lt;br /&gt;
when a user hits play internally we store a separate state that reports as LOADING but is really LOAD_TO_PLAY state which uses download rate control to predict when we should switch into playing mode. ie if the clip&#039;s duration is 60 seconds and after one second we have buffered 10 seconds of the clip we can safely immediately switch to play mode. In a different instance if after 10 seconds we have downloaded 5 seconds of the clip we should wait until we have buffered 40 seconds as it will take around 40 seconds to download the last 20 seconds of video. &lt;br /&gt;
&lt;br /&gt;
if the clip is a LIVE stream then it will begin playback after a few seconds have been buffered. Controllable by:&lt;br /&gt;
  setLiveBuffer(ms) sets the amount of the clip to buffer for a live stream.&lt;br /&gt;
&lt;br /&gt;
== load ==&lt;br /&gt;
  function load() //possible options include NOCACHE (to load from server even if its cached locally) &lt;br /&gt;
a function to begin loading the current clip without playing it back. &lt;br /&gt;
&lt;br /&gt;
== getDuration ==&lt;br /&gt;
  get the clips duration &lt;br /&gt;
 &lt;br /&gt;
== getBufferedTime ==&lt;br /&gt;
Its unclear if get Buffered time gives you the milliseconds buffered from the beaning of the clip, but thats what it should do. To enable the display of a progress bar for the full clip. Ie getBufferedTime / getDuration&lt;br /&gt;
&lt;br /&gt;
if playing back a live stream it could report amount buffered ahead of current playback point&lt;br /&gt;
&lt;br /&gt;
==playlist==&lt;br /&gt;
&lt;br /&gt;
=== loadMovieAt ===&lt;br /&gt;
to start downloading/buffering a clip later in playlist&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTimeAt === &lt;br /&gt;
to get the amount Buffered for a clip in the playlist.&lt;br /&gt;
&lt;br /&gt;
==Applications Preferences ==&lt;br /&gt;
How much disk space to use to store cached clips. Used for syncing and fast page reload on browser back. Also would be ideal if it looked for &#039;&#039;&#039;response headers&#039;&#039;&#039; that invalidate the cache. default 100megs or maybe use firefox preferences... It should uses last accessed first out cacheting. &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
* another point of comparison: [http://mplayerplug-in.cvs.sourceforge.net/mplayerplug-in/mplayerplug-in/DOCS/tech/javascript.txt?view=markup] (e.g. getDuration)&lt;br /&gt;
&lt;br /&gt;
* suggestion: Include audio capture (and Speex encoding) in the API&lt;/div&gt;</summary>
		<author><name>Tahn</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7055</id>
		<title>OggPlayJavascriptAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggPlayJavascriptAPI&amp;diff=7055"/>
		<updated>2007-06-28T01:59:08Z</updated>

		<summary type="html">&lt;p&gt;Tahn: Added removeMovieAt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This is a &#039;&#039;&#039;draft API&#039;&#039;&#039; for the OggPlay Firefox plugin.&lt;br /&gt;
&lt;br /&gt;
We want the OggPlay plugin to support both a simple individual movie mode, and a more fully-featured playlist mode.  All of the functions supported in individual movie mode are still useful in playlist mode; however additional functions also become useful.&lt;br /&gt;
&lt;br /&gt;
Note that the amount of available information for an internet-cast Ogg stream depends upon the type of server providing that stream.  In particular, an Apache server with [http://www.annodex.net/software/mod_annodex/index.html mod_annodex] installed provides the following information that is not available for live-streamed or raw file-streamed movies:&lt;br /&gt;
* length of the movie&lt;br /&gt;
* [[CMML]] annotations for the entire movie in advance&lt;br /&gt;
&lt;br /&gt;
Furthermore, mod_annodex provides remote seeking functionality across the entire movie.  Hence, OggPlay allows arbitrary seeking on mod_annodex supported movies.  On the other hand, raw streams and live streams are only seekable within the region that has already been buffered by the player.&lt;br /&gt;
&lt;br /&gt;
== Individual movies ==&lt;br /&gt;
&lt;br /&gt;
=== OggPlayState ===&lt;br /&gt;
&lt;br /&gt;
 enum OggPlayState { PAUSED = 0; PLAYING = 1; FINISHED = 2 };&lt;br /&gt;
&lt;br /&gt;
These are fairly self-evident: the plugin begins in PAUSED or PLAYING state depending on the settings provided through the params tags, and changes to FINISHED state when the movie finishes playback.&lt;br /&gt;
&lt;br /&gt;
=== getCurrentState ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the state:&lt;br /&gt;
&lt;br /&gt;
 int &amp;lt;- getCurrentState()&lt;br /&gt;
&lt;br /&gt;
=== pause ===&lt;br /&gt;
&lt;br /&gt;
 pause()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PLAYING or FINISHED states to PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== play ===&lt;br /&gt;
&lt;br /&gt;
 play()&lt;br /&gt;
&lt;br /&gt;
This function will convert the PAUSED state to PLAYING or FINISHED depending upon the current position within the movie.&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
 restart()&lt;br /&gt;
&lt;br /&gt;
This function will convert any state to PLAYING, and start the movie again from the beginning&lt;br /&gt;
&lt;br /&gt;
=== getCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the currently playing (or just played, or about to play) movie:&lt;br /&gt;
&lt;br /&gt;
 string URL &amp;lt;- getCurrentMovie()&lt;br /&gt;
&lt;br /&gt;
=== setCurrentMovie ===&lt;br /&gt;
&lt;br /&gt;
To set a new movie:&lt;br /&gt;
&lt;br /&gt;
 setCurrentMovie(string URL)&lt;br /&gt;
&lt;br /&gt;
This will automatically begin playing at the beginning if the state is PLAYING or FINISHED, but will remain paused ready to play at the beginning if the state is PAUSED.&lt;br /&gt;
&lt;br /&gt;
=== getPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To get the current play position (in milliseconds) from the movie:&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getPlayPosition()&lt;br /&gt;
&lt;br /&gt;
=== setPlayPosition ===&lt;br /&gt;
&lt;br /&gt;
To set the current play position (in milliseconds):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setPlayPosition(int milliseconds)&lt;br /&gt;
&lt;br /&gt;
Note that if you set a position past the end of the movie then the result will be a play position at the end of the movie, and the player in FINISHED mode.&lt;br /&gt;
&lt;br /&gt;
Note also that certain servers (e.g. plain Ogg files, no mod-annodex installed, etc.) will prevent seeking from being able to occur past the buffered portion of the file; in this case, false will be returned and the play position will be updated as far forward as possible.&lt;br /&gt;
&lt;br /&gt;
=== registerCMMLCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method as each CMML annotation is encountered (i.e. as movie playback reaches the point where the annotation needs to be inserted):&lt;br /&gt;
&lt;br /&gt;
 registerCMMLCallback(function callback)&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotations ===&lt;br /&gt;
&lt;br /&gt;
To retrieve all of the CMML annotations for a movie:&lt;br /&gt;
&lt;br /&gt;
 string CMML &amp;lt;- retrieveAnnotations()&lt;br /&gt;
&lt;br /&gt;
Note that this won&#039;t return all annotations from some servers, e.g. if mod-annodex is not installed.  In this case, you will still be able to retrieve CMML as each annotation is encountered using registerCMMLCallback.&lt;br /&gt;
&lt;br /&gt;
=== registerEndPlayCallback ===&lt;br /&gt;
&lt;br /&gt;
To have the plugin call a javascript method when the movie finishes:&lt;br /&gt;
&lt;br /&gt;
 registerEndPlayCallback(function callback)&lt;br /&gt;
&lt;br /&gt;
Use null if you want to deregister the callback without setting a new one.&lt;br /&gt;
&lt;br /&gt;
=== setVolume ===&lt;br /&gt;
&lt;br /&gt;
 setVolume(float volume)&lt;br /&gt;
&lt;br /&gt;
Use this function to set the playback volume.  A value of 0.0 is equivalent to muting; a value of 1.0 is maximum volume.&lt;br /&gt;
&lt;br /&gt;
=== getVolume ===&lt;br /&gt;
&lt;br /&gt;
 float volume &amp;lt;- getVolume()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the current playback volume.&lt;br /&gt;
&lt;br /&gt;
=== getWindowWidth ===&lt;br /&gt;
&lt;br /&gt;
 int width &amp;lt;- getWindowWidth()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the width of the window in pixels (The width is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getWindowHeight ===&lt;br /&gt;
&lt;br /&gt;
 int height &amp;lt;- getWindowHeight()&lt;br /&gt;
&lt;br /&gt;
Use this function to retrieve the height of the window in pixels (The height is determined by the Firefox render model)&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTime ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getBufferedTime()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how many milliseconds of the current movie are buffered for display.  Note that this is the amount downloaded past the currently playing point, not just the amount decoded past the currently playing point.&lt;br /&gt;
&lt;br /&gt;
=== getMovieLength ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLength()&lt;br /&gt;
&lt;br /&gt;
Use this function to determine how long in milliseconds a movie is.  Note that this value will not be available for some movies, depending on the server.  If no value is available, then this function will return a length of -1.&lt;br /&gt;
&lt;br /&gt;
=== getVersionString ===&lt;br /&gt;
&lt;br /&gt;
To retrieve a version string:&lt;br /&gt;
&lt;br /&gt;
 string version &amp;lt;- getVersionString()&lt;br /&gt;
&lt;br /&gt;
This string will be of the format:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;liboggplay (a.b) Annodex Media Plugin (API x.y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where a.b is the liboggplay version, and x.y is the API version.  Once accepted, this API will be version 1.0.  Minor changes of the API can add functions but not modify existing functions.&lt;br /&gt;
&lt;br /&gt;
== Playlists ==&lt;br /&gt;
&lt;br /&gt;
If you wish to use playlists instead of individual movies, then the above function calls still exist, with the following caveats:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentState&amp;lt;/tt&amp;gt; will not return FINISHED until the last movie in the playlist has completed playback&lt;br /&gt;
* &amp;lt;tt&amp;gt;restart&amp;lt;/tt&amp;gt; will start from the beginning of the playlist, not the beginning of the current movie&lt;br /&gt;
* &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; retrieves the currently playing movie - i.e. the movie at the current playlist position&lt;br /&gt;
* &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; sets the currently playing movie (and playback will begin from the beginning of the newly set movie, not the beginning of the playlist)&lt;br /&gt;
* &amp;lt;tt&amp;gt;getPlayPosition&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;setPlayPosition&amp;lt;/tt&amp;gt; operate on the playlist as a whole - i.e. if a playlist consists of a 5 second, a 7 second and a 4 second movie, then setPlayPosition(6000) will start playing from 1 second into the 2nd movie.  In situations where the size of movies not yet encountered can not be determined (e.g. if mod-annodex is not installed on the server), then false will be returned if &amp;lt;tt&amp;gt;setPlayPosition&amp;lt;/tt&amp;gt; requests a position past the furthest encountered position, and the furthest encountered position will be set.&lt;br /&gt;
* &amp;lt;tt&amp;gt;retrieveAnnotations&amp;lt;/tt&amp;gt; will retrieve the annotations for the current movie only&lt;br /&gt;
* &amp;lt;tt&amp;gt;registerEODCallback&amp;lt;/tt&amp;gt; will call back at the end of the playlist (i.e. at the end of the last movie) only.  Use &amp;lt;tt&amp;gt;registerPlaylistCallback&amp;lt;/tt&amp;gt; to recieve notifications per movie.&lt;br /&gt;
* &amp;lt;tt&amp;gt;getMovieLength&amp;lt;/tt&amp;gt; will retrieve the movie length for the current movie only.  Use &amp;lt;tt&amp;gt;getMovieLengthAt&amp;lt;/tt&amp;gt; to retrieve he movie length for movies in the playlist that are not currently playing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The plugin does not actually recognise separate &amp;quot;single movie&amp;quot; and &amp;quot;playlist&amp;quot; modes - instead, single movies are actually just playlists with length 1.  The interface has been arranged so that the functions above &amp;quot;just work&amp;quot; for what looks like a single movie mode, but are also useful when multiple movies are inserted into the playlist.&lt;br /&gt;
&lt;br /&gt;
The following additional functions are also available for manipulation of the playlist.  These functions are also available when there is only one movie in the playlist, but don&#039;t provide much in the way of useful features.&lt;br /&gt;
&lt;br /&gt;
=== freezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 freezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
This function does not stop the current movie from playing, but does prevent the plugin from progressing to the next movie in the playlist.  Use this and unfreezePlayPosition for &amp;quot;atomic&amp;quot; operations on the playlist.&lt;br /&gt;
&lt;br /&gt;
=== unfreezePlaylistProgression ===&lt;br /&gt;
&lt;br /&gt;
 unfreezePlaylistProgression()&lt;br /&gt;
&lt;br /&gt;
See documentation for freezePlaylistProgression.&lt;br /&gt;
&lt;br /&gt;
=== registerPlaylistCallback ===&lt;br /&gt;
&lt;br /&gt;
 registerPlaylistCallback(function callback)&lt;br /&gt;
&lt;br /&gt;
Use this function to register a javascript function that will get called by the plugin at the end of each movie in the playlist - i.e. when the playlist changes tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; the last track will also trigger a call.  In the following circumstance&lt;br /&gt;
&lt;br /&gt;
 // there are 3 movies in the playlist&lt;br /&gt;
 registerPlaylistCallback(callbackA)&lt;br /&gt;
 registerEODCallback(callbackB)&lt;br /&gt;
&lt;br /&gt;
Then &amp;lt;tt&amp;gt;callbackA&amp;lt;/tt&amp;gt; will be called 3 times, and &amp;lt;tt&amp;gt;callbackB&amp;lt;/tt&amp;gt; will be called once&lt;br /&gt;
&lt;br /&gt;
=== getPlaylistLength ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the length of the playlist:&lt;br /&gt;
&lt;br /&gt;
 int length &amp;lt;- getPlaylistLength()&lt;br /&gt;
&lt;br /&gt;
=== getCurrentPlaylistPosition ===&lt;br /&gt;
&lt;br /&gt;
To retrieve the position in the playlist of the current movie:&lt;br /&gt;
&lt;br /&gt;
 int position &amp;lt;- getCurrentPlaylistPosition()&lt;br /&gt;
&lt;br /&gt;
=== getMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To get the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 string url &amp;lt;- getMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return null if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;getCurrentMovie&amp;lt;/tt&amp;gt; can be used to retrieve the movie at the current position.&lt;br /&gt;
&lt;br /&gt;
=== setMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To set the url of the movie at the specified position (0 is the first position):&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setMovieAt(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;lt;tt&amp;gt;setCurrentMovie&amp;lt;/tt&amp;gt; can be used to change the currently playing movie.&lt;br /&gt;
&lt;br /&gt;
=== appendMovie ===&lt;br /&gt;
&lt;br /&gt;
To append a movie to the end of the playlist:&lt;br /&gt;
&lt;br /&gt;
 appendMovie(string url)&lt;br /&gt;
&lt;br /&gt;
=== insertMovieBefore ===&lt;br /&gt;
&lt;br /&gt;
To insert a movie before a specified position in the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- insertMovieBefore(int position, string url)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== removeMovieAt ===&lt;br /&gt;
&lt;br /&gt;
To remove a movie from the playlist:&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- removeMovieAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function will return false if the position points to a slot outside the bounds of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== getPlayPositionWithinMovie ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getPlayPositionWithinMovie()&lt;br /&gt;
&lt;br /&gt;
This function retrieves the play position in milliseconds relative to the beginning of the current movie.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;getPlayPosition&amp;lt;/tt&amp;gt; to retrieve the play position relative to the beginning of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== setPlayPositionWithinMovie ===&lt;br /&gt;
&lt;br /&gt;
 boolean success &amp;lt;- setPlayPositionWithinMovie(int milliseconds)&lt;br /&gt;
&lt;br /&gt;
This function sets the play position in milliseconds relative to the beginning of the current movie.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;setPlayPosition&amp;lt;/tt&amp;gt; to set the play position relative to the beginning of the playlist.&lt;br /&gt;
&lt;br /&gt;
=== retrieveAnnotationsAt ===&lt;br /&gt;
&lt;br /&gt;
 string CMML &amp;lt;- retrieveAnnotationsAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function retrieves the CMML annotations from the movie at the specified position in the playlist.  The function will return an empty string in the following cases:&lt;br /&gt;
&lt;br /&gt;
* the movie at this position has no annotation&lt;br /&gt;
* the movie at this position is being served from a server that does not support out-of-band annotation retrieval&lt;br /&gt;
* the position is not a valid position (i.e. is outside the bounds of the playlist)&lt;br /&gt;
&lt;br /&gt;
=== getMovieLengthAt ===&lt;br /&gt;
&lt;br /&gt;
 int milliseconds &amp;lt;- getMovieLengthAt(int position)&lt;br /&gt;
&lt;br /&gt;
This function retrieves the length of the movie at the specified position in the playlist.  The function will return -1 if the movie length can not be determined.&lt;br /&gt;
&lt;br /&gt;
= Suggested modifications =&lt;br /&gt;
==Individual Movies==&lt;br /&gt;
== states ==&lt;br /&gt;
 add state LOADING and NULL or uninitialized state &lt;br /&gt;
&lt;br /&gt;
== play ==&lt;br /&gt;
  function play()&lt;br /&gt;
if current state is NULL set state to LOADING else if already in loading state than a second call to play will force playback of what is available. &lt;br /&gt;
&lt;br /&gt;
when a user hits play internally we store a separate state that reports as LOADING but is really LOAD_TO_PLAY state which uses download rate control to predict when we should switch into playing mode. ie if the clip&#039;s duration is 60 seconds and after one second we have buffered 10 seconds of the clip we can safely immediately switch to play mode. In a different instance if after 10 seconds we have downloaded 5 seconds of the clip we should wait until we have buffered 40 seconds as it will take around 40 seconds to download the last 20 seconds of video. &lt;br /&gt;
&lt;br /&gt;
if the clip is a LIVE stream then it will begin playback after a few seconds have been buffered. Controllable by:&lt;br /&gt;
  setLiveBuffer(ms) sets the amount of the clip to buffer for a live stream.&lt;br /&gt;
&lt;br /&gt;
== load ==&lt;br /&gt;
  function load() //possible options include NOCACHE (to load from server even if its cached locally) &lt;br /&gt;
a function to begin loading the current clip without playing it back. &lt;br /&gt;
&lt;br /&gt;
== getDuration ==&lt;br /&gt;
  get the clips duration &lt;br /&gt;
 &lt;br /&gt;
== getBufferedTime ==&lt;br /&gt;
Its unclear if get Buffered time gives you the milliseconds buffered from the beaning of the clip, but thats what it should do. To enable the display of a progress bar for the full clip. Ie getBufferedTime / getDuration&lt;br /&gt;
&lt;br /&gt;
if playing back a live stream it could report amount buffered ahead of current playback point&lt;br /&gt;
&lt;br /&gt;
==playlist==&lt;br /&gt;
&lt;br /&gt;
=== loadMovieAt ===&lt;br /&gt;
to start downloading/buffering a clip later in playlist&lt;br /&gt;
&lt;br /&gt;
=== getBufferedTimeAt === &lt;br /&gt;
to get the amount Buffered for a clip in the playlist.&lt;br /&gt;
&lt;br /&gt;
==Applications Preferences ==&lt;br /&gt;
How much disk space to use to store cached clips. Used for syncing and fast page reload on browser back. Also would be ideal if it looked for &#039;&#039;&#039;response headers&#039;&#039;&#039; that invalidate the cache. default 100megs or maybe use firefox preferences... It should uses last accessed first out cacheting. &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
* another point of comparison: [http://mplayerplug-in.cvs.sourceforge.net/mplayerplug-in/mplayerplug-in/DOCS/tech/javascript.txt?view=markup] (e.g. getDuration)&lt;br /&gt;
&lt;br /&gt;
* suggestion: Include audio capture (and Speex encoding) in the API&lt;/div&gt;</summary>
		<author><name>Tahn</name></author>
	</entry>
</feed>