Hi, there:
I check your script, and you've something missunderstood about the VLC webpage plugin.
1. The ID of your vlc player instance is 'vlc' (described in <embed>). But you use 'vlc0', 'vlc1' to operate it. (described in getElementById(), so you've to change it.
2. since there's just one player instance, so the 2 playlist.add() should both operate on object 'vlc'.
3. You use <embed> tag, that would not work on IE, instead both of them should be <object> (see my writeVLC()).
4. Your codes are just native JavaScript so the includes are not necessary (jquery.js, jquery-vlc.js, vlc-object.js)
Here's the webpage, I've test it on IE and FF with my local video clip.
Code: Select all
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="commonR.js"></script>
</head>
<script type='text/javascript'>
function WriteVLC(str, xsz, ysz) {
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape
document.write('<object type="application/x-vlc-plugin"');
document.write(' version="VideoLAN.VLCPlugin.2"');
document.write(' pluginspage="http://www.videolan.org"');
} else { // IE
document.write('<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"');
document.write(' codebase="http://download.videolan.org/pub/videolan/vlc/0.8.6c/win32/axvlc.cab"');
}
document.writeln(' id="'+str+'" name="'+str+'" width='+xsz+' height='+ysz+' events="true">');
document.writeln('</object>');
}
</script>
<body>
<script type="text/javascript">WriteVLC("vlc", 547, 305);</script>
<script type="text/javascript">
function mute() {
vlc.audio.toggleMute();
}
function pause() {
vlc.playlist.togglePause();
}
function stop() {
vlc.playlist.stop();
}
function next() {
if (vlc.playindex == vlc.playlist.items.count) {
vlc.playlist.playItem(0);
vlc.playindex = 1;
} else {
vlc.playlist.next();
vlc.playindex ++;
}
}
function prev() {
if (vlc.playindex == 1) {
vlc.playindex = vlc.playlist.items.count;
vlc.playlist.playItem(vlc.playindex-1);
} else {
vlc.playindex --;
vlc.playlist.prev();
}
}
var vlc = new Object();
function fnInit() {
// For My test code
// var vLoc = window.location.href ;
// var vBase = vLoc.substr(0, vLoc.lastIndexOf("/", vLoc.lastIndexOf("/")-1)+1) + "Video/" ;
vlc = document.getElementById('vlc');
vlc.playlist.clear();
// vlc.playlist.add(vBase+'00011.avi'); // For My local test code
// vlc.playlist.add(vBase+'00010.avi'); // For My local test code
vlc.playlist.add('udp://239.100.0.4:4422');
vlc.playlist.add('udp://239.107.1.4:4422');
vlc.playlist.playItem(0);
vlc.playindex = 1; // my Extended for looping check
}
function regEvent(tobj, type, func) {
if (tobj.addEventListener)
tobj.addEventListener(type, func, true);
else if (tobj.attachEvent)
tobj.attachEvent("on" + type, func);
else tobj["on" + type] = func;
}
regEvent(window, 'load', fnInit);
</script>
<br>
<input type="button" onClick='pause();' value="Play/Pause" />
<input type="button" onClick='mute();' value="Mute" />
<input type="button" onClick='stop();' value="Stop" />
<input type="button" onClick='prev();' value="Channel Down" />
<input type="button" onClick='next();' value="Channel Up" />
</body>
</html>