|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I have tested using SKFKit with VLC ActiveX Plugin playing movies successfully.
But my client require me to select the sound device for the playback. I understand that this maynot be a SWFKit specific question, I would like to know how can I select the sound device for playback using MS Media Player or VLC Plugin ? Is the MCI object in SWFKit able to used to select the default sound device for the whole application ? Roger. |
|
|||
|
No, you cannot use the MCI object to change the default playback device. There is no method in swfkit that can change the default playback device. However, because swfkit pro can call external dynamic linked libraries (Dlls), we will let you know whether it is possible to set the default playback device programmatically before Monday.
|
|
|||
|
Please use the following modified code. The original code has a small problem.
It can be done by calling Windows API. Please insert the following code into the initialize script in swfkit pro, before the "return" clause. Code:
struct
{
unsigned short wMid;
unsigned short wPid;
unsigned int vDriverVersion;
char szPname[32];
unsigned int dwFormats;
unsigned short wChannels;
unsigned short wReserved1;
unsigned int dwSupport;
} WaveOutCapsA;
dllimport "winmm.dll" stdcall unsigned int waveOutGetNumDevs();
dllimport "winmm.dll" stdcall unsigned int waveOutGetDevCapsA(int, WaveOutCapsA*, int);
dllimport "winmm.dll" stdcall unsigned int waveOutMessage(unsigned int, unsigned int, int*, int*);
dllimport "winmm.dll" stdcall unsigned int waveOutMessage(unsigned int, unsigned int, pointer, pointer) as waveOutMessage2;
// returns an array that contains all names of audio playback devices installed in system
function getPlaybackDevices() {
var devs = [];
var count = waveOutGetNumDevs();
for (var i = 0; i < count; i++) {
var MMSYSERR_NOERROR = 0;
var output = new Object;
output.value = new Struct(WaveOutCapsA);
if (waveOutGetDevCapsA(i, output, output.value.structSize) == MMSYSERR_NOERROR) {
devs.push(output.value.szPname);
}
}
return devs;
}
// return the id of the current default audio playback device.
// id is from 0 to device count - 1
function getDefaultPlaybackDevice() {
var WAVE_MAPPER = 0xFFFFFFFF;
var DRVM_MAPPER = 0x2000;
var DRVM_MAPPER_PREFERRED_GET = DRVM_MAPPER + 21;
var MMSYSERR_NOERROR = 0;
var out = new Object;
out.value = 0;
var err = waveOutMessage(WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, out, 0);
if (err != MMSYSERR_NOERROR) {
trace("encounters error: " + err);
return -1;
}
return out.value;
}
// set the default audio playback device
// parameters -
// id: the id of the device to set as the default playback device
// it should be 0 to device count - 1
function setDefaultPlaybackDevice(id) {
var WAVE_MAPPER = 0xFFFFFFFF;
var DRVM_MAPPER = 0x2000;
var DRVM_MAPPER_PREFERRED_SET = DRVM_MAPPER + 22;
var MMSYSERR_NOERROR = 0;
var err = waveOutMessage2(WAVE_MAPPER, DRVM_MAPPER_PREFERRED_SET, id, 0);
if (err != MMSYSERR_NOERROR) {
trace("encounters error: " + err);
return false;
}
return true;
}
var devs = getPlaybackDevices();
trace("The current default playback device is: " +
devs[getDefaultPlaybackDevice()]);
trace(setDefaultPlaybackDevice(devs.length - 1));
|
|
|||
|
After inserting the above code, you can call the "getDefaultPlaybackDevice" or "setDefaultPlaybackDevice" function to retrieve or set the default audio playback device, in either ffish script or actionscript(by using the ExternalInterface.call method).
|
|
|||
|
Thanks for the quick support.
However, I found the following using FFScript: devs.length is 2. But the setDefaultPlaybackDevice(1) didn't work. And I test it with the following scenarios. I use Control panel to set the default audio to both the USB Audio device (Sound Blaster), and the onboard audio one at a time. Both times, the getDefaultPlaybackDevice returns "0" but the audio actually comes out correctly via the two devices respectively. And the setDefaultPlaybackDevice(0) or setDefaultPlaybackDevice(1) makes no different to the auido playback, it seems only follow what the control panel set. I am building and testing the script in Win XP. Anything wrong on my setup ? ===== P.S. I never see any output window showing the trace() in ffscript, the F10 explore output directory shows no files except the "Application" folder. |
|
|||
|
Please use the above modified code, we are sure that it works. The original code has a small problem, which causes the "setDefaultPlaybackDevice" method to fail. And when you press F9 to preview your swfkit pro project, you will find that a minimized window on the left bottom of the screen, which is the trace window showing the output of the trace method. To see the output EXE files built by swfkit pro in the output directory by pressing "F10", you must first press "F7" to build it.
Besides, we have found something interesting that when the default playback device has been changed, the order of the devices may change. For example, before changing the default playback device, the id of the device A is 0, but after changing, its id maybe 1. So please always use the getPlaybackDevices method to determine the id of a device, which is the same as the index of the device in the array returned by the method. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|