Page 1 of 1

Using two instances of VLC-player. Control first player?

Posted: 05 May 2009 21:08
by lucasambuca
Hy,

Hy i made an addon to open two instances of VLC-player. Now when i try to open a new file it will always put it in the second-opened player.

Maybe first some explanasion before i post the code:
1) I made a copy of vlc.exe and named it vlc1.exe
I did this so if you open vlc.exe and vlc.exe you've two processes running and each process is named another way

2) then in the code:
if you start the function: twoPlayers
2.1)It will open a vlc-player with processname: vlc.exe
The arguments:
--directx-audio-device=0: this will play the sound of the player in the default soundcard
--no-one-instance: this will make it able to open a second vlc-player
--playlist-enqueue: this will enqueue the files in the playlist instead of playing it immediatly
playFolderPath: this is the directory it has to open in the playlist

2.2)Afterwards it will open a second vlc-player with processname:vlc1.exe
--directx-audio-device=2: this will play the sound of the player in the second soundcard
--one-instance: this will make it unable to open another vlc-player instance
--playlist-enqueue: this will enqueue the files in the playlist instead of playing it immediatly
playFolderPath: this is the directory it has to open in the playlist

Sofar evrything works perfect, but then:

3)when you start the function play
It supposes to put a file to proces vlc.exe and enqueue it in the playlist. This was the first opened VLC-player.
But the problem is that he always enqueues it in the second VLC-player: vlc1.exe


4) the code i wrote:

Code: Select all

// // myplay.js // // Created by Luc Van Roey on 2009-04-27. // top.myplay = { /** * plays the downloading file in VLC-player or when player already open then enqueue the file to the playlist * @param playFile path frome the downloadingfile * @argument --one-instance Don't open a new VLC-player * @argument --playlist-enqueue Enqueue the file to the playlist instead of playing it */ play: function(playFile) { var startFile = playFile; alert("druk op ok om video te starten"); // create an nsILocalFile for the executable var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("e:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe"); // create an nsIProcess var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); process.init(file); var args = ["--one-instance", "--playlist-enqueue", startFile]; process.run(false, args, args.length); }, /** * Open Two VLC-players with the downloadfolder as playlist. Each player has an audio-output to another soundcard * @argument --directx-audio-device=0 Default soundcard * @argument --directx-audio-device=2 Next soundcard * @argument --no-one-instance Open a new VLC-player * @argument --one-instance Don't open a new VLC-player */ twoPlayers: function() { var playFolder = top.myDownloadManager.getDestFolder(); var playFolderPath = playFolder.path alert("druk op ok om video te starten"); // create an nsILocalFile for the executable var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("e:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe"); // create an nsIProcess var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); process.init(file); var args = ["--directx-audio-device=0", "--no-one-instance", "--playlist-enqueue", playFolderPath]; process.run(false, args, args.length); alert("druk op ok om video te starten"); // create an nsILocalFile for the executable var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("e:\\Program Files (x86)\\VideoLAN1\\VLC\\vlc1.exe"); // create an nsIProcess var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); process.init(file); var args = ["--directx-audio-device=2", "--one-instance", "--playlist-enqueue", playFolderPath]; process.run(false, args, args.length); }, }
Does anyone knows how it is possible to enqueue it to the first player?
So i can change the playlist of the first opened player.

Thanks