Difference between revisions of "Documentation:WebPlugin"

From VideoLAN Wiki
Jump to navigation Jump to search
(→‎Root object: Add getVersionInfo())
(→‎Playlist object: Improve description for vlc.playlist.parse())
 
(53 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Outdated}}
 +
 
This Documentation speaks about the {{VLC}} Web plugins and how to write pages for it.  
 
This Documentation speaks about the {{VLC}} Web plugins and how to write pages for it.  
 
{{RightMenu|Documentation TOC}}
 
{{RightMenu|Documentation TOC}}
  
= Introduction: Building Web pages with Video =
+
== Introduction: Building Web pages with Video ==
  
 
The {{VLC}} webplugins are native browser plugins, similar to Flash or Silverlight plugins and allow playback inside the browser of all the videos that {{VLC}} can read.
 
The {{VLC}} webplugins are native browser plugins, similar to Flash or Silverlight plugins and allow playback inside the browser of all the videos that {{VLC}} can read.
  
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.  
+
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.  
  
 
There are 2 main plugins: one is ActiveX for IE, the other is NPAPI for the other browsers. They feature the same amount of features.
 
There are 2 main plugins: one is ActiveX for IE, the other is NPAPI for the other browsers. They feature the same amount of features.
Line 16: Line 18:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
| Mozilla Firefox || [[Image:Firefox-logo.png|40x40px]]
+
| Mozilla Firefox (up to v51) || [[File:Firefox-logo.png|40x40px]]
 
|-
 
|-
| Internet Explorer || [[Image:20101105053305!Internet Explorer 9.png|40x40px]]
+
| Internet Explorer || [[File:Internet Explorer.png|40x40px]]
 
|-
 
|-
| Safari || [[Image:Apple Safari.png|40x40px]]
+
| Safari (up to v11) || [[File:Apple Safari.png|40x40px]]
 
|-
 
|-
| Chrome ||  
+
| Chrome (up to v44) ||  
 
|-
 
|-
 
| Konqueror ||  
 
| Konqueror ||  
 
|-
 
|-
| Opera ||
+
| Opera (up to v36) ||
 
|}
 
|}
  
 
It has been tested on GNU/Linux, Windows and MacOS.
 
It has been tested on GNU/Linux, Windows and MacOS.
  
= Embed tag attributes =
 
  
To embed the plugin into a webpage, use the following <embed> template:  
+
'''Note:'''
 +
 
 +
In the most of browsers, the support for NPAPI plugins was dropped. Only in some forks of Firefox like Waterfox or Pale Moon, NPAPI plugins are still supported.
 +
 
 +
For this reason, the NPAPI plugin will be dropped in vlc version 4.
 +
 
 +
== Embed tag attributes ==
 +
 
 +
To embed the plugin into a webpage, use the following {{tag|embed}} template:  
  
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" />
+
<embed type="application/x-vlc-plugin" width="640" height="480" />
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
If you are using vlc version < 2.2.0 with Internet Explorer, use instead the following <object> template:  
+
If you are using vlc version < 2.2.0 with Internet Explorer, use instead the following {{tag|object}} template:  
  
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"></object>
+
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" width="640" height="480"></object>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
For the declaration of tag attributes, use the tag <param>. Here a example:
+
For the declaration of tag attributes, use the tag {{tag|param}}. Here an example:
  
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab">
+
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" width="640" height="480">
 
     <param name="autostart" value="true" />
 
     <param name="autostart" value="true" />
 
     <param name="allowfullscreen" value="false" />
 
     <param name="allowfullscreen" value="false" />
Line 58: Line 67:
  
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab" id="vlc">
+
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" id="vlc" width="640" height="480">
     <embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" name="vlc" />
+
     <embed type="application/x-vlc-plugin" name="vlc" width="640" height="480" />
 
</object>
 
</object>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
=== Required elements ===
 
=== Required elements ===
These are '''required''' attributes for the &lt;embed&gt; tag:  
+
These are '''required''' attributes for the {{tag|embed}} tag:  
  
 
*'''width''': Specifies the width of the plugin.  
 
*'''width''': Specifies the width of the plugin.  
Line 71: Line 80:
  
 
=== Optional elements ===
 
=== Optional elements ===
These are additional attributes for the &lt;embed&gt; tag:  
+
These are additional attributes for the {{tag|embed}} tag:  
  
 
*'''autoplay''', '''autostart''': Specifies whether the plugin starts playing on load. Default: ''true''  
 
*'''autoplay''', '''autostart''': Specifies whether the plugin starts playing on load. Default: ''true''  
 
*'''allowfullscreen''' (or '''fullscreenEnabled''', '''fullscreen'''): (since VLC version 2.0.0) Specifies whether the user can switch into fullscreen mode. Default: ''true''
 
*'''allowfullscreen''' (or '''fullscreenEnabled''', '''fullscreen'''): (since VLC version 2.0.0) Specifies whether the user can switch into fullscreen mode. Default: ''true''
*'''windowless''': (since VLC version 2.0.6) Draw the video on a window-less (non-accelerated) surface and allow styling (CSS overlay, 3D transformations, and much more). Default: ''false''
+
*'''windowless''': (since VLC version 2.0.6, only for Mozilla) Draw the video on a window-less (non-accelerated) surface and allow styling (CSS overlay, 3D transformations, and much more). Default: ''false''
 
*'''mute''': Specifies whether the audio volume is initially muted. Default: ''false''  
 
*'''mute''': Specifies whether the audio volume is initially muted. Default: ''false''  
 +
*'''volume''': (since VLC version 2.2.2) Specifies the initial audio volume as a percentage. Default: ''100''
 
*'''loop''', '''autoloop''': Specifies whether the video loops on end. Default: ''false''  
 
*'''loop''', '''autoloop''': Specifies whether the video loops on end. Default: ''false''  
 
*'''controls''' (or '''toolbar'''): Specifies whether the controls are shown by default. Default: ''true''  
 
*'''controls''' (or '''toolbar'''): Specifies whether the controls are shown by default. Default: ''true''  
 
*'''bgcolor''': Specifies the background color of the video player. Default: ''#000000''
 
*'''bgcolor''': Specifies the background color of the video player. Default: ''#000000''
*'''text''': Specifies a text displayed as long as no video is shown. Default: empty
+
*'''text''': (only for Mozilla on MacOS) Specifies a text displayed as long as no video is shown. Default: empty
*'''branding''': Specifies whether VLC branding should be displayed in the web plugin's drawing context. Default: ''true''
+
*'''branding''': (in vlc version < 2.2.2 only for Mozilla on MacOS) Specifies whether VLC branding should be displayed in the web plugin's drawing context. Default: ''true''
  
 
=== Normal DOM elements ===
 
=== Normal DOM elements ===
Line 87: Line 97:
 
*'''name''': DOM name
 
*'''name''': DOM name
  
= Javascript API description  =
+
== Javascript API description  ==
  
The vlc plugin exports several 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 exports several 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 you set vlc.audio.track out of range.
  
== VLC objects ==
+
=== VLC objects ===
 
The vlc plugin knows the following objects:  
 
The vlc plugin knows the following objects:  
  
 
*'''audio''': Access audio properties.  
 
*'''audio''': Access audio properties.  
*'''input''': Access input properties.  
+
*'''input''': Access input properties.
 +
**'''input.title''': Access title properties (available in vlc version ≥ 2.2.2, supported only ≥ 3.0.0)
 +
**'''input.chapter''': Access chapter properties (available in vlc version ≥ 2.2.2, supported only ≥ 3.0.0)
 
*'''playlist''': Access playlist properties.  
 
*'''playlist''': Access playlist properties.  
 +
**'''playlist.items''': Access playlist items properties.
 
*'''subtitle''': Access subtitle properties.  
 
*'''subtitle''': Access subtitle properties.  
 
*'''video''': Access video properties.  
 
*'''video''': Access video properties.  
 +
**'''video.deinterlace''': Access deinterlace properties.
 
**'''video.marquee''': Access marquee video filter properties.  
 
**'''video.marquee''': Access marquee video filter properties.  
 
**'''video.logo''': Access logo video filter properties.  
 
**'''video.logo''': Access logo video filter properties.  
*'''mediaDescription''': Access media info properties (only available in vlc version >= 2.0.2).
+
*'''mediaDescription''': Access media info properties (available in vlc version 2.0.2).
  
 
The following are deprecated:
 
The following are deprecated:
*'''log''': Access log properties (only available in vlc version &lt;= 1.0.0-rc1).  
+
*'''log''': Access log properties (only available in vlc version 1.0.0-rc1).  
*'''messages''': Access to log message properties (only available in vlc version &lt;= 1.0.0-rc1).  
+
*'''messages''': Access to log message properties (only available in vlc version 1.0.0-rc1).  
*'''iterator''': Access to log iterator properties (only available in vlc version &lt;= 1.0.0-rc1).
+
*'''iterator''': Access to log iterator properties (only available in vlc version 1.0.0-rc1).
*'''message''': Access to log message properties (only available in vlc version &lt;= 1.0.0-rc1).  
+
*'''message''': Access to log message properties (only available in vlc version 1.0.0-rc1).  
  
=== Example ===
+
==== Example ====
 
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.  
 
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.  
  
Line 117: Line 131:
 
<title>VLC Mozilla plugin test page</title>
 
<title>VLC Mozilla plugin test page</title>
 
<body>
 
<body>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
+
<embed type="application/x-vlc-plugin"
 
       width="640"
 
       width="640"
 
       height="480"
 
       height="480"
 
       id="vlc" />
 
       id="vlc" />
 
<script type="text/javascript">
 
<script type="text/javascript">
</syntaxhighlight><syntaxhighlight lang="javascript" line>
+
</syntaxhighlight><syntaxhighlight lang="javascript" start="10" line>
 
<!--
 
<!--
 
var vlc = document.getElementById("vlc");
 
var vlc = document.getElementById("vlc");
 
vlc.audio.toggleMute();
 
vlc.audio.toggleMute();
 
//-->
 
//-->
</syntaxhighlight><syntaxhighlight lang="html5" line>
+
</syntaxhighlight><syntaxhighlight lang="html5" start="14" line>
 
</script>
 
</script>
 
</body>
 
</body>
Line 133: Line 147:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Root object  ==
+
=== Root object  ===
  
 
readonly properties  
 
readonly properties  
Line 146: Line 160:
  
 
*'''vlc.versionInfo()''': (only for Mozilla) returns version information string (same as VersionInfo)
 
*'''vlc.versionInfo()''': (only for Mozilla) returns version information string (same as VersionInfo)
*'''vlc.getVersionInfo()''': (supported in vlc version >= 2.2.2) returns version information string (same as VersionInfo and versionInfo())
+
*'''vlc.getVersionInfo()''': (supported in vlc version 2.2.2) returns version information string (same as VersionInfo and versionInfo())
  
 
*'''vlc.addEventListener(eventname, callback, bubble)''': (only for Mozilla) add a listener for mentioned event name, callback expects a function and bubble influences the order of eventhandling by JS (usually it is set to false).  
 
*'''vlc.addEventListener(eventname, callback, bubble)''': (only for Mozilla) add a listener for mentioned event name, callback expects a function and bubble influences the order of eventhandling by JS (usually it is set to false).  
Line 157: Line 171:
  
 
*'''MediaPlayerNothingSpecial''': vlc is in idle state doing nothing but waiting for a command to be issued  
 
*'''MediaPlayerNothingSpecial''': vlc is in idle state doing nothing but waiting for a command to be issued  
*'''MediaPlayerOpening''': vlc is opening an media resource locator (MRL)  
+
*'''MediaPlayerOpening''': vlc is opening an media resource locator ([[MRL]])  
*'''MediaPlayerBuffering''': vlc is buffering  
+
*'''MediaPlayerBuffering(int cache)''': vlc is buffering  
 
*'''MediaPlayerPlaying''': vlc is playing a media  
 
*'''MediaPlayerPlaying''': vlc is playing a media  
 
*'''MediaPlayerPaused''': vlc is in paused state  
 
*'''MediaPlayerPaused''': vlc is in paused state  
 
*'''MediaPlayerStopped''': vlc is in stopped state  
 
*'''MediaPlayerStopped''': vlc is in stopped state  
*'''MediaPlayerForward''': vlc is fastforwarding through the media (works only when an input supports forward playback)  
+
*'''MediaPlayerStopAsyncDone''': (supported in vlc version ≥ 3.0.0) playback has stopped asynchronously
*'''MediaPlayerBackward''': vlc is going backwards through the media (works only when an input supports backwards playback)  
+
*'''MediaPlayerForward''': vlc is fastforwarding through the media (this never gets invoked)  
 +
*'''MediaPlayerBackward''': vlc is going backwards through the media (this never gets invoked)  
 
*'''MediaPlayerEncounteredError''': vlc has encountered an error and is unable to continue  
 
*'''MediaPlayerEncounteredError''': vlc has encountered an error and is unable to continue  
 
*'''MediaPlayerEndReached''': vlc has reached the end of current playlist  
 
*'''MediaPlayerEndReached''': vlc has reached the end of current playlist  
*'''MediaPlayerTimeChanged''': time has changed  
+
*'''MediaPlayerTimeChanged(int time)''': time has changed  
*'''MediaPlayerPositionChanged''': media position has changed  
+
*'''MediaPlayerPositionChanged(float position)''': media position has changed  
*'''MediaPlayerSeekableChanged''': media seekable flag has changed (true means media is seekable, false means it is not)  
+
*'''MediaPlayerSeekableChanged(bool seekable)''': media seekable flag has changed (true means media is seekable, false means it is not)  
*'''MediaPlayerPausableChanged''': media pausable flag has changed (true means media is pauseable, false means it is not)
+
*'''MediaPlayerPausableChanged(bool pausable)''': media pausable flag has changed (true means media is pauseable, false means it is not)
*'''MediaPlayerMediaChanged''': (supported in vlc version >= 2.2.0) media has changed
+
*'''MediaPlayerMediaChanged''': (supported in vlc version 2.2.0) media has changed
*'''MediaPlayerTitleChanged''': (in vlc version < 2.2.0 only for Mozilla) title has changed
+
*'''MediaPlayerTitleChanged(int title)''': (in vlc version < 2.2.0 only for Mozilla) title has changed (DVD/Blu-ray)
*'''MediaPlayerLengthChanged''': (in vlc version < 2.2.0 only for Mozilla) length has changed
+
*'''MediaPlayerChapterChanged(int chapter)''': (supported in vlc version ≥ 3.0.0) chapter has changed (DVD/Blu-ray)
 
+
*'''MediaPlayerLengthChanged(int length)''': (in vlc version < 2.2.0 only for Mozilla) length has changed
=== Example ===
+
*'''MediaPlayerVout(int count)''': (supported in vlc version ≥ 2.2.7) the number of video output has changed
The following code snippet provides easy functions to register and unregister event callbacks on all supported platforms (currently only Linux mozilla based browsers and windows activeX objects for Internet Explorer).  
+
*'''MediaPlayerMuted''': (supported in vlc version ≥ 2.2.7) audio volume was muted
 +
*'''MediaPlayerUnmuted''': (supported in vlc version ≥ 2.2.7) audio volume was unmuted
 +
*'''MediaPlayerAudioVolume(float volume)''': (supported in vlc version ≥ 2.2.7) audio volume has changed
  
 +
==== Example ====
 +
The following code snippet provides easy functions to register and unregister event callbacks on all supported platforms.
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
 
<script type="text/javascript">
 
<script type="text/javascript">
</syntaxhighlight><syntaxhighlight lang="javascript" line>
+
</syntaxhighlight><syntaxhighlight lang="javascript" start="2" line>
 
<!--
 
<!--
 
function registerVLCEvent(event, handler) {
 
function registerVLCEvent(event, handler) {
Line 190: Line 209:
 
             // Mozilla: DOM level 2
 
             // Mozilla: DOM level 2
 
             vlc.addEventListener (event, handler, false);
 
             vlc.addEventListener (event, handler, false);
        } else {
 
            // DOM level 0
 
            vlc["on" + event] = handler;
 
 
         }
 
         }
 
     }
 
     }
Line 206: Line 222:
 
             // Mozilla: DOM level 2
 
             // Mozilla: DOM level 2
 
             vlc.removeEventListener (event, handler, false);
 
             vlc.removeEventListener (event, handler, false);
        } else {
 
            // DOM level 0
 
            vlc["on" + event] = null;
 
 
         }
 
         }
 
     }
 
     }
Line 214: Line 227:
 
// event callbacks
 
// event callbacks
 
function handle_MediaPlayerNothingSpecial(){
 
function handle_MediaPlayerNothingSpecial(){
     alert("Idle");
+
     console.log("Idle");
 
}
 
}
 
function handle_MediaPlayerOpening(){
 
function handle_MediaPlayerOpening(){
     alert("Opening");
+
     console.log("Opening");
 
}
 
}
 
function handle_MediaPlayerBuffering(val){
 
function handle_MediaPlayerBuffering(val){
     alert("Buffering: " + val + "%");
+
     console.log("Buffering: " + val + "%");
 
}
 
}
 
function handle_MediaPlayerPlaying(){
 
function handle_MediaPlayerPlaying(){
     alert("Playing");
+
     console.log("Playing");
 
}
 
}
 
function handle_MediaPlayerPaused(){
 
function handle_MediaPlayerPaused(){
     alert("Paused");
+
     console.log("Paused");
 
}
 
}
 
function handle_MediaPlayerStopped(){
 
function handle_MediaPlayerStopped(){
     alert("Stopped");
+
     console.log("Stopped");
 +
}
 +
function handle_MediaPlayerStopAsyncDone(){
 +
    console.log("Stopped asynchronously");
 
}
 
}
 
function handle_MediaPlayerForward(){
 
function handle_MediaPlayerForward(){
     alert("Forward");
+
     console.log("Forward");
 
}
 
}
 
function handle_MediaPlayerBackward(){
 
function handle_MediaPlayerBackward(){
     alert("Backward");
+
     console.log("Backward");
 
}
 
}
 
function handle_MediaPlayerEndReached(){
 
function handle_MediaPlayerEndReached(){
     alert("EndReached");
+
     console.log("EndReached");
 
}
 
}
 
function handle_MediaPlayerEncounteredError(){
 
function handle_MediaPlayerEncounteredError(){
     alert("EncounteredError");
+
     console.log("EncounteredError");
 
}
 
}
 
function handle_MediaPlayerTimeChanged(time){
 
function handle_MediaPlayerTimeChanged(time){
     alert("Time changed: " + time + " ms");
+
     console.log("Time changed: " + time + " ms");
 
}
 
}
 
function handle_MediaPlayerPositionChanged(val){
 
function handle_MediaPlayerPositionChanged(val){
     alert("Position changed: " + val);
+
     console.log("Position changed: " + val);
 
}
 
}
 
function handle_MediaPlayerSeekableChanged(val){
 
function handle_MediaPlayerSeekableChanged(val){
     alert("Seekable changed: " + val);
+
     console.log("Seekable changed: " + val);
 
}
 
}
 
function handle_MediaPlayerPausableChanged(val){
 
function handle_MediaPlayerPausableChanged(val){
     alert("Pausable changed: " + val);
+
     console.log("Pausable changed: " + val);
 
}
 
}
 
function handle_MediaPlayerMediaChanged(){
 
function handle_MediaPlayerMediaChanged(){
     alert("Media changed");
+
     console.log("Media changed");
 
}
 
}
 
function handle_MediaPlayerTitleChanged(val){
 
function handle_MediaPlayerTitleChanged(val){
     alert("Title changed: " + val);
+
     console.log("Title changed: " + val);
 +
}
 +
function handle_MediaPlayerChapterChanged(val){
 +
    console.log("Chapter changed: " + val);
 
}
 
}
 
function handle_MediaPlayerLengthChanged(val){
 
function handle_MediaPlayerLengthChanged(val){
     alert("Length changed: " + val + " ms");
+
     console.log("Length changed: " + val + " ms");
 +
}
 +
function handle_MediaPlayerVout(val){
 +
    console.log("Number of video output changed: " + val);
 +
}
 +
function handle_MediaPlayerMuted(){
 +
    console.log("Audio volume muted");
 +
}
 +
function handle_MediaPlayerUnmuted(){
 +
    console.log("Audio volume unmuted");
 +
}
 +
function handle_MediaPlayerAudioVolume(volume){
 +
    console.log("Audio volume changed: " + Math.round(volume * 100) + "%");
 
}
 
}
 
// Register a bunch of callbacks.
 
// Register a bunch of callbacks.
Line 271: Line 302:
 
registerVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
 
registerVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
 
registerVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
 
registerVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
 +
registerVLCEvent("MediaPlayerStopAsyncDone", handle_MediaPlayerStopAsyncDone);
 
registerVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
 
registerVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
 
registerVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
 
registerVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
Line 281: Line 313:
 
registerVLCEvent("MediaPlayerMediaChanged", handle_MediaPlayerMediaChanged);
 
registerVLCEvent("MediaPlayerMediaChanged", handle_MediaPlayerMediaChanged);
 
registerVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
 
registerVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
 +
registerVLCEvent("MediaPlayerChapterChanged", handle_MediaPlayerChapterChanged);
 
registerVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
 
registerVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
 +
registerVLCEvent("MediaPlayerVout", handle_MediaPlayerVout);
 +
registerVLCEvent("MediaPlayerMuted", handle_MediaPlayerMuted);
 +
registerVLCEvent("MediaPlayerUnmuted", handle_MediaPlayerUnmuted);
 +
registerVLCEvent("MediaPlayerAudioVolume", handle_MediaPlayerAudioVolume);
 
//-->
 
//-->
</syntaxhighlight><syntaxhighlight lang="html5" line>
+
</syntaxhighlight><syntaxhighlight lang="html5" start="119" line>
 +
</script>
 +
</syntaxhighlight>
 +
 
 +
==== Event registration issue with IE11 ====
 +
Since IE11, the methods attachEvent() and detachEvent() are not longer available. So the registration of events is not possible. But there are two workarounds:
 +
 
 +
Workaround 1 - Use the IE10 compatibility mode to re-enable the missing methods. For using the compatibility mode, add this meta tag to the header of your page:
 +
<syntaxhighlight lang="html5" line>
 +
<meta http-equiv="X-UA-Compatible" content="IE=10"/>
 +
</syntaxhighlight>
 +
 
 +
Workaround 2 - Use an old IE-only implementation of event registration. An example with the MediaPlayerBuffering event:
 +
<syntaxhighlight lang="javascript" line>
 +
<script for="vlc" event="MediaPlayerBuffering(val)">
 +
console.log("Buffering: " + val + "%");
 
</script>
 
</script>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Audio object  ==
+
=== Audio object  ===
  
 
readonly properties  
 
readonly properties  
  
*'''vlc.audio.count''': (supported in vlc version &gt;= 1.1.0) returns the number of audio track available.
+
*'''vlc.audio.count''': (supported in vlc version 1.1.0) returns the number of audio track available.
  
 
read/write properties  
 
read/write properties  
Line 297: Line 349:
 
*'''vlc.audio.mute''': boolean value to mute and unmute the audio.  
 
*'''vlc.audio.mute''': boolean value to mute and unmute the audio.  
 
*'''vlc.audio.volume''': a value between [0-200] which indicates a percentage of the volume.  
 
*'''vlc.audio.volume''': a value between [0-200] which indicates a percentage of the volume.  
*'''vlc.audio.track''': (supported in vlc version &gt; 0.8.6) a value between [1-65535] which indicates the audio track to play or that is playing. a value of 0 means the audio is/will be disabled.  
+
*'''vlc.audio.track''': (supported in vlc version > 0.8.6) a value between [1-65535] which indicates the audio track to play or that is playing. a value of 0 means the audio is/will be disabled.  
*'''vlc.audio.channel''': (supported in vlc version &gt; 0.8.6) integer value between [1-5] that indicates which audio channel mode is used, values can be: "1=stereo", "2=reverse stereo", "3=left", "4=right", "5=dolby". Use vlc.audio.channel to check if setting of the audio channel mode has succeeded.
+
*'''vlc.audio.channel''': (supported in vlc version > 0.8.6) integer value between [1-5] that indicates which audio channel mode is used, values can be: "1=stereo", "2=reverse stereo", "3=left", "4=right", "5=dolby". Use vlc.audio.channel to check if setting of the audio channel mode has succeeded.
  
 
methods  
 
methods  
  
 
*'''vlc.audio.toggleMute()''': boolean toggle that mutes and unmutes the audio based upon the previous state.  
 
*'''vlc.audio.toggleMute()''': boolean toggle that mutes and unmutes the audio based upon the previous state.  
*'''vlc.audio.description(int i)''': (supported in vlc version &gt;= 1.1.0) give the i-th audio track name. 0 corresponds to disable and 1 to the first audio track.
+
*'''vlc.audio.description(int i)''': (supported in vlc version 1.1.0) give the i-th audio track name. 0 corresponds to disable and 1 to the first audio track.
  
=== Example ===
+
==== Example ====
  
 
<syntaxhighlight lang="html5" line>
 
<syntaxhighlight lang="html5" line>
 
Audio Channel:
 
Audio Channel:
<select readonly onChange='doAudioChannel(this.value)'>
+
<select onChange='doAudioChannel(this.value)'>
<option value=1>Stereo</option>
+
    <option value=1>Stereo</option>
<option value=2>Reverse stereo</option>
+
    <option value=2>Reverse stereo</option>
<option value=3>Left</option>
+
    <option value=3>Left</option>
<option value=4>Right</option>
+
    <option value=4>Right</option>
<option value=5>Dolby</option>
+
    <option value=5>Dolby</option>
 
</select>
 
</select>
</syntaxhighlight>
 
<br />
 
<syntaxhighlight lang="javascript" line>
 
 
<script type="text/javascript">
 
<script type="text/javascript">
 +
</syntaxhighlight><syntaxhighlight lang="javascript" line start="10">
 
<!--
 
<!--
 
function doAudioChannel(value)
 
function doAudioChannel(value)
 
{
 
{
var vlc = getVLC("vlc");
+
    var vlc = getVLC("vlc");
vlc.audio.channel = parseInt(value);
+
    vlc.audio.channel = parseInt(value);
alert(vlc.audio.channel);
+
    alert(vlc.audio.channel);
};
+
}
 
//-->
 
//-->
 +
</syntaxhighlight><syntaxhighlight lang="html5" line start="18">
 
</script>
 
</script>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Input object  ==
+
=== Input object  ===
  
 
readonly properties  
 
readonly properties  
Line 344: Line 395:
 
*'''vlc.input.time''': the absolute position in time given in milliseconds, this property can be used to seek through the stream
 
*'''vlc.input.time''': the absolute position in time given in milliseconds, this property can be used to seek through the stream
  
  &lt;!-- absolute seek in stream&nbsp;--&gt;
+
<syntaxhighlight lang="javascript">
  vlc.input.time = &lt;absolute seek&gt;
+
  <!-- absolute seek in stream -->
  &lt;!-- relative seek in stream&nbsp;--&gt;
+
  vlc.input.time = <absolute seek>
  vlc.input.time = vlc.input.time + &lt;relative seek&gt;
+
  <!-- relative seek in stream -->
 +
  vlc.input.time = vlc.input.time + <relative seek>
 +
</syntaxhighlight>
  
 
*'''vlc.input.state''': current state of the input chain given as enumeration:
 
*'''vlc.input.state''': current state of the input chain given as enumeration:
Line 372: Line 425:
 
*'''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.).
 
*'''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.).
  
rate &gt; 1             &nbsp;: is fastforward
+
{| class="wikitable"
rate &gt; 0 and rate &lt; 1&nbsp;: is slow motion
+
|-
rate &lt; 0            &nbsp;: is rewind
+
| rate > 1 || fast forward
 +
|-
 +
| rate = 1 || normal speed
 +
|-
 +
| rate < 1 || slow motion
 +
|}
  
 
methods  
 
methods  
Line 380: Line 438:
 
*''none''
 
*''none''
  
== Playlist object ==
+
==== Title object  ====
 +
 
 +
readonly properties
 +
 
 +
*'''vlc.input.title.count''': (supported in vlc version ≥ 2.2.2) returns the number of title available.
 +
 
 +
read/write properties
 +
 
 +
*'''vlc.input.title.track''': (supported in vlc version ≥ 2.2.2) get and set the title track. The property takes an integer as input value [0..65535]. It returns -1 if no titles are available.
 +
 
 +
methods
 +
 
 +
*'''vlc.input.title.description(int i)''': (supported in vlc version ≥ 2.2.2) give the i-th title name.
 +
 
 +
==== Chapter object  ====
 +
 
 +
readonly properties
 +
 
 +
*'''vlc.input.chapter.count''': (supported in vlc version ≥ 2.2.2) returns the number of chapter available in the current title.
 +
 
 +
read/write properties
 +
 
 +
*'''vlc.input.chapter.track''': (supported in vlc version ≥ 2.2.2) get and set the chapter track. The property takes an integer as input value [0..65535]. It returns -1 if no chapters are available.
 +
 
 +
methods
 +
 
 +
*'''vlc.input.chapter.description(int i)''': (supported in vlc version ≥ 2.2.2) give the i-th chapter name.
 +
*'''vlc.input.chapter.countForTitle(int i)''': (supported in vlc version ≥ 2.2.2) returns the number of chapter available for a specific title.
 +
*'''vlc.input.chapter.prev()''': (supported in vlc version ≥ 2.2.2) play the previous chapter.
 +
*'''vlc.input.chapter.next()''': (supported in vlc version ≥ 2.2.2) play the next chapter.
 +
 
 +
=== Playlist object ===
  
 
readonly properties  
 
readonly properties  
Line 386: Line 475:
 
*'''vlc.playlist.itemCount''': number that returns the amount of items currently in the playlist ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])  
 
*'''vlc.playlist.itemCount''': number that returns the amount of items currently in the playlist ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])  
 
*'''vlc.playlist.isPlaying''': a boolean that returns true if the current playlist item is playing and false when it is not playing  
 
*'''vlc.playlist.isPlaying''': a boolean that returns true if the current playlist item is playing and false when it is not playing  
*'''vlc.playlist.currentItem''': (supported in vlc version >= 2.2.0) number that returns the index of the current item in the playlist. It returns -1 if the playlist is empty or no item is active.
+
*'''vlc.playlist.currentItem''': (supported in vlc version 2.2.0) number that returns the index of the current item in the playlist. It returns -1 if the playlist is empty or no item is active.
 
*'''vlc.playlist.items''': return the playlist items collection, see [[#Playlist_items_object|Playlist items]]
 
*'''vlc.playlist.items''': return the playlist items collection, see [[#Playlist_items_object|Playlist items]]
  
Line 395: Line 484:
 
methods  
 
methods  
  
*'''vlc.playlist.add(mrl)''': add a playlist item as [[MRL]]. The MRL must be given as a string. Returns a number as an item identifier in playlist (this is not a position in playlist).  
+
*'''vlc.playlist.add(mrl)''': add a playlist item as [[MRL]]. The MRL must be given as a string. Returns the index of the just added item in the playlist as a number.
*'''vlc.playlist.add(mrl,name,options)''': add a playlist item as MRL, with metaname 'name' and options 'options'. options are text arguments which can be provided either as a single string containing space separated values, akin to VLC command line, or as an array of string values. Returns a number as an item identifier in playlist (this is not a position in playlist).
+
*'''vlc.playlist.add(mrl,name,options)''': add a playlist item as MRL, with metaname 'name' and options 'options'. options are text arguments which can be provided either as a single string containing space separated values, akin to VLC command line, or as an array of string values. Returns the index of the just added item in the playlist as a number.
  
 
<syntaxhighlight lang="javascript" line>
 
<syntaxhighlight lang="javascript" line>
 
var options = new Array(":aspect-ratio=4:3", "--rtsp-tcp");
 
var options = new Array(":aspect-ratio=4:3", "--rtsp-tcp");
 +
// Or: var options = ":aspect-ratio=4:3 --rtsp-tcp";
 
var id = vlc.playlist.add("rtsp://servername/item/to/play", "fancy name", options);
 
var id = vlc.playlist.add("rtsp://servername/item/to/play", "fancy name", options);
 
vlc.playlist.playItem(id);
 
vlc.playlist.playItem(id);
Line 409: Line 499:
 
*'''vlc.playlist.togglePause()''': toggle the pause state for 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.stop()''': stop playing the current playlist item  
 +
*'''vlc.playlist.stop_async()''': (supported in vlc version ≥ 3.0.0) stop playing the current playlist item asynchronously and fire the event MediaPlayerStopAsyncDone, if done
 
*'''vlc.playlist.next()''': iterate to the next playlist item  
 
*'''vlc.playlist.next()''': iterate to the next playlist item  
 
*'''vlc.playlist.prev()''': iterate to the previous 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 ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])  
 
*'''vlc.playlist.clear()''': empty the current playlist, all items will be deleted from the playlist ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])  
 
*'''vlc.playlist.removeItem(number)''': remove the item from playlist whose identifier is number <!-- (note: this number isn't the position in the playlist, but the number given by vlc.playlist.add() ) --> ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])
 
*'''vlc.playlist.removeItem(number)''': remove the item from playlist whose identifier is number <!-- (note: this number isn't the position in the playlist, but the number given by vlc.playlist.add() ) --> ('''deprecated''', do not use, see [[#Playlist_items_object|Playlist items]])
 +
*'''vlc.playlist.parse(options, timeout)''': (supported in vlc version ≥ 3.0.0) Parse the first media in the playlist. This fetches (local or network) art, meta data and/or tracks information. A timeout for parsing can be set in milliseconds or to indefinitely (0). Returns the parsed status.
  
=== Playlist items object  ===
+
Available options flags for parsing (which can be combined):
 +
{| class="wikitable"
 +
|-
 +
| 0 || Parse media if it's a local file.
 +
|-
 +
| 1 || Parse media even if it's a network file.
 +
|-
 +
| 2 || Fetch meta and covert art using local resources.
 +
|-
 +
| 4 || Fetch meta and covert art using network resources.
 +
|-
 +
| 8 || Interact with the user. Set this flag in order to receive a callback when the input is asking for credentials.
 +
|}
 +
 
 +
Parsed status given as enumeration:
 +
{| class="wikitable"
 +
|-
 +
| 1 || skipped
 +
|-
 +
| 2 || failed
 +
|-
 +
| 3 || timeout
 +
|-
 +
| 4 || done
 +
|}
 +
 
 +
==== Playlist items object  ====
  
 
readonly properties  
 
readonly properties  
Line 426: Line 544:
 
methods  
 
methods  
  
*'''vlc.playlist.items.clear()''': empty the current playlist, all items will be deleted from the playlist. If a movie is playing, it stop. Note that when this method returns, playlist may not have been entirely been cleared as this operation is performed asynchronously; use the ''count'' property to verify/wait until the playlist is empty.
+
*'''vlc.playlist.items.clear()''': empty the current playlist, all items will be deleted from the playlist. (note: if a movie is playing, it will not stop)
*'''vlc.playlist.items.remove(number)''': remove the item whose identifier is number from playlist. (note: this number isn't the position in the playlist, but the number given by vlc.playlist.add() )
+
*'''vlc.playlist.items.remove(number)''': remove the item whose identifier is number from playlist. (note: this number is the current position in the playlist. It's not the number given by vlc.playlist.add(), if any items of the playlist were removed in the meantime.)
  
== Subtitle object  ==
+
=== Subtitle object  ===
  
 
readonly properties  
 
readonly properties  
  
*'''vlc.subtitle.count''': (supported in vlc version &gt;= 1.1.0) returns the number of subtitle available.
+
*'''vlc.subtitle.count''': (supported in vlc version 1.1.0) returns the number of subtitle available.
  
 
read/write properties  
 
read/write properties  
  
*'''vlc.subtitle.track''': (supported in vlc version &gt;= 1.1.0) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled. If set to a value outside the current subtitle tracks range, then it will return -1 and display an error message.
+
*'''vlc.subtitle.track''': (supported in vlc version 1.1.0) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled.
  
 
methods  
 
methods  
  
*'''vlc.subtitle.description(int i)''': (supported in vlc version &gt;= 1.1.0) give the i-th subtitle name. 0 correspond to disable and 1 to the first subtitle.
+
*'''vlc.subtitle.description(int i)''': (supported in vlc version 1.1.0) give the i-th subtitle name. 0 correspond to disable and 1 to the first subtitle.
  
== Video object  ==
+
=== Video object  ===
  
 
readonly properties  
 
readonly properties  
Line 449: Line 567:
 
*'''vlc.video.width''': returns the horizontal size of the video  
 
*'''vlc.video.width''': returns the horizontal size of the video  
 
*'''vlc.video.height''': returns the vertical size of the video
 
*'''vlc.video.height''': returns the vertical size of the video
 +
*'''vlc.video.count''': (supported in vlc version ≥ 2.2.7) returns the number of video track available.
  
 
read/write properties  
 
read/write properties  
Line 454: Line 573:
 
*'''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.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. Typical values are: "1:1", "4:3", "16:9", "16:10", "221:100" and "5:4"  
 
*'''vlc.video.aspectRatio''': get and set the aspect ratio to use in the video screen. The property takes a string as input value. Typical values are: "1:1", "4:3", "16:9", "16:10", "221:100" and "5:4"  
*'''vlc.video.subtitle''': (supported in vlc version &gt; 0.8.6a) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled. If set to a value outside the current subtitle tracks range, then it will return -1 and display an error message.
+
*'''vlc.video.scale''': (supported in vlc version ≥ 3.0.0) get and set the video scaling factor as float. That is the ratio of the number of pixels on screen to the number of pixels in the original decoded video in each dimension. Zero is a special value; it will adjust the video to the output window.
*'''vlc.video.teletext''': (supported in vlc version &gt;= 0.9.0) get and set teletext page to show on the video stream. This will only work if a teletext elementary stream is available in the video stream. The property takes an integer as input value [0..999] for indicating the teletext page to view, setting the value to 0 means hide teletext. On error it will return -1 and display an error message.
+
*'''vlc.video.subtitle''': (supported in vlc version > 0.8.6a) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled.
 +
*'''vlc.video.crop''': (removed with vlc version 4.0.0) get and set the geometry of the zone to crop. This is set as <width> x <height> + <left offset> + <top offset>. A possible value is: "120x120+10+10"
 +
*'''vlc.video.teletext''': (supported in vlc version 0.9.0) get and set teletext page to show on the video stream. This will only work if a teletext elementary stream is available in the video stream. The property takes an integer as input value [0..1000] for indicating the teletext page to view, setting the value to 0 means hide teletext.
 +
*'''vlc.video.track''': (supported in vlc version ≥ 2.2.7) a value between [1-65535] which indicates the video track to play or that is playing. a value of 0 means the video is/will be disabled.  
  
 
methods  
 
methods  
  
 +
*'''vlc.video.takeSnapshot()''': (supported in vlc version ≥ 0.9.0, only for ActiveX) generates a snapshot and saves it on the desktop
 
*'''vlc.video.toggleFullscreen()''': toggle the fullscreen mode based on the previous setting  
 
*'''vlc.video.toggleFullscreen()''': toggle the fullscreen mode based on the previous setting  
*'''vlc.video.toggleTeletext()''': (supported in vlc version &gt;= 0.9.0) toggle the teletext page to overlay transparent or not, based on the previous setting
+
*'''vlc.video.toggleTeletext()''': (supported in vlc version 0.9.0) toggle the teletext page to overlay transparent or not, based on the previous setting
 +
*'''vlc.video.description(int i)''': (supported in vlc version ≥ 2.2.7) give the i-th video track name. 0 corresponds to disable and 1 to the first video track.
 +
*'''vlc.video.crop_ratio(int numerator, int denominator)''': (supported in vlc version ≥ 4.0.0) Forces a crop ratio on any and all video tracks rendered by the media player. To disable video crop, set a crop ratio with zero as denominator.
 +
*'''vlc.video.crop_window(int x, int y, int width, int height)''': (supported in vlc version ≥ 4.0.0) Selects a sub-rectangle of video to show. Any pixels outside the rectangle will not be shown. To unset the video crop window, use vlc.video.crop_ratio() or vlc.video.crop_border().
 +
*'''vlc.video.crop_border(int left, int right, int top, int bottom)''': (supported in vlc version ≥ 4.0.0) Selects the size of video edges to be cropped out. To unset the video crop borders, set all borders to zero.
  
=== Deinterlace Object  ===
+
==== Deinterlace Object  ====
  
 
readonly properties  
 
readonly properties  
Line 474: Line 601:
 
methods  
 
methods  
  
*'''vlc.video.deinterlace.enable("my_mode")''': (supported in vlc version &gt;= 1.1.0) enable deinterlacing with my_mode. You can enable it with "blend", "bob", "discard", "linear", "mean", "x", "yadif" or "yadif2x" mode. Enabling too soon deinterlacing may cause some problems. You have to wait that all variable are available before enabling it.  
+
*'''vlc.video.deinterlace.enable("my_mode")''': (supported in vlc version 1.1.0) enable deinterlacing with my_mode. You can enable it with "blend", "bob", "discard", "linear", "mean", "x", "yadif" or "yadif2x" mode. Enabling too soon deinterlacing may cause some problems. You have to wait that all variable are available before enabling it.  
*'''vlc.video.deinterlace.disable()''': (supported in vlc version &gt;= 1.1.0) disable deinterlacing.
+
*'''vlc.video.deinterlace.disable()''': (supported in vlc version 1.1.0) disable deinterlacing.
  
=== Marquee Object  ===
+
==== Marquee Object  ====
  
 
readonly properties  
 
readonly properties  
Line 485: Line 612:
 
read/write properties  
 
read/write properties  
  
*'''vlc.video.marquee.text''': (supported in vlc version &gt;= 1.1.0) display my text on the screen.  
+
*'''vlc.video.marquee.text''': (supported in vlc version 1.1.0, since vlc version 4.0.0 writeonly) display my text on the screen.
*'''vlc.video.marquee.color''': (supported in vlc version &gt;= 1.1.0) change the text color. val is the new color to use (WHITE=0x000000, BLACK=0xFFFFFF, RED=0xFF0000, GREEN=0x00FF00, BLUE=0x0000FF...).  
+
*'''vlc.video.marquee.color''': (supported in vlc version 1.1.0) change the text color. val is the new color to use (WHITE=0x000000, BLACK=0xFFFFFF, RED=0xFF0000, GREEN=0x00FF00, BLUE=0x0000FF...).  
*'''vlc.video.marquee.opacity''': (supported in vlc version &gt;= 1.1.0) change the text opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).  
+
*'''vlc.video.marquee.opacity''': (supported in vlc version 1.1.0) change the text opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).  
*'''vlc.video.marquee.position''': (supported in vlc version &gt;= 1.1.0) change the text position (CENTER=0, LEFT=1, RIGHT=2, TOP=4, TOP-LEFT=5, TOP-RIGHT=6, BOTTOM=8, BOTTOM-LEFT=9, BOTTOM_RIGHT=10).  
+
*'''vlc.video.marquee.position''': (supported in vlc version 1.1.0) change the text position ("center", "left", "right", "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right").  
*'''vlc.video.marquee.refresh''': (supported in vlc version &gt;= 1.1.0) change the marquee refresh period.  
+
*'''vlc.video.marquee.refresh''': (supported in vlc version 1.1.0) change the marquee refresh period.  
*'''vlc.video.marquee.size''': (supported in vlc version &gt;= 1.1.0) val define the new size for the text displayed on the screen. If the text is bigger than the screen then the text is not displayed.  
+
*'''vlc.video.marquee.size''': (supported in vlc version 1.1.0) val define the new size for the text displayed on the screen. If the text is bigger than the screen then the text is not displayed.  
*'''vlc.video.marquee.timeout''': (supported in vlc version &gt;= 1.1.0) change the timeout value. val is defined in ms, but 0 value correspond to unlimited.  
+
*'''vlc.video.marquee.timeout''': (supported in vlc version 1.1.0) change the timeout value. val is defined in ms, but 0 value correspond to unlimited.  
*'''vlc.video.marquee.x''': (supported in vlc version &gt;= 1.1.0) change text abscissa.  
+
*'''vlc.video.marquee.x''': (supported in vlc version 1.1.0) change text abscissa.  
*'''vlc.video.marquee.y''': (supported in vlc version &gt;= 1.1.0) change text ordinate.
+
*'''vlc.video.marquee.y''': (supported in vlc version 1.1.0) change text ordinate.
  
 
methods  
 
methods  
  
*'''vlc.video.marquee.enable()''': (supported in vlc version &gt;= 1.1.0) enable marquee filter.  
+
*'''vlc.video.marquee.enable()''': (supported in vlc version 1.1.0) enable marquee filter.  
*'''vlc.video.marquee.disable()''': (supported in vlc version &gt;= 1.1.0) disable marquee filter.
+
*'''vlc.video.marquee.disable()''': (supported in vlc version 1.1.0) disable marquee filter.
  
 
Some problems may happen (option like color or text will not be applied) because of the VLC asynchronous functioning. To avoid it, after enabling marquee, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.  
 
Some problems may happen (option like color or text will not be applied) because of the VLC asynchronous functioning. To avoid it, after enabling marquee, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.  
  
NOTE: [http://forum.videolan.org/viewtopic.php?f=16&t=89427#p295058]  
+
NOTE: see [https://forum.videolan.org/viewtopic.php?f=16&t=89427#p295058 this forum post]
  
=== Logo Object  ===
+
==== Logo Object  ====
  
 
readonly properties  
 
readonly properties  
Line 512: Line 639:
 
read/write properties  
 
read/write properties  
  
*'''vlc.video.logo.opacity''': (supported in vlc version &gt;= 1.1.0) change the picture opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).  
+
*'''vlc.video.logo.opacity''': (supported in vlc version 1.1.0) change the picture opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).  
*'''vlc.video.logo.position''': (supported in vlc version &gt;= 1.1.0) change the text position ("center", "left", "right", "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right").  
+
*'''vlc.video.logo.position''': (supported in vlc version 1.1.0) change the text position ("center", "left", "right", "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right").  
*'''vlc.video.logo.delay''': (supported in vlc version &gt;= 1.1.0) display each picture for a duration of 1000 ms (default) before displaying the next picture.  
+
*'''vlc.video.logo.delay''': (supported in vlc version 1.1.0) display each picture for a duration of 1000 ms (default) before displaying the next picture.  
*'''vlc.video.logo.repeat''': (supported in vlc version &gt;= 1.1.0) number of loops for picture animation (-1=continuous, 0=disabled, n=n-times). The default is -1 (continuous).  
+
*'''vlc.video.logo.repeat''': (supported in vlc version 1.1.0) number of loops for picture animation (-1=continuous, 0=disabled, n=n-times). The default is -1 (continuous).  
*'''vlc.video.logo.x''': (supported in vlc version &gt;= 1.1.0) change the x-offset for displaying the picture counting from top-left on the screen.  
+
*'''vlc.video.logo.x''': (supported in vlc version 1.1.0) change the x-offset for displaying the picture counting from top-left on the screen.  
*'''vlc.video.logo.y''': (supported in vlc version &gt;= 1.1.0) change the y-offset for displaying the picture counting from top-left on the screen.
+
*'''vlc.video.logo.y''': (supported in vlc version 1.1.0) change the y-offset for displaying the picture counting from top-left on the screen.  
*'''vlc.video.logo.width''': (supported in vlc version &gt;= 1.1.0) change the picture width.
 
*'''vlc.video.logo.height''': (supported in vlc version &gt;= 1.1.0) change the picture height.
 
  
 
methods  
 
methods  
  
*'''vlc.video.logo.enable()''': (supported in vlc version &gt;= 1.1.0) enable logo video filter.  
+
*'''vlc.video.logo.enable()''': (supported in vlc version 1.1.0) enable logo video filter.  
*'''vlc.video.logo.disable()''': (supported in vlc version &gt;= 1.1.0) disable logo video filter.  
+
*'''vlc.video.logo.disable()''': (supported in vlc version 1.1.0) disable logo video filter.  
*'''vlc.video.logo.file("file.png")''': (supported in vlc version &gt;= 1.1.0) display my file.png as logo on the screen.
+
*'''vlc.video.logo.file("file.png")''': (supported in vlc version 1.1.0) display my file.png as logo on the screen.
  
 
Some problems may happen because of the VLC asynchronous functioning. To avoid it, after enabling logo video filter, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.
 
Some problems may happen because of the VLC asynchronous functioning. To avoid it, after enabling logo video filter, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.
  
== MediaDescription Object  ==
+
=== MediaDescription Object  ===
  
 
readonly properties  
 
readonly properties  
  
*'''vlc.mediaDescription.title''': (supported in vlc version &gt;= 2.0.2) returns title meta information field.
+
*'''vlc.mediaDescription.title''': (supported in vlc version 2.0.2) returns title meta information field.
*'''vlc.mediaDescription.artist''': (supported in vlc version &gt;= 2.0.2) returns artist meta information field.
+
*'''vlc.mediaDescription.artist''': (supported in vlc version 2.0.2) returns artist meta information field.
*'''vlc.mediaDescription.copyright''': (supported in vlc version &gt;= 2.0.2) returns copyright meta information field.
+
*'''vlc.mediaDescription.genre''': (supported in vlc version ≥ 2.0.2) returns genre meta information field.
*'''vlc.mediaDescription.album''': (supported in vlc version &gt;= 2.0.2) returns album meta information field.
+
*'''vlc.mediaDescription.copyright''': (supported in vlc version 2.0.2) returns copyright meta information field.
*'''vlc.mediaDescription.trackNumber''': (supported in vlc version &gt;= 2.0.2) returns trackNumber meta information field.
+
*'''vlc.mediaDescription.album''': (supported in vlc version 2.0.2) returns album meta information field.
*'''vlc.mediaDescription.description''': (supported in vlc version &gt;= 2.0.2) returns description meta information field.
+
*'''vlc.mediaDescription.trackNumber''': (supported in vlc version 2.0.2) returns trackNumber meta information field.
*'''vlc.mediaDescription.rating''': (supported in vlc version &gt;= 2.0.2) returns rating meta information field.
+
*'''vlc.mediaDescription.description''': (supported in vlc version 2.0.2) returns description meta information field.
*'''vlc.mediaDescription.date''': (supported in vlc version &gt;= 2.0.2) returns date meta information field.
+
*'''vlc.mediaDescription.rating''': (supported in vlc version 2.0.2) returns rating meta information field.
*'''vlc.mediaDescription.setting''': (supported in vlc version &gt;= 2.0.2) returns setting meta information field.
+
*'''vlc.mediaDescription.date''': (supported in vlc version 2.0.2) returns date meta information field.
*'''vlc.mediaDescription.URL''': (supported in vlc version &gt;= 2.0.2) returns URL meta information field.
+
*'''vlc.mediaDescription.setting''': (supported in vlc version 2.0.2) returns setting meta information field.
*'''vlc.mediaDescription.language''': (supported in vlc version &gt;= 2.0.2) returns language meta information field.
+
*'''vlc.mediaDescription.URL''': (supported in vlc version 2.0.2) returns URL meta information field.
*'''vlc.mediaDescription.nowPlaying''': (supported in vlc version &gt;= 2.0.2) returns nowPlaying meta information field.
+
*'''vlc.mediaDescription.language''': (supported in vlc version 2.0.2) returns language meta information field.
*'''vlc.mediaDescription.publisher''': (supported in vlc version &gt;= 2.0.2) returns publisher meta information field.
+
*'''vlc.mediaDescription.nowPlaying''': (supported in vlc version 2.0.2) returns nowPlaying meta information field.
*'''vlc.mediaDescription.encodedBy''': (supported in vlc version &gt;= 2.0.2) returns encodedBy meta information field.
+
*'''vlc.mediaDescription.publisher''': (supported in vlc version 2.0.2) returns publisher meta information field.
 
+
*'''vlc.mediaDescription.encodedBy''': (supported in vlc version 2.0.2) returns encodedBy meta information field.
*'''vlc.mediaDescription.artworkURL''': (supported in vlc version &gt;= 2.0.2) returns artworkURL meta information field.
+
*'''vlc.mediaDescription.artworkURL''': (supported in vlc version 2.0.2) returns artworkURL meta information field.
 
+
*'''vlc.mediaDescription.trackID''': (supported in vlc version 2.0.2) returns trackID meta information field.
*'''vlc.mediaDescription.trackID''': (supported in vlc version &gt;= 2.0.2) returns trackID meta information field.
 
  
 
read/write properties  
 
read/write properties  
Line 560: Line 684:
 
*''none''
 
*''none''
  
== DEPRECATED APIs ==
+
=== DEPRECATED APIs ===
=== DEPRECATED: Log object  ===
+
==== DEPRECATED: Log object  ====
  
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
  
This object allows accessing VLC main message logging queue. Typically this queue capacity is very small (no nore than 256 entries) and can easily overflow, therefore messages should be read and cleared as often as possible.  
+
This object allows accessing VLC main message logging queue. Typically this queue capacity is very small (no more than 256 entries) and can easily overflow, therefore messages should be read and cleared as often as possible.  
  
 
readonly properties  
 
readonly properties  
  
*'''vlc.log.messages''': returns the message collection, see [[#Messages_object|Messages object]]
+
*'''vlc.log.messages''': returns the message collection, see [[#DEPRECATED:_Messages_object|Messages object]]
  
 
read/write properties  
 
read/write properties  
Line 579: Line 703:
 
*''none''
 
*''none''
  
=== DEPRECATED: Messages object  ===
+
==== DEPRECATED: Messages object  ====
  
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
Line 596: Line 720:
 
*'''messages.iterator()''': creates and returns an iterator object, used to iterate over the messages in the log. '''Don't clear the log buffer while holding an iterator object.'''
 
*'''messages.iterator()''': creates and returns an iterator object, used to iterate over the messages in the log. '''Don't clear the log buffer while holding an iterator object.'''
  
=== DEPRECATED: Messages Iterator object  ===
+
==== DEPRECATED: Messages Iterator object  ====
  
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
Line 610: Line 734:
 
methods  
 
methods  
  
*'''iterator.next()''': returns the next message object in the log, see [[Message object]]
+
*'''iterator.next()''': returns the next message object in the log, see [[#DEPRECATED:_Message_subobject|Message object]]
  
=== DEPRECATED: Message subobject  ===
+
==== DEPRECATED: Message subobject  ====
  
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
 
:'''CAUTION''': For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
Line 624: Line 748:
  
 
[[Category:Development‏‎]]
 
[[Category:Development‏‎]]
 +
[[Category:VLC plugins]]

Latest revision as of 19:57, 5 July 2020

This page is outdated and information might be incorrect.
Create an account to start editing, and then click here to update this article.

This Documentation speaks about the VLC media player Web plugins and how to write pages for it.

VLC User Guide

Quick Start Guide
Installing VLC
History
Usage
Interface
Open Media
Audio
Video
Playback
Playlist
Subtitles
Video and Audio Filters
Snapshots
Hotkeys
Uninstalling VLC
Troubleshooting
Advanced usage
Using VLC inside a webpage
Command line
Alternative Interfaces
Misc

Appendix
Building Pages for the HTTP Interface
Format String
Building Lua Playlist Scripts
View this alone

Introduction: Building Web pages with Video

The VLC media player webplugins are native browser plugins, similar to Flash or Silverlight plugins and allow playback inside the browser of all the videos that VLC media player can read.

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.

There are 2 main plugins: one is ActiveX for IE, the other is NPAPI for the other browsers. They feature the same amount of features.

In older versions, those plugins were very crashy. We URGE YOU to use VLC 2.0.0 or newer versions.

Browsers support

It has been tested with:

Mozilla Firefox (up to v51) Firefox-logo.png
Internet Explorer Internet Explorer.png
Safari (up to v11) Apple Safari.png
Chrome (up to v44)
Konqueror
Opera (up to v36)

It has been tested on GNU/Linux, Windows and MacOS.


Note:

In the most of browsers, the support for NPAPI plugins was dropped. Only in some forks of Firefox like Waterfox or Pale Moon, NPAPI plugins are still supported.

For this reason, the NPAPI plugin will be dropped in vlc version 4.

Embed tag attributes

To embed the plugin into a webpage, use the following <embed> template:

<embed type="application/x-vlc-plugin" width="640" height="480" />


If you are using vlc version < 2.2.0 with Internet Explorer, use instead the following <object> template:

<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" width="640" height="480"></object>

For the declaration of tag attributes, use the tag <param>. Here an example:

<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" width="640" height="480">
    <param name="autostart" value="true" />
    <param name="allowfullscreen" value="false" />
</object>

For compatibility with the mozilla plugin, you can combine both tags:

<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" id="vlc" width="640" height="480">
    <embed type="application/x-vlc-plugin" name="vlc" width="640" height="480" />
</object>

Required elements

These are required attributes for the <embed> tag:

  • width: Specifies the width of the plugin.
  • height: Specifies the height of the plugin.
  • target (or one of these alias: mrl, filename, src): Specifies the source location (URL) of the video to load.

Optional elements

These are additional attributes for the <embed> tag:

  • autoplay, autostart: Specifies whether the plugin starts playing on load. Default: true
  • allowfullscreen (or fullscreenEnabled, fullscreen): (since VLC version 2.0.0) Specifies whether the user can switch into fullscreen mode. Default: true
  • windowless: (since VLC version 2.0.6, only for Mozilla) Draw the video on a window-less (non-accelerated) surface and allow styling (CSS overlay, 3D transformations, and much more). Default: false
  • mute: Specifies whether the audio volume is initially muted. Default: false
  • volume: (since VLC version 2.2.2) Specifies the initial audio volume as a percentage. Default: 100
  • loop, autoloop: Specifies whether the video loops on end. Default: false
  • controls (or toolbar): Specifies whether the controls are shown by default. Default: true
  • bgcolor: Specifies the background color of the video player. Default: #000000
  • text: (only for Mozilla on MacOS) Specifies a text displayed as long as no video is shown. Default: empty
  • branding: (in vlc version < 2.2.2 only for Mozilla on MacOS) Specifies whether VLC branding should be displayed in the web plugin's drawing context. Default: true

Normal DOM elements

  • id: DOM id
  • name: DOM name

Javascript API description

The vlc plugin exports several 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 you set vlc.audio.track out of range.

VLC objects

The vlc plugin knows the following objects:

  • audio: Access audio properties.
  • input: Access input properties.
    • input.title: Access title properties (available in vlc version ≥ 2.2.2, supported only ≥ 3.0.0)
    • input.chapter: Access chapter properties (available in vlc version ≥ 2.2.2, supported only ≥ 3.0.0)
  • playlist: Access playlist properties.
    • playlist.items: Access playlist items properties.
  • subtitle: Access subtitle properties.
  • video: Access video properties.
    • video.deinterlace: Access deinterlace properties.
    • video.marquee: Access marquee video filter properties.
    • video.logo: Access logo video filter properties.
  • mediaDescription: Access media info properties (available in vlc version ≥ 2.0.2).

The following are deprecated:

  • log: Access log properties (only available in vlc version ≤ 1.0.0-rc1).
  • messages: Access to log message properties (only available in vlc version ≤ 1.0.0-rc1).
  • iterator: Access to log iterator properties (only available in vlc version ≤ 1.0.0-rc1).
  • message: Access to log message properties (only available in vlc version ≤ 1.0.0-rc1).

Example

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.

<!DOCTYPE html>
<html>
<title>VLC Mozilla plugin test page</title>
<body>
<embed type="application/x-vlc-plugin"
       width="640"
       height="480"
       id="vlc" />
<script type="text/javascript">
<!--
var vlc = document.getElementById("vlc");
vlc.audio.toggleMute();
//-->
</script>
</body>
</html>

Root object

readonly properties

  • vlc.VersionInfo: returns version information string

read/write properties

  • none

methods

  • vlc.versionInfo(): (only for Mozilla) returns version information string (same as VersionInfo)
  • vlc.getVersionInfo(): (supported in vlc version ≥ 2.2.2) returns version information string (same as VersionInfo and versionInfo())
  • vlc.addEventListener(eventname, callback, bubble): (only for Mozilla) add a listener for mentioned event name, callback expects a function and bubble influences the order of eventhandling by JS (usually it is set to false).
  • vlc.removeEventListener(eventname, callback, bubble): (only for Mozilla) remove listener for mentioned event name, callback expects a function and bubble influences the order of eventhandling by JS (usually it is set to false).
  • vlc.attachEvent(eventname, callback): (only for ActiveX) add listener for mentioned event name, callback expects a function
  • vlc.detachEvent(eventname, callback): (only for ActiveX) remove listener for mentioned event name, callback expects a function

events

  • MediaPlayerNothingSpecial: vlc is in idle state doing nothing but waiting for a command to be issued
  • MediaPlayerOpening: vlc is opening an media resource locator (MRL)
  • MediaPlayerBuffering(int cache): vlc is buffering
  • MediaPlayerPlaying: vlc is playing a media
  • MediaPlayerPaused: vlc is in paused state
  • MediaPlayerStopped: vlc is in stopped state
  • MediaPlayerStopAsyncDone: (supported in vlc version ≥ 3.0.0) playback has stopped asynchronously
  • MediaPlayerForward: vlc is fastforwarding through the media (this never gets invoked)
  • MediaPlayerBackward: vlc is going backwards through the media (this never gets invoked)
  • MediaPlayerEncounteredError: vlc has encountered an error and is unable to continue
  • MediaPlayerEndReached: vlc has reached the end of current playlist
  • MediaPlayerTimeChanged(int time): time has changed
  • MediaPlayerPositionChanged(float position): media position has changed
  • MediaPlayerSeekableChanged(bool seekable): media seekable flag has changed (true means media is seekable, false means it is not)
  • MediaPlayerPausableChanged(bool pausable): media pausable flag has changed (true means media is pauseable, false means it is not)
  • MediaPlayerMediaChanged: (supported in vlc version ≥ 2.2.0) media has changed
  • MediaPlayerTitleChanged(int title): (in vlc version < 2.2.0 only for Mozilla) title has changed (DVD/Blu-ray)
  • MediaPlayerChapterChanged(int chapter): (supported in vlc version ≥ 3.0.0) chapter has changed (DVD/Blu-ray)
  • MediaPlayerLengthChanged(int length): (in vlc version < 2.2.0 only for Mozilla) length has changed
  • MediaPlayerVout(int count): (supported in vlc version ≥ 2.2.7) the number of video output has changed
  • MediaPlayerMuted: (supported in vlc version ≥ 2.2.7) audio volume was muted
  • MediaPlayerUnmuted: (supported in vlc version ≥ 2.2.7) audio volume was unmuted
  • MediaPlayerAudioVolume(float volume): (supported in vlc version ≥ 2.2.7) audio volume has changed

Example

The following code snippet provides easy functions to register and unregister event callbacks on all supported platforms.

<script type="text/javascript">
<!--
function registerVLCEvent(event, handler) {
    var vlc = getVLC("vlc");
    if (vlc) {
        if (vlc.attachEvent) {
            // Microsoft
            vlc.attachEvent (event, handler);
        } else if (vlc.addEventListener) {
            // Mozilla: DOM level 2
            vlc.addEventListener (event, handler, false);
        }
    }
}
// stop listening to event
function unregisterVLCEvent(event, handler) {
    var vlc = getVLC("vlc");
    if (vlc) {
        if (vlc.detachEvent) {
            // Microsoft
            vlc.detachEvent (event, handler);
        } else if (vlc.removeEventListener) {
            // Mozilla: DOM level 2
            vlc.removeEventListener (event, handler, false);
        }
    }
}
// event callbacks
function handle_MediaPlayerNothingSpecial(){
    console.log("Idle");
}
function handle_MediaPlayerOpening(){
    console.log("Opening");
}
function handle_MediaPlayerBuffering(val){
    console.log("Buffering: " + val + "%");
}
function handle_MediaPlayerPlaying(){
    console.log("Playing");
}
function handle_MediaPlayerPaused(){
    console.log("Paused");
}
function handle_MediaPlayerStopped(){
    console.log("Stopped");
}
function handle_MediaPlayerStopAsyncDone(){
    console.log("Stopped asynchronously");
}
function handle_MediaPlayerForward(){
    console.log("Forward");
}
function handle_MediaPlayerBackward(){
    console.log("Backward");
}
function handle_MediaPlayerEndReached(){
    console.log("EndReached");
}
function handle_MediaPlayerEncounteredError(){
    console.log("EncounteredError");
}
function handle_MediaPlayerTimeChanged(time){
    console.log("Time changed: " + time + " ms");
}
function handle_MediaPlayerPositionChanged(val){
    console.log("Position changed: " + val);
}
function handle_MediaPlayerSeekableChanged(val){
    console.log("Seekable changed: " + val);
}
function handle_MediaPlayerPausableChanged(val){
    console.log("Pausable changed: " + val);
}
function handle_MediaPlayerMediaChanged(){
    console.log("Media changed");
}
function handle_MediaPlayerTitleChanged(val){
    console.log("Title changed: " + val);
}
function handle_MediaPlayerChapterChanged(val){
    console.log("Chapter changed: " + val);
}
function handle_MediaPlayerLengthChanged(val){
    console.log("Length changed: " + val + " ms");
}
function handle_MediaPlayerVout(val){
    console.log("Number of video output changed: " + val);
}
function handle_MediaPlayerMuted(){
    console.log("Audio volume muted");
}
function handle_MediaPlayerUnmuted(){
    console.log("Audio volume unmuted");
}
function handle_MediaPlayerAudioVolume(volume){
    console.log("Audio volume changed: " + Math.round(volume * 100) + "%");
}
// Register a bunch of callbacks.
registerVLCEvent("MediaPlayerNothingSpecial", handle_MediaPlayerNothingSpecial);
registerVLCEvent("MediaPlayerOpening", handle_MediaPlayerOpening);
registerVLCEvent("MediaPlayerBuffering", handle_MediaPlayerBuffering);
registerVLCEvent("MediaPlayerPlaying", handle_MediaPlayerPlaying);
registerVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
registerVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
registerVLCEvent("MediaPlayerStopAsyncDone", handle_MediaPlayerStopAsyncDone);
registerVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
registerVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
registerVLCEvent("MediaPlayerEndReached", handle_MediaPlayerEndReached);
registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);
registerVLCEvent("MediaPlayerTimeChanged", handle_MediaPlayerTimeChanged);
registerVLCEvent("MediaPlayerPositionChanged", handle_MediaPlayerPositionChanged);
registerVLCEvent("MediaPlayerSeekableChanged", handle_MediaPlayerSeekableChanged);
registerVLCEvent("MediaPlayerPausableChanged", handle_MediaPlayerPausableChanged);
registerVLCEvent("MediaPlayerMediaChanged", handle_MediaPlayerMediaChanged);
registerVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
registerVLCEvent("MediaPlayerChapterChanged", handle_MediaPlayerChapterChanged);
registerVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
registerVLCEvent("MediaPlayerVout", handle_MediaPlayerVout);
registerVLCEvent("MediaPlayerMuted", handle_MediaPlayerMuted);
registerVLCEvent("MediaPlayerUnmuted", handle_MediaPlayerUnmuted);
registerVLCEvent("MediaPlayerAudioVolume", handle_MediaPlayerAudioVolume);
//-->
</script>

Event registration issue with IE11

Since IE11, the methods attachEvent() and detachEvent() are not longer available. So the registration of events is not possible. But there are two workarounds:

Workaround 1 - Use the IE10 compatibility mode to re-enable the missing methods. For using the compatibility mode, add this meta tag to the header of your page:

<meta http-equiv="X-UA-Compatible" content="IE=10"/>

Workaround 2 - Use an old IE-only implementation of event registration. An example with the MediaPlayerBuffering event:

<script for="vlc" event="MediaPlayerBuffering(val)"> 
console.log("Buffering: " + val + "%");
</script>

Audio object

readonly properties

  • vlc.audio.count: (supported in vlc version ≥ 1.1.0) returns the number of audio track available.

read/write properties

  • vlc.audio.mute: boolean value to mute and unmute the audio.
  • vlc.audio.volume: a value between [0-200] which indicates a percentage of the volume.
  • vlc.audio.track: (supported in vlc version > 0.8.6) a value between [1-65535] which indicates the audio track to play or that is playing. a value of 0 means the audio is/will be disabled.
  • vlc.audio.channel: (supported in vlc version > 0.8.6) integer value between [1-5] that indicates which audio channel mode is used, values can be: "1=stereo", "2=reverse stereo", "3=left", "4=right", "5=dolby". Use vlc.audio.channel to check if setting of the audio channel mode has succeeded.

methods

  • vlc.audio.toggleMute(): boolean toggle that mutes and unmutes the audio based upon the previous state.
  • vlc.audio.description(int i): (supported in vlc version ≥ 1.1.0) give the i-th audio track name. 0 corresponds to disable and 1 to the first audio track.

Example

Audio Channel:
<select onChange='doAudioChannel(this.value)'>
    <option value=1>Stereo</option>
    <option value=2>Reverse stereo</option>
    <option value=3>Left</option>
    <option value=4>Right</option>
    <option value=5>Dolby</option>
</select>
<script type="text/javascript">
<!--
function doAudioChannel(value)
{
    var vlc = getVLC("vlc");
    vlc.audio.channel = parseInt(value);
    alert(vlc.audio.channel);
}
//-->
</script>

Input object

readonly properties

  • vlc.input.length: length of the input file in number of milliseconds. 0 is returned for 'live' streams or clips whose length cannot be determined by VLC. It returns -1 if no input is playing.
  • vlc.input.fps: frames per second returned as a float (typically 60.0, 50.0, 23.976, etc...)
  • 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:
0 IDLE
1 OPENING
2 BUFFERING
3 PLAYING
4 PAUSED
5 STOPPING
6 ENDED
7 ERROR

Note: Test for ENDED=6 to catch end of playback. Checking for STOPPING=5 is NOT ENOUGH.

  • 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.).
rate > 1 fast forward
rate = 1 normal speed
rate < 1 slow motion

methods

  • none

Title object

readonly properties

  • vlc.input.title.count: (supported in vlc version ≥ 2.2.2) returns the number of title available.

read/write properties

  • vlc.input.title.track: (supported in vlc version ≥ 2.2.2) get and set the title track. The property takes an integer as input value [0..65535]. It returns -1 if no titles are available.

methods

  • vlc.input.title.description(int i): (supported in vlc version ≥ 2.2.2) give the i-th title name.

Chapter object

readonly properties

  • vlc.input.chapter.count: (supported in vlc version ≥ 2.2.2) returns the number of chapter available in the current title.

read/write properties

  • vlc.input.chapter.track: (supported in vlc version ≥ 2.2.2) get and set the chapter track. The property takes an integer as input value [0..65535]. It returns -1 if no chapters are available.

methods

  • vlc.input.chapter.description(int i): (supported in vlc version ≥ 2.2.2) give the i-th chapter name.
  • vlc.input.chapter.countForTitle(int i): (supported in vlc version ≥ 2.2.2) returns the number of chapter available for a specific title.
  • vlc.input.chapter.prev(): (supported in vlc version ≥ 2.2.2) play the previous chapter.
  • vlc.input.chapter.next(): (supported in vlc version ≥ 2.2.2) play the next chapter.

Playlist object

readonly properties

  • vlc.playlist.itemCount: number that returns the amount of items currently in the playlist (deprecated, do not use, see Playlist items)
  • vlc.playlist.isPlaying: a boolean that returns true if the current playlist item is playing and false when it is not playing
  • vlc.playlist.currentItem: (supported in vlc version ≥ 2.2.0) number that returns the index of the current item in the playlist. It returns -1 if the playlist is empty or no item is active.
  • vlc.playlist.items: return the playlist items collection, see Playlist items

read/write properties

  • none

methods

  • vlc.playlist.add(mrl): add a playlist item as MRL. The MRL must be given as a string. Returns the index of the just added item in the playlist as a number.
  • vlc.playlist.add(mrl,name,options): add a playlist item as MRL, with metaname 'name' and options 'options'. options are text arguments which can be provided either as a single string containing space separated values, akin to VLC command line, or as an array of string values. Returns the index of the just added item in the playlist as a number.
var options = new Array(":aspect-ratio=4:3", "--rtsp-tcp");
// Or: var options = ":aspect-ratio=4:3 --rtsp-tcp";
var id = vlc.playlist.add("rtsp://servername/item/to/play", "fancy name", options);
vlc.playlist.playItem(id);
  • vlc.playlist.play(): start playing the current playlist item
  • vlc.playlist.playItem(number): start playing the item whose identifier is number
  • vlc.playlist.pause(): pause 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.stop_async(): (supported in vlc version ≥ 3.0.0) stop playing the current playlist item asynchronously and fire the event MediaPlayerStopAsyncDone, if done
  • 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 (deprecated, do not use, see Playlist items)
  • vlc.playlist.removeItem(number): remove the item from playlist whose identifier is number (deprecated, do not use, see Playlist items)
  • vlc.playlist.parse(options, timeout): (supported in vlc version ≥ 3.0.0) Parse the first media in the playlist. This fetches (local or network) art, meta data and/or tracks information. A timeout for parsing can be set in milliseconds or to indefinitely (0). Returns the parsed status.

Available options flags for parsing (which can be combined):

0 Parse media if it's a local file.
1 Parse media even if it's a network file.
2 Fetch meta and covert art using local resources.
4 Fetch meta and covert art using network resources.
8 Interact with the user. Set this flag in order to receive a callback when the input is asking for credentials.

Parsed status given as enumeration:

1 skipped
2 failed
3 timeout
4 done

Playlist items object

readonly properties

  • vlc.playlist.items.count: number of items currently in the playlist

read/write properties

  • none

methods

  • vlc.playlist.items.clear(): empty the current playlist, all items will be deleted from the playlist. (note: if a movie is playing, it will not stop)
  • vlc.playlist.items.remove(number): remove the item whose identifier is number from playlist. (note: this number is the current position in the playlist. It's not the number given by vlc.playlist.add(), if any items of the playlist were removed in the meantime.)

Subtitle object

readonly properties

  • vlc.subtitle.count: (supported in vlc version ≥ 1.1.0) returns the number of subtitle available.

read/write properties

  • vlc.subtitle.track: (supported in vlc version ≥ 1.1.0) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled.

methods

  • vlc.subtitle.description(int i): (supported in vlc version ≥ 1.1.0) give the i-th subtitle name. 0 correspond to disable and 1 to the first subtitle.

Video object

readonly properties

  • vlc.video.width: returns the horizontal size of the video
  • vlc.video.height: returns the vertical size of the video
  • vlc.video.count: (supported in vlc version ≥ 2.2.7) returns the number of video track available.

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. Typical values are: "1:1", "4:3", "16:9", "16:10", "221:100" and "5:4"
  • vlc.video.scale: (supported in vlc version ≥ 3.0.0) get and set the video scaling factor as float. That is the ratio of the number of pixels on screen to the number of pixels in the original decoded video in each dimension. Zero is a special value; it will adjust the video to the output window.
  • vlc.video.subtitle: (supported in vlc version > 0.8.6a) get and set the subtitle track to show on the video screen. The property takes an integer as input value [1..65535]. If subtitle track is set to 0, the subtitles will be disabled.
  • vlc.video.crop: (removed with vlc version 4.0.0) get and set the geometry of the zone to crop. This is set as <width> x <height> + <left offset> + <top offset>. A possible value is: "120x120+10+10"
  • vlc.video.teletext: (supported in vlc version ≥ 0.9.0) get and set teletext page to show on the video stream. This will only work if a teletext elementary stream is available in the video stream. The property takes an integer as input value [0..1000] for indicating the teletext page to view, setting the value to 0 means hide teletext.
  • vlc.video.track: (supported in vlc version ≥ 2.2.7) a value between [1-65535] which indicates the video track to play or that is playing. a value of 0 means the video is/will be disabled.

methods

  • vlc.video.takeSnapshot(): (supported in vlc version ≥ 0.9.0, only for ActiveX) generates a snapshot and saves it on the desktop
  • vlc.video.toggleFullscreen(): toggle the fullscreen mode based on the previous setting
  • vlc.video.toggleTeletext(): (supported in vlc version ≥ 0.9.0) toggle the teletext page to overlay transparent or not, based on the previous setting
  • vlc.video.description(int i): (supported in vlc version ≥ 2.2.7) give the i-th video track name. 0 corresponds to disable and 1 to the first video track.
  • vlc.video.crop_ratio(int numerator, int denominator): (supported in vlc version ≥ 4.0.0) Forces a crop ratio on any and all video tracks rendered by the media player. To disable video crop, set a crop ratio with zero as denominator.
  • vlc.video.crop_window(int x, int y, int width, int height): (supported in vlc version ≥ 4.0.0) Selects a sub-rectangle of video to show. Any pixels outside the rectangle will not be shown. To unset the video crop window, use vlc.video.crop_ratio() or vlc.video.crop_border().
  • vlc.video.crop_border(int left, int right, int top, int bottom): (supported in vlc version ≥ 4.0.0) Selects the size of video edges to be cropped out. To unset the video crop borders, set all borders to zero.

Deinterlace Object

readonly properties

  • none

read/write properties

  • none

methods

  • vlc.video.deinterlace.enable("my_mode"): (supported in vlc version ≥ 1.1.0) enable deinterlacing with my_mode. You can enable it with "blend", "bob", "discard", "linear", "mean", "x", "yadif" or "yadif2x" mode. Enabling too soon deinterlacing may cause some problems. You have to wait that all variable are available before enabling it.
  • vlc.video.deinterlace.disable(): (supported in vlc version ≥ 1.1.0) disable deinterlacing.

Marquee Object

readonly properties

  • none

read/write properties

  • vlc.video.marquee.text: (supported in vlc version ≥ 1.1.0, since vlc version 4.0.0 writeonly) display my text on the screen.
  • vlc.video.marquee.color: (supported in vlc version ≥ 1.1.0) change the text color. val is the new color to use (WHITE=0x000000, BLACK=0xFFFFFF, RED=0xFF0000, GREEN=0x00FF00, BLUE=0x0000FF...).
  • vlc.video.marquee.opacity: (supported in vlc version ≥ 1.1.0) change the text opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).
  • vlc.video.marquee.position: (supported in vlc version ≥ 1.1.0) change the text position ("center", "left", "right", "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right").
  • vlc.video.marquee.refresh: (supported in vlc version ≥ 1.1.0) change the marquee refresh period.
  • vlc.video.marquee.size: (supported in vlc version ≥ 1.1.0) val define the new size for the text displayed on the screen. If the text is bigger than the screen then the text is not displayed.
  • vlc.video.marquee.timeout: (supported in vlc version ≥ 1.1.0) change the timeout value. val is defined in ms, but 0 value correspond to unlimited.
  • vlc.video.marquee.x: (supported in vlc version ≥ 1.1.0) change text abscissa.
  • vlc.video.marquee.y: (supported in vlc version ≥ 1.1.0) change text ordinate.

methods

  • vlc.video.marquee.enable(): (supported in vlc version ≥ 1.1.0) enable marquee filter.
  • vlc.video.marquee.disable(): (supported in vlc version ≥ 1.1.0) disable marquee filter.

Some problems may happen (option like color or text will not be applied) because of the VLC asynchronous functioning. To avoid it, after enabling marquee, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.

NOTE: see this forum post

Logo Object

readonly properties

  • none

read/write properties

  • vlc.video.logo.opacity: (supported in vlc version ≥ 1.1.0) change the picture opacity, val is defined from 0 (completely transparent) to 255 (completely opaque).
  • vlc.video.logo.position: (supported in vlc version ≥ 1.1.0) change the text position ("center", "left", "right", "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right").
  • vlc.video.logo.delay: (supported in vlc version ≥ 1.1.0) display each picture for a duration of 1000 ms (default) before displaying the next picture.
  • vlc.video.logo.repeat: (supported in vlc version ≥ 1.1.0) number of loops for picture animation (-1=continuous, 0=disabled, n=n-times). The default is -1 (continuous).
  • vlc.video.logo.x: (supported in vlc version ≥ 1.1.0) change the x-offset for displaying the picture counting from top-left on the screen.
  • vlc.video.logo.y: (supported in vlc version ≥ 1.1.0) change the y-offset for displaying the picture counting from top-left on the screen.

methods

  • vlc.video.logo.enable(): (supported in vlc version ≥ 1.1.0) enable logo video filter.
  • vlc.video.logo.disable(): (supported in vlc version ≥ 1.1.0) disable logo video filter.
  • vlc.video.logo.file("file.png"): (supported in vlc version ≥ 1.1.0) display my file.png as logo on the screen.

Some problems may happen because of the VLC asynchronous functioning. To avoid it, after enabling logo video filter, you have to wait a little time before changing an option. But it should be fixed by the new vout implementation.

MediaDescription Object

readonly properties

  • vlc.mediaDescription.title: (supported in vlc version ≥ 2.0.2) returns title meta information field.
  • vlc.mediaDescription.artist: (supported in vlc version ≥ 2.0.2) returns artist meta information field.
  • vlc.mediaDescription.genre: (supported in vlc version ≥ 2.0.2) returns genre meta information field.
  • vlc.mediaDescription.copyright: (supported in vlc version ≥ 2.0.2) returns copyright meta information field.
  • vlc.mediaDescription.album: (supported in vlc version ≥ 2.0.2) returns album meta information field.
  • vlc.mediaDescription.trackNumber: (supported in vlc version ≥ 2.0.2) returns trackNumber meta information field.
  • vlc.mediaDescription.description: (supported in vlc version ≥ 2.0.2) returns description meta information field.
  • vlc.mediaDescription.rating: (supported in vlc version ≥ 2.0.2) returns rating meta information field.
  • vlc.mediaDescription.date: (supported in vlc version ≥ 2.0.2) returns date meta information field.
  • vlc.mediaDescription.setting: (supported in vlc version ≥ 2.0.2) returns setting meta information field.
  • vlc.mediaDescription.URL: (supported in vlc version ≥ 2.0.2) returns URL meta information field.
  • vlc.mediaDescription.language: (supported in vlc version ≥ 2.0.2) returns language meta information field.
  • vlc.mediaDescription.nowPlaying: (supported in vlc version ≥ 2.0.2) returns nowPlaying meta information field.
  • vlc.mediaDescription.publisher: (supported in vlc version ≥ 2.0.2) returns publisher meta information field.
  • vlc.mediaDescription.encodedBy: (supported in vlc version ≥ 2.0.2) returns encodedBy meta information field.
  • vlc.mediaDescription.artworkURL: (supported in vlc version ≥ 2.0.2) returns artworkURL meta information field.
  • vlc.mediaDescription.trackID: (supported in vlc version ≥ 2.0.2) returns trackID meta information field.

read/write properties

  • none

methods

  • none

DEPRECATED APIs

DEPRECATED: Log object

CAUTION: For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.

This object allows accessing VLC main message logging queue. Typically this queue capacity is very small (no more than 256 entries) and can easily overflow, therefore messages should be read and cleared as often as possible.

readonly properties

read/write properties

  • vlc.log.verbosity: write number [-1,0,1,2,3] for changing the verbosity level of the log messages; messages whose verbosity is higher than set will be not be logged in the queue. The numbers have the following meaning: -1 disable, 0 info, 1 error, 2 warning, 3 debug.

methods

  • none

DEPRECATED: Messages object

CAUTION: For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.

readonly properties

  • messages.count: returns number of messages in the log

read/write properties

  • none

methods

  • messages.clear(): clear the current log buffer. It should be called as frequently as possible to not overflow the message queue. Call this method after the log messages of interest are read.
  • messages.iterator(): creates and returns an iterator object, used to iterate over the messages in the log. Don't clear the log buffer while holding an iterator object.

DEPRECATED: Messages Iterator object

CAUTION: For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.

readonly properties

  • iterator.hasNext: returns a boolean that indicates whether vlc.log.messages.next() will return the next message.

read/write properties

  • none

methods

  • iterator.next(): returns the next message object in the log, see Message object

DEPRECATED: Message subobject

CAUTION: For security concern, VLC 1.0.0-rc1 is the latest (near-to-stable) version in which this object and its children are supported.
  • message.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
This page is part of official VLC media player Documentation (User GuideStreaming HowToHacker GuideModules)
Please read the Documentation Editing Guidelines before you edit the documentation
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.