Build HTML pages that use the plugin (version > 0.8.5.1)
Additionally to viewing video on all pages, you can build custom pages that will use the advanced features of the plugin, using Javascript functions to control playback or extract information from the plugin.
The vlc plugin exports serveral objects that can be accessed for setting and getting information. When used improperly the API's will throw an exception that includes a string that explains what happened. For example when asking for vlc.input.length when there is no playlist item playing.
The vlc plugin knows the following objects:
audio : Access audio properties.
input : Access input properties.
playlist : Access playlist properties.
video : Access video properties.
log : Access log properties.
messages : Access to log message properties.
iterator : Access to log iterator properties.
The following JavaScript code shows howto get a reference to the vlc plugin. This reference can then be used to access the objects of the vlc plugin.
<html>
<title>VLC Mozilla plugin test page</title>
<body>
<embed type="application/x-vlc-plugin" pluginspage="
http://www.videolan.org" version="VideoLAN.VLCPlugin.2"
width="640"
height="480"
id="vlc">
</embed>
<script language="Javascript">
<!--
var vlc = document.getElementById("vlc");
vlc.audio.toggleMute();
!-->
</script>
</body>
</html>
Root object
readonly properties
VersionInfo : returns version information string
read/write properties
none
methods
vlc.versionInfo() : returns version information string
Audio object
readonly properties
none
read/write properties
vlc.audio.mute : boolean value to mute and ummute the audio
vlc.audio.volume : a value between [0-200] which indicates a percentage of the volume.
methods
vlc.audio.toggleMute() : boolean toggle that mutes and unmutes the audio based upon the previous state
Input object
readonly properties
vlc.input.length : length of the input file in number of milliseconds
vlc.input.fps : frames per second returned as a float
vlc.input.hasVout : a boolean that returns true when the video is being displayed, it returns false when video is not displayed
read/write properties
vlc.input.position : normalized position in multimedia stream item given as a float value between [0.0 - 1.0]
vlc.input.time : the absolute position in time given in milliseconds, this property can be used to seek through the stream
<!-- absolute seek in stream !-->
vlc.input.time = <absolute seek>
<!-- relative seek in stream !-->
vlc.input.time = vlc.input.time + <relative seek>
vlc.input.state : current state of the input chain given as enumeration (IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4, STOPPING=5, ERROR=6)
vlc.input.rate : input speed given as float (1.0 for normal speed, 0.5 for half speed, 2.0 for twice as fast, etc.)
methods
none
Playlist object
readonly properties
vlc.playlist.itemCount : number that returns the amount of items currently in the playlist
vlc.playlist.isPlaying : a boolean that returns true if the current playlist item is playing and false when it is not playing
read/write properties
none
methods
vlc.playlist.add(mrl) : add a playlist item as MRL (Multimedia Resource Locator). The MRL must be given as a string.
vlc.playlist.add(mrl,name,options) : add a playlist item as MRL (Multimedia Resource Locator), with metaname 'name' and options 'options'. All input values must be given as string.
vlc.playlist.play() : start playing the current playlist item
vlc.playlist.togglePause() : toggle the pause state for the current playlist item
vlc.playlist.stop() : stop playing the current playlist item
vlc.playlist.next() : iterate to the next playlist item
vlc.playlist.prev() : iterate to the previous playlist item
vlc.playlist.clear() : empty the current playlist, all items will be deleted from the playlist
vlc.playlist.removeItem(number) : remove the given item number (which cannot be greater then vlc.playlist.itemCount)
Video object
readonly properties
vlc.video.width : returns the horizontal size of the video
vlc.video.height : returns the vertical size of the video
read/write properties
vlc.video.fullscreen : when set to true the video will be displayed in fullscreen mode, when set to false the video will be shown inside the video output size. The property takes a boolean as input.
vlc.video.aspectRatio : get and set the aspect ratio to use in the video screen. The property takes a string as input value. Valid values are: "1:1", "4:3", "16:9", "16:10", "221:100" and "5:4"
methods
vlc.video.toggleFullscreen() : toggle the fullscreen mode based on the previous setting
Log object
readonly properties
vlc.log.messages : returns a messages object
read/write properties
vlc.log.verbosity : write number [-1,0,1,2,3] for changing the verbosity level of the log messages. The numbers have the following meaning: -1 disable, 0 info, 1 error, 2 warning, 3 debug.
methods
none
Messages object
readonly properties
messages.count : returns number of messages in the log
messages.severity : number that indicates the severity of the log message (0 = info, 1 = error, 2 = warning, 3 = debug)
message.name : name of VLC module that printed the log message (e.g: main, http, directx, etc...)
message.type : type of VLC module that printed the log message (eg: input, access, vout, sout, etc...)
message.message : the message text
read/write properties
none
methods
messages.clear() : clear the current log buffer. It should be called as frequently as possible to not overflow the plugins logging buffer. Call this method after the log messages of interest are read.
messages.iterator() : returns a messages iterator object, which is used to iterate over the messages in the log. <b>Don't clear the log buffer while holding an iterator object.</b>
Iterator object
readonly properties
iterator.hasNext : returns a boolean that indicates when true, that wheter vlc.log.messages.next() returns the next message.
read/write properties
none
methods
iterator.next() : returns the next message object it the log