CWindow Release Candidate 27

Started by José Roca, March 19, 2017, 05:26:35 AM

Previous topic - Next topic

José Roca

#45
The next version is going to be a cool one.

I have just finished CDSAudio, a class that uses Direct Show to play audio files. It supports a great variety of formats.

You can create an instance of the class and load the file at the same time with:


DIM pCDSAudio AS CDSAudio = ExePath & "\prodigy.wav"
pCDSAudio.Run


or you can use the default constructor and then load the file:


DIM pCDSAudio AS CDSAudio
pCDSAudio.Load(ExePath & "\prodigy.wav")
pCDSAudio.Run


With the Load method you can change the audio file on the fly.

To receive event messages, you can define a custom message:


#define WM_GRAPHNOTIFY  WM_APP + 1


and pass it to the class the handle of the window that will process the message:


pCDSAudio.SetNotifyWindow(pWindow.hWindow, WM_GRAPHNOTIFY, 0)


And process the messages in the window callback procedure:


      CASE WM_GRAPHNOTIFY
         DIM AS LONG lEventCode
         DIM AS LONG_PTR lParam1, lParam2
         WHILE (SUCCEEDED(pCDSAudio.GetEvent(lEventCode, lParam1, lParam2)))
            SELECT CASE lEventCode
               CASE EC_COMPLETE:    ' Handle event
               CASE EC_USERABORT:    ' Handle event
               CASE EC_ERRORABORT:   ' Handle event
            END SELEct
         WEND


There are other methods to get/set the volume and balance, to get the duration and current position, to set the positions, and to pause or stop.

I will see if i can to write a similar one but for video.

Richard Kelly

Jeez Jose, I can't keep up and try/test with your avalanche of objects.... :o

Rick

José Roca

Another one to play audio CDs using MCI:

Usage example:


DIM pAudio AS CCDAudio
pAudio.Open
pAudio.Play


Available methods:


' ########################################################################################
' CCDAudio - MCI CD Audio class
' ########################################################################################
TYPE CCDAudio

Private:
   m_dwError AS MCIERROR

Public:
   DECLARE CONSTRUCTOR
   DECLARE DESTRUCTOR
   DECLARE FUNCTION GetLastError () AS MCIERROR
   DECLARE FUNCTION SetError (BYVAL dwError AS MCIERROR) AS MCIERROR
   DECLARE FUNCTION GetErrorString (BYVAL dwError AS MCIERROR = 0) AS CWSTR
   DECLARE FUNCTION Open () AS MCIERROR
   DECLARE FUNCTION Close () AS MCIERROR
   DECLARE FUNCTION IsReady () AS BOOLEAN
   DECLARE FUNCTION IsMediaInserted () AS BOOLEAN
   DECLARE FUNCTION IsPaused () AS BOOLEAN
   DECLARE FUNCTION IsStopped () AS BOOLEAN
   DECLARE FUNCTION IsPlaying () AS BOOLEAN
   DECLARE FUNCTION IsSeeking () AS BOOLEAN
   DECLARE FUNCTION OpenDoor () AS MCIERROR
   DECLARE FUNCTION CloseDoor () AS MCIERROR
   DECLARE FUNCTION Play () AS MCIERROR
   DECLARE FUNCTION PlayFrom (BYVAL nTrack AS LONG) AS MCIERROR
   DECLARE FUNCTION PlayFromTo (BYVAL nStartTrack AS LONG, BYVAL nEndTrack AS LONG) AS MCIERROR
   DECLARE FUNCTION Stop () AS MCIERROR
   DECLARE FUNCTION Pause () AS MCIERROR
   DECLARE FUNCTION GetTracksCount () AS LONG
   DECLARE FUNCTION GetCurrentTrack () AS LONG
   DECLARE FUNCTION GetTrackLengthString (BYVAL nTrack AS LONG) AS CWSTR
   DECLARE FUNCTION GetTrackLength (BYVAL nTrack AS LONG) AS LONG
   DECLARE FUNCTION GetAllTracksLengthString () AS CWSTR
   DECLARE FUNCTION GetAllTracksLength () AS LONG
   DECLARE FUNCTION GetCurrentPosString () AS CWSTR
   DECLARE FUNCTION GetCurrentPos () AS LONG
   DECLARE FUNCTION ToStart () AS MCIERROR
   DECLARE FUNCTION ToEnd () AS MCIERROR
   DECLARE FUNCTION Forward () AS BOOLEAN
   DECLARE FUNCTION Backward () AS BOOLEAN
   DECLARE FUNCTION GetTrackStartTimeString (BYVAL nTrack AS LONG) AS CWSTR
   DECLARE FUNCTION GetTrackStartTime (BYVAL nTrack AS LONG) AS LONG

END TYPE
' ########################################################################################