This commit is contained in:
睿 安
2026-01-25 23:46:14 +08:00
parent 2a2a3d68d8
commit 37e7d278bd
727 changed files with 193377 additions and 7 deletions

View File

@@ -0,0 +1,237 @@
== ACTIVEX Control for VLC ==
The VLC ActiveX Control has been primary designed to work with Internet
Explorer. However it may also work with Visual Basic and/or .NET. Please
note, that this code does not rely upon Microsoft MFC/ATL code, hence
good compatibility is not guaranteed.
I. Compiling
The ActiveX Control should compile without any glitches as long as you
have the latest version of mingw gcc and headers.
In order to script the ActiveX Control on Internet Explorer, a type
library is required. This type library is usually generated from an IDL
file using Microsoft MIDL compiler. Therefore, for convenience I have
checked in the output of the MIDL compiler in the repository so that you
will only need the MIDL compiler if you change axvlc.idl. the generated
files are as follow:
axvlc_idl.c
axvlc_idl.h
axvlc.tlb
To use the MIDL compiler on cygwin, you will need to set some
environment variables before configuring vlc. If you have a copy of
'Microsoft Visual C++ 6.0' installed, the following settings are
correct:
export PATH=$PATH:"/cygdrive/c/Program Files/Microsoft Visual Studio/COMMON/MSDev98/Bin":"/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/Bin"
export INCLUDE='C:\Program Files\Microsoft Visual Studio\VC98\Include'
export MIDL="midl"
If you are cross-compiling on Linux, you can use 'widl' which is part of
the WINE project (http://www.winehq.com). At leat wine-dev-0.9.57 works,
the comand line to compile IDL should looks like the following :
widl -I/usr/include/wine/windows/ \
-h -H axvlc_idl.h -t -T axvlc.tlb -u -U axvlc_idl.c axvlc.idl
NOTE: widl breaks compatibility with Visual Basic. If that is important
to you then you must use midl.
II. Debugging
The ActiveX control is compiled with verbose output by default, but you
will need to launch Internet Explorer from a Cygwin shell to see the
output. Alternatively, the plugin will also use the VLC preferences, so
if you enable the file logging interface through the player and save the
preferences, the control will automatically log its verbose output into
the designated file.
Debugging the ActiveX control DLL with GNU GDB can be difficult.
Fortunately the ActiveX control can also be compiled as an executable
rather than a DLL. In ActiveX terms, this is called a local server. The
advantage of a local server is that it will never crash its client,
i.e. Internet Explorer, even if the local server crashes. The build
system does not currently allow to create an executable version of the
ActiveX control, you will need to manually define the BUILD_LOCALSERVER
pre-processor variable and modify the Makefile to exclude the '-shared'
option at the linking stage. Once this is done, launch axvlc.exe to have
a working Activex control. Please note, that executable version of the
ActiveX control will override any settings required for the DLL version,
which will no longer work until you (re)register it as shown in the
following section
III. Local Install
The VLC NSIS installer will install the ActiveX Control without
requiring any further manual intervention, but for people who like to
live on the edge, here are the steps you need to perform once you have
built the ActiveX Control.
The ActiveX control DLL file may be copied anywhere on the target
machine, but before you can use the control, you will need to register
it with Windows by using the REGSVR32 command, as per following example:
REGSVR32 C:\WINDOWS\AXVLC.DLL
If the control needs to use external VLC plugins (i.e other than the
built-in ones), make sure that the plugin path is set in the registry as
per following example:
[HKEY_LOCAL_MACHINE\Software\VideoLAN\VLC]
InstallDir="C:\Program Files\VideoLAN\VLC"
The InstallDir must be the parent directory of the 'plugins' directory.
WARNING: Both control and plugins must come from the same source build
tree. Otherwise, at best, the control will not play any content,
at worse it may crash Internet Explorer while attempting to load
incompatible plugins.
IV. Internet Install
The activex control may be installed from a remote through Internet
Installer if it is packaged up in a CAB file. The following link
explains how to achieve this
http://msdn.microsoft.com/workshop/components/activex/packaging.asp
For convenience, I have provided a sample axvlc.INF file, which assumes
that the VLC NSIS Installer has been packaged up a CAB file called
AXVLC.CAB.
The ActiveX Control DLL file can also be distributed by itself if it has
been compiled with built-in VLC plugins; check developer information for
more information on built-in plugins.
V. Controlling the plugin
1) Properties
The following public properties can be used to control the plugin
from HTML, the property panel of Visual Basic and most ActiveX aware
applications.
+==========+=========+===================================+===============+
| Name: | Type: | Description: | Alias: |
+==========+=========+===================================+===============+
| autoplay | boolean | play when control is activated | autostart |
+----------+---------+-----------------------------------+---------------+
| autoloop | boolean | loop the playlist | loop |
+----------+---------+-----------------------------------+---------------+
| mrl | string | initial MRL in playlist | src, filename |
+----------+---------+-----------------------------------+---------------+
| mute | boolean | mute audio volume | |
+----------+---------+-----------------------------------+---------------+
| visible | boolean | show/hide control viewport | showdisplay |
+----------+---------+-----------------------------------+---------------+
| volume | integer | set/get audio volume | |
+----------+---------+-----------------------------------+---------------+
| toolbar | boolean | set/get visibility of the toolbar | |
+----------+---------+-----------------------------------+---------------+
The alias column shows an alternative <PARAM name> for the property in
internet explorer, which is useful to maintain compatibility with HTML
pages already leveraging Windows Media Player
2) Programming APIs
The MRL, Autoplay and Autoloop properties are only used to configure the
initial state of the ActiveX control,i.e before its activation; they are
ignored afterward. Therefore, if some runtime control is required, the
following APIs should be used within your programming environment:
Variables:
+==========+=========+=========+=======================================+
| Name: | Type: | Access: | Description: |
+==========+=========+=========+=======================================+
| Playing | boolean | RO | Returns whether some MRL is playing |
+----------+---------+---------+---------------------------------------+
| Time | integer | RW | Time elapsed in seconds playing |
| | | | current MRL |
| | | | NOTE: live feeds returns 0 |
+----------+---------+---------+---------------------------------------+
| Position | real | RW | Playback position within current MRL |
| | | | in a scale from 0.0 to 1.0 |
| | | | NOTE: live feeds returns 0.0 |
+----------+---------+---------+---------------------------------------+
| Length | integer | RO | Total length in seconds of current MRL|
| | | | NOTE: live feeds returns 0 |
+----------+---------+---------+---------------------------------------+
| Volume | integer | RW | Current volume from 0 to 100 |
+----------+---------+---------+---------------------------------------+
| Visible | boolean | RW | Indicates whether control is visible |
+----------+---------+---------+---------------------------------------+
Methods:
*** current interface (0.8.6+) ***
UUID : 9BE31822-FDAD-461B-AD51-BE1D1C159921
defined in axvlc.idl as "coclass VLCPlugin2", "interface IVLCControl2"
This interface organizes an API with several objects (like .audio.mute).
It is currently documented on videolan wiki (the url may change) at
http://wiki.videolan.org/Documentation:Play_HowTo/Advanced_Use_of_VLC
*** old interface (deprecated) ***
UUID : E23FE9C6-778E-49D4-B537-38FCDE4887D8
defined in axvlc.idl as "coclass VLCPlugin", "interface IVLCControl"
play()
Play current item the playlist
pause()
Pause current item in the playlist
stop()
Stop playing current item in playlist
shuttle(Seconds as integer)
Advance/backtrack playback by specified amount (which is negative for
backtracking). This is also called relative seeking.
This method does not work for live streams.
fullscreen()
Switch between normal and full screen video
playFaster()
Increase play back speed by 2X, 4X, 8X
playSlower()
Decrease play back speed by 2X, 4X, 8X
toggleMute()
mute/unmute sound output
addTarget(MRL As String, Options as array of strings,
Mode as enumeration, Position as integer)
Add an MRL into the default playlist, you can also specify a list
of playlist options to attach to this MRL or Null for no options.
Mode indicates the action taken by the playlist on MRL and is one
the following:
VLCPlayListInsert = 1 (Insert MRL into playlist at Position)
VLCPlayListInsertAndGo = 9 (Insert MRL into playlist at Position and play it immediately)
VLCPlayListReplace = 2 (Replace MRL in playlist at Position)
VLCPlayListReplaceAndGo = 10 (Replace MRL in playlist at Position and play it immediately)
VLCPlayListAppend = 4 (Append MRL in playlist after Position)
VLCPlayListAppendAndGo = 12 (Append MRL in playlist after Position and play it immediately)
VLCPlayListCheckInsert = 16 (Verify if MRL is in playlist)
Position can take the value of -666 as wildcard for the last element
in the playlist.
setVariable(Name as string, Value as object);
Set a value into a VLC variables
getVariable(Name as string) as object
Retrieve the value of a VLC variable.
Regards,
Damien Fouilleul <Damien dot Fouilleul at laposte dot net>

View File

@@ -0,0 +1,821 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<title>VLC Plugin test page</TITLE>
<style>
.inputTrackerInput {
height:20;
width:30;
font-family : Arial, Helvetica, sans-serif;
font-size : 12px;
}
</style>
<script language="JavaScript"><!--
function init()
{
if( navigator.appName.indexOf("Microsoft Internet")==-1 )
{
onVLCPluginReady()
}
else if( document.readyState == 'complete' )
{
onVLCPluginReady();
}
else
{
/* Explorer loads plugins asynchronously */
document.onreadystatechange=function()
{
if( document.readyState == 'complete' )
{
onVLCPluginReady();
}
}
}
}
function getVLC(name)
{
if (window.document[name])
{
return window.document[name];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[name])
return document.embeds[name];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(name);
}
}
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, true);
} else {
// DOM level 0
eval("vlc.on" + event + " = handler");
}
}
}
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, true);
} else {
// DOM level 0
eval("vlc.on" + event + " = null");
}
}
}
// JS VLC API callbacks
function handleMediaPlayerMediaChanged()
{
document.getElementById("info").innerHTML = "Media Changed";
}
function handle_MediaPlayerNothingSpecial()
{
document.getElementById("state").innerHTML = "Idle...";
}
function handle_MediaPlayerOpening()
{
onOpen();
}
function handle_MediaPlayerBuffering(val)
{
document.getElementById("info").innerHTML = val + "%";
}
function handle_MediaPlayerPlaying()
{
onPlay();
}
function handle_MediaPlayerPaused()
{
onPause();
}
function handle_MediaPlayerStopped()
{
onStop();
}
function handle_MediaPlayerForward()
{
document.getElementById("state").innerHTML = "Forward...";
}
function handle_MediaPlayerBackward()
{
document.getElementById("state").innerHTML = "Backward...";
}
function handle_MediaPlayerEndReached()
{
onEnd();
}
function handle_MediaPlayerEncounteredError()
{
onError();
}
function handle_MediaPlayerTimeChanged(time)
{
var vlc = getVLC("vlc");
var info = document.getElementById("info");
if( vlc )
{
var mediaLen = vlc.input.length;
if( mediaLen > 0 )
{
// seekable media
info.innerHTML = formatTime(time)+"/"+formatTime(mediaLen);
}
}
}
function handle_MediaPlayerPositionChanged(val)
{
// set javascript slider to correct position
}
function handle_MediaPlayerSeekableChanged(val)
{
setSeekable(val);
}
function handle_MediaPlayerPausableChanged(val)
{
setPauseable(val);
}
function handle_MediaPlayerTitleChanged(val)
{
//setTitle(val);
document.getElementById("info").innerHTML = "Title: " + val;
}
function handle_MediaPlayerLengthChanged(val)
{
//setMediaLength(val);
}
// VLC Plugin
function onVLCPluginReady()
{
registerVLCEvent("MediaPlayerMediaChanged", handleMediaPlayerMediaChanged);
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("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("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
registerVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
}
function close()
{
unregisterVLCEvent("MediaPlayerMediaChanged", handleMediaPlayerMediaChanged);
unregisterVLCEvent("MediaPlayerNothingSpecial", handle_MediaPlayerNothingSpecial);
unregisterVLCEvent("MediaPlayerOpening", handle_MediaPlayerOpening);
unregisterVLCEvent("MediaPlayerBuffering", handle_MediaPlayerBuffering);
unregisterVLCEvent("MediaPlayerPlaying", handle_MediaPlayerPlaying);
unregisterVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
unregisterVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
unregisterVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
unregisterVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
unregisterVLCEvent("MediaPlayerEndReached", handle_MediaPlayerEndReached);
unregisterVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);
unregisterVLCEvent("MediaPlayerTimeChanged", handle_MediaPlayerTimeChanged);
unregisterVLCEvent("MediaPlayerPositionChanged", handle_MediaPlayerPositionChanged);
unregisterVLCEvent("MediaPlayerSeekableChanged", handle_MediaPlayerSeekableChanged);
unregisterVLCEvent("MediaPlayerPausableChanged", handle_MediaPlayerPausableChanged);
unregisterVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
unregisterVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
}
//--></script>
<body onLoad="init();" onClose="close();">
<div style="width: 600; height: 200; top:200px; position: absolute; border: 1pt solid black; background: blue; border-radius: 5px; display: none;" id="overlay"></div>
<table>
<tr><td colspan="2">
MRL:
<input size="90" id="targetTextField" value="">
<input type=submit value="Go" onClick="doGo(document.getElementById('targetTextField').value);">
<input type=submit value="Add" onClick="doAdd(document.getElementById('targetTextField').value);">
</td></tr>
<tr><td align="center" colspan="2">
<!--
Insert VideoLAN.VLCPlugin.2
-->
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
width="640"
height="480"
id="vlc"
events="True">
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
<param name="toolbar" value="true" />
<param name="StartTime" value="0" />
<EMBED pluginspage="http://www.videolan.org"
type="application/x-vlc-plugin"
version="VideoLAN.VLCPlugin.2"
width="640"
height="480"
toolbar="true"
loop="true"
branding="true"
text="Waiting for video"
bgcolor="#000000"
allowfullscreen="true"
name="vlc">
</EMBED>
</object>
</td></tr>
<tr><td colspan="2">
<table><tr>
<td valign="top" width="550">
<!--
Insert Slider widget
-->
<div id="inputTrackerDiv"></div>
</td><td width="15%">
<div id="info" style="text-align:center">-:--:--/-:--:--</div>
<div id="state" style="text-align:center">Stopped...</div>
</td></tr></table>
</td></tr>
<tr><td>
<input type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause();'>
<input type=button value="Stop" onClick='doStop();'>
&nbsp;
<input type=button value=" << " onClick='doPlaySlower();'>
<input type=button value="Reverse" onClick='doReverse();'>
<input type=button value=" >> " onClick='doPlayFaster();'>
&nbsp;
<input type=button value="Fullscreen" onClick='getVLC("vlc").video.toggleFullscreen();'>
<input type=button value="Version" onClick='alert("vlc " + getVLC("vlc").VersionInfo);'>
<input type=button value=" State " onClick='alert("state: " + getVLC("vlc").input.state);'>
</td><td align="right">
<SPAN style="text-align:center">Volume:</SPAN>
<input type=button value=" - " onClick='updateVolume(-10)'>
<SPAN id="volumeTextField" style="text-align:center">--</SPAN>
<input type=button value=" + " onClick='updateVolume(+10)'>
<input type=button value="Mute" onClick='getVLC("vlc").audio.toggleMute();'>
</td>
</tr>
<tr><td>Playlist:
<input type=button value="Prev" onClick='getVLC("vlc").playlist.prev();'>
<input type=button value="Next" onClick='getVLC("vlc").playlist.next();'>
<input type=button value="Clear All" onClick='doPlaylistClearAll();'>
Aspect Ratio:
<select readonly onChange='doAspectRatio(this.value)'>
<option value="default">Default</option>
<option value="1:1">1:1</option>
<option value="4:3">4:3</option>
<option value="16:9">16:9</option>
<option value="221:100">221:100</option>
<option value="5:4">5:4</option>
</select>
</td><td align="right">
<input type=button id="itemCount" value=" Items 0 " onClick='doItemCount();'>
<input size=4 value="" id="removeid"><input type=submit value="Delete" onClick="doRemoveItem(document.getElementById('removeid').value);">
</td>
</tr>
<tr><td>Audio Channel:
<select readonly onClick='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>
</td>
<td>
<input type=button value="current channel" onClick='alert(getVLC("vlc").audio.channel);'>
</td>
</tr>
<tr><td> Audio Track:
<input type=button value=" + " onClick='doAudioTrack(1);'>
<SPAN id="trackTextField" style="text-align:center">--</SPAN>
<input type=button value=" - " onClick='doAudioTrack(-1);'>
<input type=button value="current track" onClick='alert(getVLC("vlc").audio.description(vlc.audio.track));'>
<input type=button value="number of track" onClick='alert(getVLC("vlc").audio.count);'>
</td>
<td>
<input type=button value="set slider" onClick='doSetSlider();'>
<input type=button value="get position" onClick='doGetPosition();'>
</td>
</tr>
<tr>
<td>Video Subtitle:
<input type=button value=" + " onClick='doSubtitle(1);'>
<SPAN id="spuTextField" style="text-align:center">--</SPAN>
<input type=button value=" - " onClick='doSubtitle(-1);'>
<input type=button value="current subtitle" onClick='alert(getVLC("vlc").subtitle.description(vlc.subtitle.track));'>
<input type=button value="number of subtitle" onClick='alert(getVLC("vlc").subtitle.count);'>
</td>
</tr>
<tr>
<td>Deinterlacing:
<input type=button value="BLEND" onClick='getVLC("vlc").video.deinterlace.enable("blend");'>
<input type=button value=" X " onClick='getVLC("vlc").video.deinterlace.enable("x");'>
<input type=button value="Disable" onClick='getVLC("vlc").video.deinterlace.disable();'>
</td>
</tr>
<tr>
<td>Marquee video filter:
<input type=button value="Enable" onClick='getVLC("vlc").video.marquee.enable();'>
<input type=button value="Disable" onClick='getVLC("vlc").video.marquee.disable();'>
<input size=4 value="" id="marqueeIntValue">
<select readonly onClick="doMarqueeOption(this.value,document.getElementById('marqueeIntValue').value);">
<option value=1>Color</option>
<option value=2>Opacity</option>
<option value=3>Position</option>
<option value=4>Refresh</option>
<option value=5>Size</option>
<option value=6>Text</option>
<option value=7>Timeout</option>
<option value=8>X</option>
<option value=9>Y</option>
</select>
</td>
</tr>
<tr>
<td>Logo video filter:
<input type=button value="Enable" onClick='getVLC("vlc").video.logo.enable();'>
<input type=button value="Disable" onClick='getVLC("vlc").video.logo.disable();'>
<input size=4 value="" id="logoIntValue">
<select readonly onClick="doLogoOption(this.value,document.getElementById('logoIntValue').value);">
<option value=1>File</option>
<option value=2>Position</option>
<option value=3>Opacity</option>
<option value=4>Repeat</option>
<option value=5>Delay</option>
<option value=6>X</option>
<option value=7>Y</option>
</select>
</td>
</tr>
<tr>
<td>
<input type=button id="telx" value="Teletext off" onClick='doToggleTeletext();'>
Teletext page:
<input size=4 value="100" id="telxPage" onClick='doTelxPage(document.getElementById("telxPage").value);'>
</td>
</tr>
</table>
<SCRIPT language="javascript">
<!--
var rate = 0;
var prevState = 0;
var telxState = false;
var canPause = true;
var canSeek = true;
function setPauseable(val)
{
canPause = val;
}
function setSeekable(val)
{
canSeek = val;
}
function doSetSlider()
{
var vlc = getVLC("vlc");
// set slider to new position
if( vlc )
vlc.input.time = (vlc.input.length/2);
}
function doGetPosition()
{
var vlc = getVLC("vlc");
// set slider to new position
if (vlc)
alert( "position is " + vlc.input.time);
}
function doReverse(rate)
{
var vlc = getVLC("vlc");
if( vlc )
vlc.input.rate = -1.0 * vlc.input.rate;
}
function doAudioChannel(value)
{
var vlc = getVLC("vlc");
if( vlc )
vlc.audio.channel = parseInt(value);
}
function doAudioTrack(value)
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.audio.track = vlc.audio.track + value;
document.getElementById("trackTextField").innerHTML = vlc.audio.track;
}
}
function doAspectRatio(value)
{
var vlc = getVLC("vlc");
if( vlc )
vlc.video.aspectRatio = value;
}
function doSubtitle(value)
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.subtitle.track = vlc.subtitle.track + value;
document.getElementById("spuTextField").innerHTML = vlc.subtitle.track;
}
}
function doTelxPage(value)
{
var vlc = getVLC("vlc");
if( vlc )
vlc.video.teletext = parseInt(value);
}
function doToggleTeletext()
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.video.toggleTeletext();
if (telxState)
{
document.getElementById("telx").innerHTML = "Teletext on";
telxState = true;
}
else
{
document.getElementById("telx").innerHTML = "Teletext off";
telxState = false;
}
}
}
function doItemCount()
{
var vlc = getVLC("vlc");
if( vlc )
{
var count = vlc.playlist.items.count;
document.getElementById("itemCount").value = " Items " + count + " ";
}
}
function doRemoveItem(item)
{
var vlc = getVLC("vlc");
if( vlc )
vlc.playlist.items.remove(item);
}
function doPlaylistClearAll()
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.playlist.items.clear();
while( vlc.playlist.items.count > 0)
{
// wait till playlist empties.
}
doItemCount();
}
}
function updateVolume(deltaVol)
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.audio.volume += deltaVol;
document.getElementById("volumeTextField").innerHTML = vlc.audio.volume+"%";
}
}
function formatTime(timeVal)
{
if( typeof timeVal != 'number' )
return "-:--:--";
var timeHour = Math.round(timeVal / 1000);
var timeSec = timeHour % 60;
if( timeSec < 10 )
timeSec = '0'+timeSec;
timeHour = (timeHour - timeSec)/60;
var timeMin = timeHour % 60;
if( timeMin < 10 )
timeMin = '0'+timeMin;
timeHour = (timeHour - timeMin)/60;
if( timeHour > 0 )
return timeHour+":"+timeMin+":"+timeSec;
else
return timeMin+":"+timeSec;
}
// Old method of querying current state
// function doState() - depreceated
function doState()
{
var vlc = getVLC("vlc");
var newState = 0;
if( vlc )
newState = vlc.input.state;
if( newState == 0 )
{
// current media has stopped
onEnd();
}
else if( newState == 1 )
{
// current media is openning/connecting
onOpen();
}
else if( newState == 2 )
{
// current media is buffering data
onBuffer();
}
else if( newState == 3 )
{
// current media is now playing
onPlay();
}
else if( newState == 4 )
{
// current media is now paused
onPause();
}
else if( newState == 5 )
{
// current media has stopped
onStop();
}
else if( newState == 6 )
{
// current media has ended
onEnd();
}
else if( newState == 7 )
{
// current media encountered error
onError();
}
}
/* actions */
function doGo(targetURL)
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.playlist.items.clear();
while( vlc.playlist.items.count > 0 )
{
// clear() may return before the playlist has actually been cleared
// just wait for it to finish its job
}
var options = [":rtsp-tcp"];
var itemId = vlc.playlist.add(targetURL,"",options);
options = [];
if( itemId != -1 )
{
// play MRL
vlc.playlist.playItem(itemId);
}
else
{
alert("cannot play at the moment !");
}
doItemCount();
}
}
function doAdd(targetURL)
{
var vlc = getVLC("vlc");
var options = [":vout-filter=deinterlace", ":deinterlace-mode=linear"];
if( vlc )
{
vlc.playlist.add(targetURL, "", options);
options = [];
doItemCount();
}
}
function doPlayOrPause()
{
var vlc = getVLC("vlc");
if( vlc )
{
vlc.playlist.togglePause();
}
}
function doStop()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.playlist.stop();
}
function doPlaySlower()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.input.rate = vlc.input.rate / 2;
}
function doPlayFaster()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.input.rate = vlc.input.rate * 2;
}
function doMarqueeOption(option, value)
{
var vlc = getVLC("vlc");
val = parseInt(value);
if( vlc )
{
if (option == 1)
vlc.video.marquee.color = val;
if (option == 2)
vlc.video.marquee.opacity = val;
if (option == 3)
vlc.video.marquee.position = value;
if (option == 4)
vlc.video.marquee.refresh = val;
if (option == 5)
vlc.video.marquee.size = val;
if (option == 6)
vlc.video.marquee.text = value;
if (option == 7)
vlc.video.marquee.timeout = val;
if (option == 8)
vlc.video.marquee.x = val;
if (option == 9)
vlc.video.marquee.y = val;
}
}
function doLogoOption(option, value)
{
var vlc = getVLC("vlc");
if( vlc )
{
if (option == 1)
vlc.video.logo.file(value);
if (option == 2)
vlc.video.logo.position = value;
val = parseInt(value);
if (option == 3)
vlc.video.logo.opacity = val;
if (option == 4)
vlc.video.logo.repeat = val;
if (option == 5)
vlc.video.logo.delay = val;
if (option == 6)
vlc.video.logo.x = val;
if (option == 7)
vlc.video.logo.y = val;
}
}
/* events */
function onOpen()
{
document.getElementById("state").innerHTML = "Opening...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onBuffer()
{
document.getElementById("state").innerHTML = "Buffering...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onPlay()
{
document.getElementById("state").innerHTML = "Playing...";
document.getElementById("PlayOrPause").value = "Pause";
onPlaying();
}
function onEnd()
{
document.getElementById("state").innerHTML = "End...";
}
var liveFeedText = ["Live", "((Live))", "(( Live ))", "(( Live ))"];
var liveFeedRoll = 0;
function onPlaying()
{
var vlc = getVLC("vlc");
var info = document.getElementById("info");
if( vlc )
{
var mediaLen = vlc.input.length;
if( mediaLen > 0 )
{
// seekable media
info.innerHTML = formatTime(vlc.input.time)+"/"+formatTime(mediaLen);
}
else
{
// non-seekable "live" media
liveFeedRoll = liveFeedRoll & 3;
info.innerHTML = liveFeedText[liveFeedRoll++];
}
}
}
function onPause()
{
document.getElementById("state").innerHTML = "Paused...";
document.getElementById("PlayOrPause").value = " Play ";
}
function onStop()
{
var vlc = getVLC("vlc");
document.getElementById("info").innerHTML = "-:--:--/-:--:--";
document.getElementById("state").innerHTML = "Stopped...";
document.getElementById("PlayOrPause").value = " Play ";
}
function onError()
{
var vlc = getVLC("vlc");
document.getElementById("state").innerHTML = "Error...";
}
//-->
</SCRIPT>
</body>
</HTML>