next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: getFileVersionInfo   Contents


MCI Object

Description

Provides access to the Media Control Interface (MCI), which provides standard commands for playing multimedia devices and recording multimedia resource files.

available: SWFKit Express, SWFKit, SWFKit Pro


Syntax

new MCI();


Remarks

MCI provides two ways to play multimedia devices. The first is the sendCmdString method, which represents the command-string interface of MCI. You can call it directly for it is a static method. E.g.

//opens the CD-ROM then close it.
MCI.sendCmdString("open cdaudio alias cd");
MCI.sendCmdString("set cd door open wait");
MCI.sendCmdString("set cd door closed wait");
MCI.sendCmdString("close cd");
The second is the command property, which represents the command-message interface of MCI. The MCI object provides some other properties to work with the command property. The following examples demonstrating how to use these properties:
  1. Opens a device
    You can open a device by specifying the deviceType and the filename.

    //Example 1. Opens a cdaudio
    var m = new MCI;
    //specifies the device type
    m.deviceType = "cdaudio";
    //open the cdaudio device
    m.command = "open";
    
    //Example 2. Opens a waveform-audio file
    var m = new MCI;
    //specifies the device type
    m.deviceType = "waveaudio";
    //specifies the file name
    m.fileName = "test.wav";
    //open the cdaudio device
    m.command = "open";
    

  2. Handling MCI Errors
    You should check the error property for errors. If it indicates an error, use the errorMsg property to get a textual description of the error. E.g.

    var m = new MCI;
    m.command = "open";
    if (m.error) trace(m.errorMsg);
    
  3. Using the wait property MCI commands usually return to the user immediately, even if it takes several minutes to complete the action initiated by the command. You can set the wait property to true to direct the device to wait until the requested action is completed before returning control to the FFish script. E.g.

    var m = new MCI;
    m.wait = true;
    m.deviceType = "cdaudio";
    m.command = "open";
    
    //The continuous scripts won't
    //run until the CDAudio is opened
    ...
    
  4. Using the notify property MCI object fires the onNotify events if the notify property is set to true. The events are fired after an action is completed. You can handle this event by specifying a handler function. E.g.

    //Example.
    //Closes the device after playing the wave
    function on\_notify(flag)
    {
    m.notify = false;
    m.command = "close";
    if (flag == 1) trace("OK.");
    }
    
    m = new MCI;
    m.deviceType = "waveaudio";
    m.fileName = "d:\\1.wav";
    m.command = "open";
    m.notify = true;
    m.onNotify = on\_notify;
    m.command = "play";
    
  5. Playing a CD

    //Example. Playing a CD
    function on\_notify(flag)
    {
        m.notify = false;
        m.command = "close";
    }
    
    m = new MCI;
    m.deviceType = "cdaudio";
    m.command = "open";
    //set the time format to TMSF
    m.timeFormat = 10;
    
    //plays track 12
    m.from = MCI.makeTMSF(12, 0, 0, 0);
    m.to = MCI.makeTMSF(13, 0, 0, 0);
    m.notify = true;
    m.onNotify = on\_notify;
    m.command = "play";
    

  6. Playing a movie Before open a video device you must set the location of the playing movie.

    //Example: playing a movie
    m = new MCI;
    m.deviceType = "avivideo";
    m.fileName = "D:\\1.avi";
    
    //set the loaction of the playing window
    m.left = 0;
    m.top = 0;
    m.width = 320;
    m.height = 240;
    m.command = "open";
    m.command = "play";
    

  7. Changing the Current Position You can use the commands "prev", "next", "step", "back" and "seek" to change the current position of the device.

    //Example: use command "seek" to
    //change the current position of the CD
    var m = new MCI;
    m.deviceType = "cdaudio";
    m.command = "open";
    m.timeFormat = 10;
    m.to = MCI.makeTMSF(10, 1, 0, 0);
    m.command = "seek";
    m.to = MCI.makeTMSF(11, 0, 0, 0);
    m.command = "play";
    

  8. Recording with a Waveform-Audio Device

    m = new MCI;
    m.deviceType = "waveaudio";
    m.fileName = "";
    m.wait = true;
    m.command = "open";
    //set the time format to milliseconds
    m.timeFormat = 0;
    //Set the record length to 10 seconds
    m.to = 10000;
    m.command = "record";
    
    //save the recording to file
    m.fileName = "d:\\1.wav";
    m.command = "save";
    m.command = "close";
    




Subsections
next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: getFileVersionInfo   Contents
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.