Click or drag to resize
PlayerEx Class
PlayerEx is a component for playing sound in PCM, IMA ADPCM, Microsoft ADPCM, CCITT A-Law, CCITT u-Law, GSM 6.10, Windows Media Audio V2, MPEG Layer-3 (mp3) and other wave file format.
Inheritance Hierarchy

Namespace: Alvas.Audio
Assembly: Alvas.Audio (in Alvas.Audio.dll) Version: 2016.0.6173.41573
Syntax
public class PlayerEx : Component

The PlayerEx type exposes the following members.

Constructors
  NameDescription
Public methodPlayerEx
Initializes a new instance of the PlayerEx class
Public methodPlayerEx(Boolean)
Initializes a new instance of the PlayerEx class
Top
Methods
  NameDescription
Public methodAddData
Adds the audio data for playing.
Public methodCode exampleAddMixData
Adds and mixes the audio data for playing.
Public methodClosePlayer
Closes the player.
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodDispose
Releases all resources used by the Component.
(Inherited from Component.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetMixerNo
Returns mixer number
Public methodStatic memberCode exampleGetPlayerName
Returns player name by index.
Public methodGetPosition
Gets the current sound position.
Public methodGetQueueLength
Gets audio data queue length
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetVolume
Gets the volume.
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodOpenPlayer
Opens the player.
Public methodPausePlay
Pauses the play.
Public methodQueueClear
Clears audio data queue
Public methodResumePlay
Resumes the play.
Public methodSetVolume
Sets the volume.
Public methodStartPlay
Plays the audio data.
Public methodToString
Returns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component.)
Top
Properties
  NameDescription
Public propertyBufferSizeInMS
Gets or sets the player buffer size in milliseconds. By default 500 ms.
Public propertyContainer
Gets the IContainer that contains the Component.
(Inherited from Component.)
Public propertyFormat
Gets pointer to audio format.
Public propertyStatic memberPlayerCount
Gets the number of audio players installed in system.
Public propertyPlayerID
Gets or sets the current player. If -1 the system uses suitable player.
Public propertySite
Gets or sets the ISite of the Component.
(Inherited from Component.)
Public propertyState
Gets the player state.
Public propertyVolumeScale
Scales the volume of audio data. 100 is normal volume, 50 is reduced by half, 200 is increased in 2 times
Top
Events
  NameDescription
Public eventClose
Occurs when the player is closed after playing.
Public eventDisposed
Occurs when the component is disposed by a call to the Dispose method.
(Inherited from Component.)
Public eventDone
Occurs when the player returns next portion of the played data.
Public eventOpen
Occurs when the player is opened for playing.
Top
Examples
This example shows simple using of PlayerEx class.
public static void TestPlayerEx()
{
    PlayerEx plex = new PlayerEx();
    plex.Done += new PlayerEx.DoneEventHandler(plex_Done);
    Mp3Reader mr = new Mp3Reader(File.OpenRead("in.mp3"));
    IntPtr format = mr.ReadFormat();
    byte[] data = mr.ReadData();
    mr.Close();
    plex.OpenPlayer(format);
    plex.AddData(data);
    plex.StartPlay();
}

static void plex_Done(object sender, DoneEventArgs e)
{
    if (e.IsEndPlaying)
    {
        ((PlayerEx)sender).ClosePlayer();
    }
}
See Also