PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 3 [4]

Author Topic: CWindow Release Candidate 27  (Read 3119 times)

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2732
    • Josť Roca Software
Re: CWindow Release Candidate 27
« Reply #45 on: May 31, 2017, 04:11:27 PM »

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:

Code: [Select]
DIM pCDSAudio AS CDSAudio = ExePath & "\prodigy.wav"
pCDSAudio.Run

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

Code: [Select]
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:

Code: [Select]
#define WM_GRAPHNOTIFY  WM_APP + 1

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

Code: [Select]
pCDSAudio.SetNotifyWindow(pWindow.hWindow, WM_GRAPHNOTIFY, 0)

And process the messages in the window callback procedure:

Code: [Select]
      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.
« Last Edit: May 31, 2017, 04:15:43 PM by Josť Roca »
Logged

Richard Kelly

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 318
Re: CWindow Release Candidate 27
« Reply #46 on: May 31, 2017, 05:44:53 PM »

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

Rick
Logged

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2732
    • Josť Roca Software
Re: CWindow Release Candidate 27
« Reply #47 on: June 02, 2017, 10:57:51 AM »

Another one to play audio CDs using MCI:

Usage example:

Code: [Select]
DIM pAudio AS CCDAudio
pAudio.Open
pAudio.Play

Available methods:

Code: [Select]
' ########################################################################################
' 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
' ########################################################################################
Pages: 1 2 3 [4]