Announcement

Collapse
No announcement yet.

Media Foundation MediaPlayer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #41
    Yes, the second link is what I am translating now. It uses
    template <classQ> in the Player.cpp.

    Comment


    • #42
      Does this..

      Code:
      [color=000000]    [/color][color=007F00]'// Return the IMFTopology pointer to the caller.
          [/color][color=8000FF]*[/color][color=000000]ppTopology [/color][color=8000FF]= [/color][color=000000]pTopology
          [/color][color=8000FF](*[/color][color=000000]ppTopology[/color][color=8000FF])[/color][color=000000].AddRef[/color][color=8000FF]()
      [/color]
      translate to this?

      Code:
      [color=000000]    [/color][color=007F00]'// Return the IMFTopology pointer to the caller.
          [/color][color=000000]ppTopology [/color][color=8000FF]= [/color][color=0000C0]VARPTR[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF])
          [/color][color=000000]ppTopology.AddRef[/color][color=8000FF]()
      [/color]

      Comment


      • #43
        Surely not. You should learn first how to work with COM with PB. PB does automatic reference counting, whereas the C++ class that you want to translate is using pointers, not objects. The equivalent would be ppTopology = pTopology, but you should learn why.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #44
          Famous quote,
          "Regarding low-level COM, only C++ is more powerful, although is much more difficult to use."
          As yet I don't believe I've seen this technique in the Help File ppTopology = pTopology. Does PB COM see through pointers-to-pointers? I know I'm a pain.
          So if I understand you correctly, PB COM does what C++ does not. PB COM tracks references to an object but C++ requires pointers to do the tracking.

          Comment


          • #45
            C++ allows many techniques. Instead of raw pointers, you can use smart pointers, that like PB manage reference counting automatically.
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment


            • #46
              This is what I'm trying to translate...


              [CODE]
              // Static class method to create the CPlayer object.
              HRESULT CPlayer::CreateInstance(
              HWND hVideo,
              // Video window.
              HWND hEvent,
              // Window to receive notifications.
              CPlayer **ppPlayer)
              // Receives a pointer to the CPlayer object.
              {
              if
              (ppPlayer == NULL)
              {
              return
              E_POINTER;
              }

              CPlayer *pPlayer =
              new
              (std::
              nothrow
              ) CPlayer(hVideo, hEvent);
              if
              (pPlayer == NULL)
              {
              return
              E_OUTOFMEMORY;
              }

              HRESULT hr = pPlayer->Initialize();
              if
              (SUCCEEDED(hr))
              {
              *ppPlayer = pPlayer;
              }
              else
              {
              pPlayer->Release();
              }
              return
              hr;
              }




              Code:
              [COLOR=007F00]'//  Static class method to create the CPlayer object.[/COLOR]
              [COLOR=0000C0]METHOD [/COLOR][COLOR=000000]CreateInstance[/COLOR][COLOR=8000FF]( [/COLOR][COLOR=0000C0]_           [/COLOR][COLOR=007F00]'CPlayer method[/COLOR]
              [COLOR=0000C0]BYVAL [/COLOR][COLOR=000000]hVideo [/COLOR][COLOR=0000C0]AS DWORD _       [/COLOR][COLOR=007F00]'// IN HWND Video window.[/COLOR]
              [COLOR=8000FF], [/COLOR][COLOR=0000C0]BYVAL [/COLOR][COLOR=000000]hEvent [/COLOR][COLOR=0000C0]AS DWORD _       [/COLOR][COLOR=007F00]'// IN HWND Window to receive notifications.[/COLOR]
              [COLOR=8000FF], [/COLOR][COLOR=0000C0]BYVAL [/COLOR][COLOR=000000]ppPlayer [/COLOR][COLOR=0000C0]AS [/COLOR][COLOR=000000]MyInterface [/COLOR][COLOR=0000C0]_   [/COLOR][COLOR=007F00]'???? '// OUT CPlayer **ppPlayer Receives a pointer to the CPlayer object.[/COLOR]
              [COLOR=8000FF]) [/COLOR][COLOR=0000C0]AS LONG
              
                          LOCAL [/COLOR][COLOR=000000]hr [/COLOR][COLOR=0000C0]AS LONG
                          IF [/COLOR][COLOR=8000FF](ISFALSE [/COLOR][COLOR=0000C0]ISOBJECT[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]ppPlayer[/COLOR][COLOR=8000FF])) [/COLOR][COLOR=0000C0]THEN
                              FUNCTION [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=0000C0]%E_POINTER
                          END IF[/COLOR]
              
              [COLOR=000000]CPlayer [/COLOR][COLOR=8000FF]*[/COLOR][COLOR=000000]pPlayer [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=0000C0]NEW [/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]std[/COLOR][COLOR=8000FF]::[/COLOR][COLOR=000000]nothrow[/COLOR][COLOR=8000FF]) [/COLOR][COLOR=000000]CPlayer[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]hVideo[/COLOR][COLOR=8000FF], [/COLOR][COLOR=000000]hEvent[/COLOR][COLOR=8000FF])[/COLOR]
              [COLOR=0000C0]IF [/COLOR][COLOR=8000FF](ISFALSE [/COLOR][COLOR=0000C0]ISOBJECT[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]pPlayer[/COLOR][COLOR=8000FF])) [/COLOR][COLOR=0000C0]THEN
                              FUNCTION [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=0000C0]%E_OUTOFMEMORY
                          END IF[/COLOR]
              
              [COLOR=000000]hr [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=000000]pPlayer.Initialize[/COLOR][COLOR=8000FF]()[/COLOR]
              [COLOR=0000C0]IF [/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]SUCCEEDED[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]hr[/COLOR][COLOR=8000FF])) [/COLOR][COLOR=0000C0]THEN[/COLOR]
              [COLOR=8000FF]*[/COLOR][COLOR=000000]ppPlayer [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=000000]pPlayer[/COLOR]
              [COLOR=0000C0]ELSE[/COLOR]
              [COLOR=000000]pPlayer.Release[/COLOR][COLOR=8000FF]()[/COLOR]
              [COLOR=0000C0]END IF
                          FUNCTION [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=000000]hr[/COLOR]
              [COLOR=0000C0]END METHOD[/COLOR]

              I'm not sure what to do with NEW (std::nothrow)

              Comment


              • #47
                CPlayer is not a COM object. It is a custom C++ class. If you want to mimic that C++ code you need to implement your CPlayer class.
                Forum: http://www.jose.it-berater.org/smfforum/index.php

                Comment


                • #48
                  This is how I have the CPlayer class designed.


                  Code:
                  [COLOR=0000C0]CLASS [/COLOR][COLOR=000000]CPLayer $MyClassGuid [/COLOR][COLOR=0000C0]AS COM
                  
                      INTERFACE [/COLOR][COLOR=000000]IMFAsyncCallbackImpl [/COLOR][COLOR=007F00]'MyInterface $MyIfaceGuid[/COLOR]
                  [COLOR=0000C0]INHERIT IAUTOMATION[/COLOR]
                  and the code above in post #46 is a method in the CPlayer class.

                  With this line it looks like the CreateInstance method is trying to create the pPlayer COM object without producing any error messages.


                  Code:
                  [COLOR=000000]CPlayer [/COLOR][COLOR=8000FF]*[/COLOR][COLOR=000000]pPlayer [/COLOR][COLOR=8000FF]= [/COLOR][COLOR=0000C0]NEW [/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]std[/COLOR][COLOR=8000FF]::[/COLOR][COLOR=000000]nothrow[/COLOR][COLOR=8000FF]) [/COLOR][COLOR=000000]CPlayer[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]hVideo[/COLOR][COLOR=8000FF], [/COLOR][COLOR=000000]hEvent[/COLOR][COLOR=8000FF])[/COLOR]
                  There is also a CPlayer method inside the CPlayer class that I assume initializes all global variables and wipes out references to objects.


                  Code:
                  [COLOR=0000C0]METHOD [/COLOR][COLOR=000000]CPlayer[/COLOR][COLOR=8000FF]( [/COLOR][COLOR=0000C0]_             [/COLOR][COLOR=007F00]'CPlayer method[/COLOR]
                  [COLOR=000000]HWND hVideo [/COLOR][COLOR=0000C0]_[/COLOR]
                  [COLOR=8000FF], [/COLOR][COLOR=000000]HWND hEvent[/COLOR][COLOR=8000FF]) :[/COLOR]
                  [COLOR=000000]pMediaSession[/COLOR][COLOR=8000FF]([/COLOR][COLOR=0000C0]NULL[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]pMediaSource[/COLOR][COLOR=8000FF]([/COLOR][COLOR=0000C0]NULL[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]pVideoDisplay[/COLOR][COLOR=8000FF]([/COLOR][COLOR=0000C0]NULL[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]m_hwndVideo[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]hVideo[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]m_hwndEvent[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]hEvent[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]m_state[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]%Closed[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]m_hCloseEvent[/COLOR][COLOR=8000FF]([/COLOR][COLOR=0000C0]NULL[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]m_nRefCount[/COLOR][COLOR=8000FF]([/COLOR][COLOR=000000]1[/COLOR][COLOR=8000FF]),[/COLOR]
                  [COLOR=000000]pCallback[/COLOR][COLOR=8000FF]([/COLOR][COLOR=0000C0]NULL[/COLOR][COLOR=8000FF])[/COLOR]
                  
                  [COLOR=0000C0]END METHOD[/COLOR]
                  Crazy right!

                  Comment


                  • #49
                    Code:
                    CLASS CPLayer $MyClassGuid AS COM
                    
                        INTERFACE IMFAsyncCallbackImpl 'MyInterface $MyIfaceGuid
                    INHERIT IAUTOMATION
                    Sorry, but it does make any sense. Unfortunately, I don't have time to translate that C++ code to PB.
                    Last edited by José Roca; 6 Jun 2018, 09:01 AM.
                    Forum: http://www.jose.it-berater.org/smfforum/index.php

                    Comment


                    • #50
                      That is ok. I'll keep plugging at it. Thanks

                      Comment


                      • #51
                        Here is the example I cobbled together to show my problem creating a Media Source. I've also tried the asynchronous method but it didn't work either. Please help


                        Code:
                        [color=007F00]'This is a translation of this site:
                        'https://chromium.googlesource.com/webm/webmdshow/+/refs/heads/master/mediafoundation/webmmftests/mfplay/player.cc
                        
                        
                        '/////////////////////////////////////////////////////////////////////////////////
                        '// by: Jim Fritts on 13 JUNE 2018
                        '// From OLD MSDN Media Foundation Media Player example.
                        '//
                        '// Note: This example will compile.
                        '//       It is just for your info.
                        '//       Change sURL to match an audio path in your own music library.
                        '//       See here ////////  NEVER GETS HERE  //////// for problem area.
                        '//       Problem is the Source is never created.
                        '//
                        '/////////////////////////////////////////////////////////////////////////////////
                        
                        'TRUE = -1
                        'FALSE = 0
                        
                        '/////////////////////////////////////////////////////////////////
                        '/////////////////////// CPlayer Class EX ////////////////////////
                        '/////////////////////////////////////////////////////////////////
                        'Example class for Player
                        'CLASS MyClass
                        ' INSTANCE MyVar AS LONG
                        '
                        ' CLASS METHOD CREATE()        'A CLASS METHOD IS PRIVATE
                        '   ' Do initialization
                        ' END METHOD
                        '
                        ' CLASS METHOD DESTROY()       'A CLASS METHOD IS PRIVATE
                        '   ' Do cleanup
                        ' END METHOD
                        '
                        ' INTERFACE MyInterface
                        '   INHERIT IUNKNOWN
                        '   METHOD MyMethod1 <101> ()  '<> DISPATCH ID
                        '     ' Do things
                        '   END METHOD
                        '
                        '   METHOD MyMethod2 <102> () AS LONG      '*******************
                        '     ' Do things
                        '     METHOD = RETURN VALUE  '******************
                        '   END METHOD
                        ' END INTERFACE
                        '
                        'END CLASS
                        '/////////////////////////////////////////////////////////////////
                        
                        'COM RETURN VALUES
                        '%E_ACCESSDENIED 0x80070005 Access denied.
                        '%E_FAIL         0x80004005 Unspecified error.
                        '%E_INVALIDARG   0x80070057 Invalid parameter value.
                        '%E_OUTOFMEMORY  0x8007000E Out of memory.
                        '%E_POINTER      0x80004003 NULL was passed incorrectly for a pointer value.
                        '%E_UNEXPECTED   0x8000FFFF Unexpected condition.
                        '%S_OK           0x0        Success.
                        '%S_FALSE        0x1        Success.
                        
                        '// Application should not call MFStartup / MFShutdown from workqueue threads
                        
                        '/////////////////////////////////////////////////////////////////
                        
                        [/color][color=0000C0]#COMPILE EXE
                        #DIM ALL
                        #INCLUDE ONCE [/color][color=C020C0]"windows.inc"
                        [/color][color=0000C0]#INCLUDE ONCE [/color][color=C020C0]"mfapi.inc"
                        [/color][color=0000C0]#INCLUDE ONCE [/color][color=C020C0]"mfidl.inc"
                        [/color][color=0000C0]#INCLUDE ONCE [/color][color=C020C0]"evr.inc"  [/color][color=007F00]'needed for video display control
                        [/color][color=0000C0]#INCLUDE ONCE [/color][color=C020C0]"Mferror.inc"
                        [/color][color=0000C0]#INCLUDE ONCE [/color][color=C020C0]"ObjBase.inc"
                        
                        [/color][color=007F00]'These must be the globals
                        '    pMediaSession(NULL),
                        '    pMediaSource(NULL),
                        
                        '    m_hwndVideo(hVideo),
                        '    m_hwndEvent(hEvent),
                        '    m_state(%Closed),
                        '    m_hCloseEvent(NULL),
                        
                        '    pVideoDisplay(NULL),
                        '    m_nRefCount(1),
                        '    pCallback(NULL)
                        
                        [/color][color=0000C0]GLOBAL [/color][color=000000]m_hwndAudio        [/color][color=0000C0]AS LONG
                        GLOBAL [/color][color=000000]m_state            [/color][color=0000C0]AS LONG
                        GLOBAL [/color][color=000000]m_hCloseEvent      [/color][color=0000C0]AS LONG
                        GLOBAL [/color][color=000000]m_hwndVideo        [/color][color=0000C0]AS LONG
                        GLOBAL [/color][color=000000]m_hwndEvent        [/color][color=0000C0]AS LONG       [/color][color=007F00]'// App window to receive events.
                        [/color][color=0000C0]GLOBAL [/color][color=000000]m_nRefCount        [/color][color=0000C0]AS LONG
                        GLOBAL [/color][color=000000]m_PresentationTimeOffset [/color][color=0000C0]AS LONG
                        
                        GLOBAL [/color][color=000000]pMediaSession      [/color][color=0000C0]AS [/color][color=000000]IMFMediaSession
                        [/color][color=0000C0]GLOBAL [/color][color=000000]pMediaSource       [/color][color=0000C0]AS [/color][color=000000]IMFMediaSource
                        [/color][color=0000C0]GLOBAL [/color][color=000000]pPlayer            [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallbackImpl [/color][color=007F00]'MyInterface    'IMFAsyncCallbackImpl
                        [/color][color=0000C0]GLOBAL [/color][color=000000]pVideoDisplay      [/color][color=0000C0]AS [/color][color=000000]IMFVideoDisplayControl
                        [/color][color=0000C0]GLOBAL [/color][color=000000]pCallback          [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallback [/color][color=007F00]'IMFAsyncCallbackImpl   ' Object reference to the IMFAsyncCallback Interface
                        [/color][color=0000C0]GLOBAL [/color][color=000000]pConfiguration     [/color][color=0000C0]AS [/color][color=000000]IMFAttributes
                        
                        [/color][color=0000C0]GLOBAL [/color][color=000000]giHasStarted       [/color][color=0000C0]AS LONG   [/color][color=007F00]'tracks media foundation start and stop
                        
                        [/color][color=0000C0]GLOBAL [/color][color=000000]MFStatus           [/color][color=0000C0]AS STRING
                        GLOBAL [/color][color=000000]sURL               [/color][color=0000C0]AS ASCIIZ [/color][color=8000FF]* [/color][color=000000]255
                        [/color][color=0000C0]GLOBAL [/color][color=000000]TrackTitle         [/color][color=0000C0]AS STRING
                        GLOBAL [/color][color=000000]SessionStatus      [/color][color=0000C0]AS STRING
                        GLOBAL [/color][color=000000]SSMessages         [/color][color=0000C0]AS STRING
                        GLOBAL [/color][color=000000]SourceStatus       [/color][color=0000C0]AS STRING
                        GLOBAL [/color][color=000000]LastButton         [/color][color=0000C0]AS INTEGER
                        
                        GLOBAL [/color][color=000000]wsURL              [/color][color=0000C0]AS WSTRINGZ [/color][color=8000FF]* [/color][color=000000]255
                        [/color][color=007F00]'GLOBAL pwsURL             AS WSTRINGZ POINTER
                        
                        [/color][color=000000]$MyClassGuid [/color][color=8000FF]= [/color][color=0000C0]GUID$[/color][color=8000FF]([/color][color=C020C0]"{00000099-0000-0000-0000-000000000008}"[/color][color=8000FF])
                        [/color][color=000000]$MyIfaceGuid [/color][color=8000FF]= [/color][color=0000C0]GUID$[/color][color=8000FF]([/color][color=C020C0]"{00000099-0000-0000-0000-000000000009}"[/color][color=8000FF])
                        
                        [/color][color=0000C0]GLOBAL [/color][color=000000]hDlg    [/color][color=0000C0]AS DWORD
                        GLOBAL [/color][color=000000]DoPlay  [/color][color=0000C0]AS DWORD
                        
                        [/color][color=000000]%WM_APP_PLAYER_EVENT [/color][color=8000FF]= [/color][color=000000]1010
                        
                        %LabelMFStatus      [/color][color=8000FF]= [/color][color=000000]101
                        %LabelTrack         [/color][color=8000FF]= [/color][color=000000]102
                        %TextboxText        [/color][color=8000FF]= [/color][color=000000]103
                        
                        %ButtonPlay         [/color][color=8000FF]= [/color][color=000000]401
                        %ButtonPause        [/color][color=8000FF]= [/color][color=000000]402
                        %ButtonStop         [/color][color=8000FF]= [/color][color=000000]403
                        %ButtonExit         [/color][color=8000FF]= [/color][color=000000]404
                        
                        %ButtonMFStartUp    [/color][color=8000FF]= [/color][color=000000]405
                        %ButtonMFShutDown   [/color][color=8000FF]= [/color][color=000000]406
                        
                        %ButtonOpenSession  [/color][color=8000FF]= [/color][color=000000]407
                        %ButtonCloseSession [/color][color=8000FF]= [/color][color=000000]408
                        
                        %ButtonOpenSource   [/color][color=8000FF]= [/color][color=000000]409
                        %ButtonCloseSource  [/color][color=8000FF]= [/color][color=000000]410
                        
                        [/color][color=007F00]'%LabelFormat    = 102
                        '%LabelVolume    = 103
                        '%LabelText      = 105
                        '%ListboxVoice   = 201
                        
                        '%FrameVolume    = 601
                        '%FrameSpeed     = 602
                        '%ComboFormat    = 701
                        
                        'ENUM MF_OBJECT_TYPE
                           [/color][color=000000]%MF_OBJECT_MEDIASOURCE [/color][color=8000FF]= [/color][color=000000]0
                           %MF_OBJECT_BYTESTREAM  [/color][color=8000FF]= [/color][color=000000]1
                           %MF_OBJECT_INVALID     [/color][color=8000FF]= [/color][color=000000]2
                        [/color][color=007F00]'END ENUM
                        
                        [/color][color=0000C0]TYPE [/color][color=000000]MF_OBJECT_TYPE
                          ABC [/color][color=0000C0]AS INTEGER
                        END TYPE
                        
                        
                        ENUM [/color][color=000000]PlayerState [/color][color=0000C0]SINGULAR   [/color][color=007F00]'m_state values
                            [/color][color=000000]Closed [/color][color=8000FF]= [/color][color=000000]0     [/color][color=007F00]'// No session.
                            [/color][color=000000]Ready          [/color][color=007F00]'// Session was created, ready to open a file.
                            [/color][color=000000]OpenPending    [/color][color=007F00]'// Session is opening a file.
                            [/color][color=000000]Started        [/color][color=007F00]'// Session is playing a file.
                            [/color][color=000000]Paused         [/color][color=007F00]'// Session is paused.
                            [/color][color=000000]Stopped        [/color][color=007F00]'// Session is stopped (ready to play).
                            [/color][color=000000]Closing        [/color][color=007F00]'// Application has closed the session, but is waiting for MESessionClosed.
                        [/color][color=0000C0]END ENUM
                        
                        
                        FUNCTION [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=0000C0]BYREF [/color][color=000000]ppT [/color][color=0000C0]AS IUNKNOWN[/color][color=8000FF]) [/color][color=0000C0]AS LONG
                            IF ISOBJECT[/color][color=8000FF]([/color][color=000000]ppT[/color][color=8000FF]) [/color][color=0000C0]THEN
                                [/color][color=000000]ppT.Release
                                ppT [/color][color=8000FF]= [/color][color=0000C0]NOTHING
                            END IF
                        END FUNCTION
                        
                        DECLARE FUNCTION [/color][color=000000]PathFileExists [/color][color=0000C0]LIB [/color][color=C020C0]"SHLWAPI.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"PathFileExistsA"[/color][color=8000FF]([/color][color=0000C0]BYREF [/color][color=000000]pszPath [/color][color=0000C0]AS ASCIIZ[/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                        DECLARE FUNCTION [/color][color=000000]SetEvent [/color][color=0000C0]IMPORT [/color][color=C020C0]"KERNEL32.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"SetEvent" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYVAL [/color][color=000000]hEvent [/color][color=0000C0]AS DWORD _                              [/color][color=007F00]' __in HANDLE hEvent
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' BOOL
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]MFStartup [/color][color=0000C0]IMPORT [/color][color=C020C0]"MFPLAT.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"MFStartup" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYVAL [/color][color=000000]Version [/color][color=0000C0]AS DWORD _                             [/color][color=007F00]' __in ULONG Version
                         [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                             [/color][color=007F00]' __in DWORD dwFlags
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' HRESULT
                        
                        '______________________________________________________________________________
                        
                        [/color][color=0000C0]CALLBACK FUNCTION [/color][color=000000]DlgProc
                         [/color][color=0000C0]STATIC [/color][color=000000]hControlFocus [/color][color=0000C0]AS DWORD
                        
                         SELECT CASE CBMSG
                        
                           CASE %WM_INITDIALOG
                             [/color][color=000000]SetFocus GetDlgItem[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonExit[/color][color=8000FF])
                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonExit
                        
                           [/color][color=0000C0]CASE %WM_COMMAND
                             SELECT CASE LOWRD[/color][color=8000FF]([/color][color=0000C0]CBWPARAM[/color][color=8000FF])
                        
                               [/color][color=0000C0]CASE [/color][color=000000]%WM_APP_PLAYER_EVENT
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     ? [/color][color=C020C0]"A player event was sent"
                                 [/color][color=0000C0]END IF
                        
                               CASE [/color][color=000000]%ButtonPlay
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         IF [/color][color=8000FF]([/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]0 [/color][color=8000FF]OR [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]2[/color][color=8000FF]) [/color][color=0000C0]THEN
                                             [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]1
                                             [/color][color=007F00]'StartPlaying
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF], [/color][color=000000]%ButtonStop[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonStop
                                         [/color][color=0000C0]ELSE
                                             CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                        
                                         [/color][color=0000C0]END IF
                                     ELSE
                                         CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                        
                                     [/color][color=0000C0]END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonPause
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonPause[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         IF [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                             [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]2
                                             [/color][color=007F00]'PausePlaying
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]END IF
                                     ELSE
                                         CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                        
                                     [/color][color=0000C0]END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonStop
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonStop[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                                        [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]0
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                         [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=0000C0]THEN
                                             CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]END IF
                                     ELSE
                                         CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                         [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                        
                                     [/color][color=0000C0]END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonExit
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonExit[/color][color=8000FF])
                        
                                     [/color][color=0000C0]DIALOG END [/color][color=000000]hDlg
                                 [/color][color=0000C0]END IF
                        
                               CASE [/color][color=000000]%ButtonMFStartUp
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]0 [/color][color=0000C0]THEN
                                         CALL [/color][color=000000]pPlayer.Initialize[/color][color=8000FF]()
                                         [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                             CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession
                                             [/color][color=0000C0]IF [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                                                [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed." [/color][color=0000C0]THEN
                                                 CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                                 SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF])
                                                 [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]END IF
                                         END IF
                                     END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonMFShutDown
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         CALL [/color][color=000000]pPlayer.Shutdown[/color][color=8000FF]()
                                         [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]0 [/color][color=0000C0]THEN
                                             CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource
                                             SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed."
                                             [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonMFStartUp
                                         [/color][color=0000C0]END IF
                                     END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonOpenSession
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed." [/color][color=0000C0]THEN
                                             [/color][color=007F00]'open session
                                             [/color][color=0000C0]CALL [/color][color=000000]pPlayer.OpenSession[/color][color=8000FF]()
                                             [/color][color=007F00]'SessionStatus = "Media Session is open."
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             DoPlay [/color][color=8000FF]= [/color][color=000000]0
                        
                                             [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=8000FF]AND [/color][color=0000C0]_
                                                [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                                                [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"No Source created." [/color][color=0000C0]THEN
                                                 CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                                 [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                                 SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF])
                                                 [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonOpenSource
                                             [/color][color=0000C0]END IF
                                         END IF
                        
                                     END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonCloseSession
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                         IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=0000C0]THEN
                                             [/color][color=007F00]'close session
                                             [/color][color=0000C0]CALL [/color][color=000000]pPlayer.CloseSession[/color][color=8000FF]()
                                             [/color][color=007F00]'SessionStatus = "Media Session is closed."
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonOpenSession
                                         [/color][color=0000C0]END IF
                        
                                     END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonOpenSource
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=8000FF]AND [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=0000C0]THEN
                                         IF [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"No Source created." [/color][color=0000C0]THEN
                        
                                             CALL [/color][color=000000]pPlayer.OpenMyMediaSource[/color][color=8000FF]([/color][color=000000]wsURL[/color][color=8000FF], [/color][color=000000]pMediaSource[/color][color=8000FF])  [/color][color=007F00]'pwsURL
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonCloseSource
                                         [/color][color=0000C0]END IF
                                     END IF
                                 END IF
                        
                               CASE [/color][color=000000]%ButtonCloseSource
                                 [/color][color=0000C0]IF CBCTLMSG [/color][color=8000FF]= [/color][color=0000C0]%BN_CLICKED [/color][color=8000FF]OR [/color][color=0000C0]CBCTLMSG [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                     [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]LastButton[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource[/color][color=8000FF])
                        
                                     [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=8000FF]AND [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=0000C0]THEN
                                         IF [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"The Media Source was created." [/color][color=0000C0]THEN
                        
                                             CALL [/color][color=000000]pPlayer.CloseMediaSource[/color][color=8000FF]()
                        
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                             [/color][color=0000C0]CONTROL DISABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource
                                             [/color][color=0000C0]CONTROL ENABLE [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource
                                             SetButtonFocus[/color][color=8000FF]([/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF])
                                             [/color][color=000000]LastButton [/color][color=8000FF]= [/color][color=000000]%ButtonOpenSource
                                         [/color][color=0000C0]END IF
                                     END IF
                                 END IF
                        
                        
                             END SELECT
                        
                           CASE %WM_NCACTIVATE
                             IF CBWPARAM THEN
                               IF [/color][color=000000]hControlFocus [/color][color=0000C0]THEN
                                 [/color][color=000000]SetFocus[/color][color=8000FF]([/color][color=000000]hControlFocus[/color][color=8000FF])
                                 [/color][color=000000]hControlFocus [/color][color=8000FF]= [/color][color=000000]0
                               [/color][color=0000C0]END IF
                             ELSE
                               [/color][color=000000]hControlFocus [/color][color=8000FF]= [/color][color=000000]GetFocus[/color][color=8000FF]()
                             [/color][color=0000C0]END IF
                        
                          END SELECT
                        
                        END FUNCTION
                        [/color][color=007F00]'______________________________________________________________________________
                        
                        [/color][color=0000C0]FUNCTION PBMAIN [/color][color=8000FF]() [/color][color=0000C0]AS LONG
                        
                          DIALOG FONT [/color][color=C020C0]"Segoe UI"[/color][color=8000FF], [/color][color=000000]9
                          [/color][color=0000C0]DIALOG NEW %HWND_DESKTOP[/color][color=8000FF], [/color][color=000000]ExeName2[/color][color=8000FF]([/color][color=000000]6[/color][color=8000FF]), , , [/color][color=000000]312[/color][color=8000FF], [/color][color=000000]336[/color][color=8000FF], [/color][color=0000C0]_
                          %WS_CAPTION [/color][color=8000FF]OR [/color][color=0000C0]%WS_MINIMIZEBOX [/color][color=8000FF]OR [/color][color=0000C0]%WS_SYSMENU[/color][color=8000FF], [/color][color=000000]0 [/color][color=0000C0]TO [/color][color=000000]hDlg
                        
                          SetClassLong hDlg[/color][color=8000FF], [/color][color=000000]%GCL_HICON[/color][color=8000FF], [/color][color=000000]ExtractIcon[/color][color=8000FF]([/color][color=000000]GetModuleHandle[/color][color=8000FF]([/color][color=C020C0]""[/color][color=8000FF]), [/color][color=C020C0]"%SystemRoot%\system32\wpdshext.dll"[/color][color=8000FF], [/color][color=000000]6[/color][color=8000FF])
                        
                          [/color][color=000000]MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation is closed."
                          [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed."
                          [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"No Source created."
                        
                          [/color][color=007F00]'local CPlayer as pPlayer iunknown
                          [/color][color=000000]pPlayer     [/color][color=8000FF]= [/color][color=0000C0]CLASS [/color][color=C020C0]"CPlayer"
                          [/color][color=000000]pCallback   [/color][color=8000FF]= [/color][color=0000C0]CLASS [/color][color=C020C0]"CMFAsyncCallback"           [/color][color=007F00]' Create an instance of the CPlayer object
                        
                          '//////// Change this info to match your music library /////////
                          [/color][color=000000]sURL [/color][color=8000FF]= [/color][color=C020C0]"C:\Users\Public\Music\Aaron Tippin\Greatest Hits...and Then Some\01 Cold Gray Kentucky Morning.wma"
                          [/color][color=007F00]'sURL = "C:\Users\Public\Music\Billy Idol\The Very Best of Billy Idol\05 Eyes Without a Face.mp3"
                          'sURL = "C:\Users\Public\Music\Afterlife & Cathy Battistessa\Speck of Gold\01 Speck of Gold.m4a"
                        
                          [/color][color=000000]TrackTitle [/color][color=8000FF]= [/color][color=C020C0]"----- Track Not Found -----"
                        
                          [/color][color=0000C0]IF [/color][color=000000]FileExists[/color][color=8000FF]([/color][color=000000]sURL[/color][color=8000FF]) [/color][color=0000C0]THEN
                              [/color][color=000000]TrackTitle [/color][color=8000FF]= [/color][color=000000]FileNam[/color][color=8000FF]([/color][color=000000]sURL[/color][color=8000FF])
                        
                              [/color][color=000000]wsURL [/color][color=8000FF]= [/color][color=000000]sURL [/color][color=8000FF]+ [/color][color=0000C0]$NUL
                              [/color][color=007F00]'? "]" + wsURL + "["
                              'pwsURL = VARPTR(wsURL)
                              'OpenURL(BYVAL pwsURL)
                          [/color][color=0000C0]END IF
                        
                          CONTROL ADD LABEL[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%LabelMFStatus[/color][color=8000FF], [/color][color=C020C0]"Audio Track Name:"[/color][color=8000FF], [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]120[/color][color=8000FF], [/color][color=000000]10
                          [/color][color=0000C0]CONTROL ADD LABEL[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%LabelTrack[/color][color=8000FF], [/color][color=000000]TrackTitle[/color][color=8000FF], [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=000000]120[/color][color=8000FF], [/color][color=000000]10
                        
                          [/color][color=0000C0]CONTROL ADD TEXTBOX[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages[/color][color=8000FF], [/color][color=0000C0]_
                          [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]35[/color][color=8000FF], [/color][color=000000]220[/color][color=8000FF], [/color][color=000000]200[/color][color=8000FF], [/color][color=0000C0]_
                          %WS_CHILD [/color][color=8000FF]OR [/color][color=0000C0]%WS_VISIBLE [/color][color=8000FF]OR [/color][color=0000C0]%ES_AUTOHSCROLL [/color][color=8000FF]OR [/color][color=0000C0]%WS_VSCROLL [/color][color=8000FF]OR [/color][color=0000C0]_
                          %ES_NOHIDESEL [/color][color=8000FF]OR [/color][color=0000C0]%ES_READONLY [/color][color=8000FF]OR [/color][color=0000C0]%ES_MULTILINE [/color][color=8000FF]OR [/color][color=0000C0]%WS_BORDER
                        
                        
                          CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFStartUp[/color][color=8000FF], [/color][color=C020C0]"MF StartUp"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]10[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonMFShutDown[/color][color=8000FF], [/color][color=C020C0]"MF ShutDown"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]30[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_TABSTOP
                        
                          IF [/color][color=000000]TrackTitle [/color][color=8000FF]= [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]OR [/color][color=0000C0]_
                             [/color][color=000000]MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation is closed." [/color][color=0000C0]THEN
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF], [/color][color=C020C0]"Open Session"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]50[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession[/color][color=8000FF], [/color][color=C020C0]"Close Session"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]70[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          ELSE
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSession[/color][color=8000FF], [/color][color=C020C0]"Open Session"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]50[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_TABSTOP
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSession[/color][color=8000FF], [/color][color=C020C0]"Close Session"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]70[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          END IF
                        
                          IF [/color][color=000000]TrackTitle [/color][color=8000FF]= [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]OR [/color][color=0000C0]_
                             [/color][color=000000]MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation is closed." [/color][color=8000FF]OR [/color][color=0000C0]_
                             [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed." [/color][color=0000C0]THEN
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF], [/color][color=C020C0]"Open Source"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]90[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource[/color][color=8000FF], [/color][color=C020C0]"Close Source"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]110[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          ELSE
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonOpenSource[/color][color=8000FF], [/color][color=C020C0]"Open Source"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]90[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_TABSTOP
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonCloseSource[/color][color=8000FF], [/color][color=C020C0]"Close Source"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]110[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          END IF
                        
                        
                        
                          IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=8000FF]AND [/color][color=0000C0]_
                             [/color][color=000000]DoPlay [/color][color=8000FF]= [/color][color=000000]0 [/color][color=8000FF]AND [/color][color=0000C0]_
                             [/color][color=000000]TrackTitle [/color][color=8000FF]<> [/color][color=C020C0]"----- Track Not Found -----" [/color][color=8000FF]AND [/color][color=0000C0]_
                             [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF], [/color][color=C020C0]"Play"[/color][color=8000FF], [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]318[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_TABSTOP
                          ELSE
                              CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPlay[/color][color=8000FF], [/color][color=C020C0]"Play"[/color][color=8000FF], [/color][color=000000]5[/color][color=8000FF], [/color][color=000000]318[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                          END IF
                        
                          CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonPause[/color][color=8000FF], [/color][color=C020C0]"Pause"[/color][color=8000FF], [/color][color=000000]82[/color][color=8000FF], [/color][color=000000]318[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                        
                          CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonStop[/color][color=8000FF], [/color][color=C020C0]"Stop"[/color][color=8000FF], [/color][color=000000]159[/color][color=8000FF], [/color][color=000000]318[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_DISABLED [/color][color=8000FF]OR [/color][color=0000C0]%WS_TABSTOP
                        
                          CONTROL ADD BUTTON[/color][color=8000FF], [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%ButtonExit[/color][color=8000FF], [/color][color=C020C0]"Exit"[/color][color=8000FF], [/color][color=000000]236[/color][color=8000FF], [/color][color=000000]318[/color][color=8000FF], [/color][color=000000]72[/color][color=8000FF], [/color][color=000000]15[/color][color=8000FF], [/color][color=0000C0]%WS_TABSTOP
                        
                          DIALOG SHOW MODAL [/color][color=000000]hDlg [/color][color=0000C0]CALL [/color][color=000000]DlgProc
                        
                        [/color][color=0000C0]END FUNCTION
                        
                        [/color][color=007F00]'///////////////////////////////////////////////////////////////////////////
                        '// FUNCTIONS SECTION
                        '///////////////////////////////////////////////////////////////////////////
                        
                        '______________________________________________________________________________
                        
                        [/color][color=0000C0]FUNCTION [/color][color=000000]ExeName2[/color][color=8000FF]([/color][color=000000]Action [/color][color=0000C0]AS LONG[/color][color=8000FF]) [/color][color=0000C0]AS STRING [/color][color=007F00]'Return the ExeName of this APP or ExeName of calling app if DLL
                         [/color][color=0000C0]LOCAL [/color][color=000000]zFileName   [/color][color=0000C0]AS ASCIIZ [/color][color=8000FF]* [/color][color=0000C0]%MAX_PATH
                         LOCAL [/color][color=000000]PathFileLen [/color][color=0000C0]AS LONG
                         LOCAL [/color][color=000000]FileExtLen  [/color][color=0000C0]AS LONG
                         LOCAL [/color][color=000000]DotPos      [/color][color=0000C0]AS LONG
                         LOCAL [/color][color=000000]SlashPos    [/color][color=0000C0]AS LONG
                        
                         [/color][color=000000]PathFileLen [/color][color=8000FF]= [/color][color=000000]GetModuleFileName[/color][color=8000FF]([/color][color=000000]0[/color][color=8000FF], [/color][color=000000]zFileName[/color][color=8000FF], [/color][color=0000C0]%MAX_PATH[/color][color=8000FF])
                         [/color][color=000000]SlashPos [/color][color=8000FF]= [/color][color=0000C0]INSTR[/color][color=8000FF](-[/color][color=000000]1[/color][color=8000FF], [/color][color=000000]zFileName[/color][color=8000FF], [/color][color=C020C0]"\"[/color][color=8000FF])
                         [/color][color=000000]DotPos [/color][color=8000FF]= [/color][color=0000C0]INSTR[/color][color=8000FF](-[/color][color=000000]1[/color][color=8000FF], [/color][color=000000]zFileName[/color][color=8000FF], [/color][color=C020C0]"."[/color][color=8000FF])
                         [/color][color=0000C0]IF [/color][color=000000]DotPos [/color][color=8000FF]< [/color][color=000000]SlashPos [/color][color=0000C0]THEN [/color][color=000000]DotPos [/color][color=8000FF]= [/color][color=000000]0
                         FileExtLen [/color][color=8000FF]= [/color][color=000000]PathFileLen [/color][color=8000FF]- [/color][color=000000]SlashPos
                        
                         [/color][color=0000C0]SELECT CASE [/color][color=000000]Action
                        
                           [/color][color=0000C0]CASE [/color][color=000000]1 [/color][color=007F00]'C: - Drive
                             [/color][color=0000C0]IF ASC[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]2[/color][color=8000FF]) = [/color][color=000000]58 [/color][color=0000C0]THEN [/color][color=007F00]'X: 58
                               [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]LEFT$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]2[/color][color=8000FF])
                             [/color][color=0000C0]END IF
                        
                           CASE [/color][color=000000]2 [/color][color=007F00]'C:\Subdir\ - Drive and Path (Including last backslash)
                             [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]LEFT$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]SlashPos[/color][color=8000FF])
                        
                           [/color][color=0000C0]CASE [/color][color=000000]3 [/color][color=007F00]'\Subdir\ - Path (Including first and last backslash)
                             [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]3[/color][color=8000FF], [/color][color=000000]SlashPos [/color][color=8000FF]- [/color][color=000000]2[/color][color=8000FF])
                        
                           [/color][color=0000C0]CASE [/color][color=000000]4 [/color][color=007F00]'C:\Subdir\File - Drive, Path and Filename (No Extention, Dot excluded)
                             [/color][color=0000C0]IF [/color][color=000000]DotPos [/color][color=0000C0]THEN
                               FUNCTION [/color][color=8000FF]= [/color][color=0000C0]LEFT$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]DotPos [/color][color=8000FF]- [/color][color=000000]1[/color][color=8000FF])
                             [/color][color=0000C0]ELSE
                               FUNCTION [/color][color=8000FF]= [/color][color=0000C0]LEFT$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]PathFileLen[/color][color=8000FF])
                             [/color][color=0000C0]END IF
                        
                           CASE [/color][color=000000]5 [/color][color=007F00]'C:\Subdir\File.Exe - Path, Filename and Extention
                             [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]LEFT$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]PathFileLen[/color][color=8000FF])
                        
                           [/color][color=0000C0]CASE [/color][color=000000]6 [/color][color=007F00]'File - Filename (No Extention)
                             [/color][color=0000C0]IF [/color][color=000000]DotPos [/color][color=0000C0]THEN
                               FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]SlashPos [/color][color=8000FF]+ [/color][color=000000]1[/color][color=8000FF], [/color][color=000000]FileExtLen [/color][color=8000FF]- ([/color][color=000000]PathFileLen [/color][color=8000FF]- [/color][color=000000]DotPos[/color][color=8000FF]) - [/color][color=000000]1[/color][color=8000FF])
                             [/color][color=0000C0]ELSE
                               FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]SlashPos [/color][color=8000FF]+ [/color][color=000000]1[/color][color=8000FF], [/color][color=000000]FileExtLen[/color][color=8000FF])
                             [/color][color=0000C0]END IF
                        
                           CASE [/color][color=000000]7 [/color][color=007F00]'File.Exe - Filename and Extention
                             [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]SlashPos [/color][color=8000FF]+ [/color][color=000000]1[/color][color=8000FF], [/color][color=000000]FileExtLen[/color][color=8000FF])
                        
                           [/color][color=0000C0]CASE [/color][color=000000]8 [/color][color=007F00]'.Exe - Extention (Including Dot)
                             [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]zFileName[/color][color=8000FF], [/color][color=000000]DotPos[/color][color=8000FF])
                        
                         [/color][color=0000C0]END SELECT
                        
                        END FUNCTION
                        [/color][color=007F00]'______________________________________________________________________________
                        
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]MFCreateSourceResolver [/color][color=0000C0]IMPORT [/color][color=C020C0]"mf.dll" [/color][color=0000C0]ALIAS [/color][color=C020C0]"MFCreateSourceResolver" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYREF [/color][color=000000]ppISourceResolver [/color][color=0000C0]AS [/color][color=000000]IMFSourceResolver [/color][color=0000C0]_       [/color][color=007F00]' __out IMFSourceResolver **ppISourceResolver
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' HRESULT
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]CoInitializeEx [/color][color=0000C0]IMPORT [/color][color=C020C0]"OLE32.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"CoInitializeEx" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYVAL [/color][color=000000]pvReserved [/color][color=0000C0]AS DWORD _                          [/color][color=007F00]' __in void * pvReserved
                         [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwCoInit [/color][color=0000C0]AS DWORD _                            [/color][color=007F00]' __in DWORD dwCoInit
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' HRESULT
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]CoInitialize [/color][color=0000C0]IMPORT [/color][color=C020C0]"OLE32.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"CoInitialize" [/color][color=8000FF]( [/color][color=0000C0]_
                           OPTIONAL BYVAL [/color][color=000000]pvReserved [/color][color=0000C0]AS DWORD _                 [/color][color=007F00]' __in LPVOID pvReserved
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' HRESULT
                        
                        [/color][color=0000C0]DECLARE SUB [/color][color=000000]CoUninitialize [/color][color=0000C0]IMPORT [/color][color=C020C0]"OLE32.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"CoUninitialize" [/color][color=8000FF]()   [/color][color=007F00]' void
                        
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]MFCreateMediaEvent [/color][color=0000C0]IMPORT [/color][color=C020C0]"MFPLAT.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"MFCreateMediaEvent" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYVAL [/color][color=000000]met [/color][color=0000C0]AS DWORD _                                 [/color][color=007F00]' __in  MediaEventType met
                         [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]guidExtendedType [/color][color=0000C0]AS GUID _                     [/color][color=007F00]' __in  REFGUID guidExtendedType
                         [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hrStatus [/color][color=0000C0]AS LONG _                             [/color][color=007F00]' __in  HRESULT hrStatus
                         [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pvValue [/color][color=0000C0]AS ANY _                               [/color][color=007F00]' __in  const PROPVARIANT* pvValue
                         [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_                     [/color][color=007F00]' __out IMFMediaEvent ** ppEvent
                         [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                              [/color][color=007F00]' HRESULT
                        
                        
                        [/color][color=0000C0]DECLARE FUNCTION [/color][color=000000]CreateEventW [/color][color=0000C0]IMPORT [/color][color=C020C0]"KERNEL32.DLL" [/color][color=0000C0]ALIAS [/color][color=C020C0]"CreateEventW" [/color][color=8000FF]( [/color][color=0000C0]_
                           BYREF [/color][color=000000]lpEventAttributes [/color][color=0000C0]AS [/color][color=000000]SECURITY_ATTRIBUTES [/color][color=0000C0]_     [/color][color=007F00]' __in LPSECURITY_ATTRIBUTES lpEventAttributes
                         [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]bManualReset [/color][color=0000C0]AS LONG _                         [/color][color=007F00]' __in BOOL bManualReset
                         [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]bInitialState [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __in BOOL bInitialState
                         [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]lpName [/color][color=0000C0]AS WSTRINGZ _                           [/color][color=007F00]' __in LPCWSTR lpName
                         [/color][color=8000FF]) [/color][color=0000C0]AS DWORD                                             [/color][color=007F00]' HANDLE
                        
                        
                        
                        
                        
                        'CLASS MyClass $MyClassGuid AS COM
                        '    INTERFACE MyInterface $MyIfaceGuid
                        '        INHERIT IAutomation
                        '        METHOD Method1(parm AS LONG)
                        '            CALL abc(parm)
                        '        END METHOD
                        '    END INTERFACE
                        'END CLASS
                        
                        
                        '///////////////////////////////////////////////////////////////////////////
                        '// CLASS SECTION
                        '///////////////////////////////////////////////////////////////////////////
                        
                        [/color][color=0000C0]CLASS [/color][color=000000]CPLayer $MyClassGuid [/color][color=0000C0]AS COM
                        
                            CLASS METHOD CREATE[/color][color=8000FF]()  [/color][color=007F00]'Initialize() AS LONG                         'CPlayer method
                                [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]0 [/color][color=0000C0]THEN
                                    LOCAL [/color][color=000000]pvReserved [/color][color=0000C0]AS DWORD
                                    LOCAL [/color][color=000000]lpEventAttributes [/color][color=0000C0]AS [/color][color=000000]SECURITY_ATTRIBUTES
                                    [/color][color=0000C0]LOCAL [/color][color=000000]bManualReset [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]bInitialState [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]lpName [/color][color=0000C0]AS WSTRINGZ [/color][color=8000FF]* [/color][color=000000]255
                        
                                    [/color][color=007F00]' Do initialization
                                    'MFStartup
                                    '   BYVAL Version AS DWORD _                             ' __in ULONG Version
                                    ' , BYVAL dwFlags AS DWORD _                             ' __in DWORD dwFlags
                        
                                    '// Start up Media Foundation platform.
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                        
                                    [/color][color=007F00]'// initialize COM
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]CoInitializeEx[/color][color=8000FF]([/color][color=000000]pvReserved[/color][color=8000FF], [/color][color=000000]%COINIT_APARTMENTTHREADED[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation was closed."
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=C020C0]"The COM libraries were not enabled."
                                        [/color][color=0000C0]GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFStartup[/color][color=8000FF]([/color][color=000000]%MF_API_VERSION[/color][color=8000FF], [/color][color=000000]0[/color][color=8000FF])     [/color][color=007F00]' %MF_VERSION ' %MF_API_VERSION, 0 = full MF
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// create an event that will be fired when the asynchronous IMFMediaSession::Close()
                                        '// operation is complete
                                        [/color][color=000000]m_hCloseEvent [/color][color=8000FF]= [/color][color=000000]CreateEventW[/color][color=8000FF]([/color][color=000000]lpEventAttributes[/color][color=8000FF], [/color][color=000000]%FALSE[/color][color=8000FF], [/color][color=000000]%FALSE[/color][color=8000FF], [/color][color=000000]lpName[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]m_hCloseEvent [/color][color=8000FF]= [/color][color=000000]%NULL [/color][color=0000C0]THEN
                                            [/color][color=007F00]'BREAK_ON_NULL(m_hCloseEvent, %E_UNEXPECTED)
                                            [/color][color=000000]m_hCloseEvent [/color][color=8000FF]= [/color][color=0000C0]%E_UNEXPECTED
                                            ? [/color][color=C020C0]"here ?"
                                            [/color][color=0000C0]GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                        
                                        [/color][color=007F00]'m_hCloseEvent = CreateEventW(%NULL, %FALSE, %FALSE, %NULL)
                                        'IF (m_hCloseEvent = %NULL) THEN
                                        '    hr = HRESULT_FROM_WIN32(GetLastError())
                                        'END IF
                                        [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1
                                        MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation was opened."
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=000000]MFStatus [/color][color=8000FF]+ [/color][color=0000C0]$CRLF
                                        CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                    [/color][color=0000C0]END IF
                                END IF
                            [/color][color=000000]done[/color][color=8000FF]:
                            [/color][color=0000C0]END METHOD
                        
                            [/color][color=007F00]'//  Release all resources held by this object.
                            [/color][color=0000C0]CLASS METHOD DESTROY[/color][color=8000FF]() [/color][color=007F00]'AS LONG 'Shutdown() AS LONG            'cplayer method
                                [/color][color=0000C0]IF [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]1 [/color][color=0000C0]THEN
                                    [/color][color=007F00]' Do Cleanup
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                        
                                    [/color][color=007F00]'// Close the session
                                    [/color][color=0000C0]IF [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open." [/color][color=0000C0]THEN
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.CloseSession[/color][color=8000FF]()
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Shutdown the Media Foundation platform
                                    [/color][color=000000]MFShutdown[/color][color=8000FF]()
                        
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]m_hCloseEvent[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]CloseHandle[/color][color=8000FF]([/color][color=000000]m_hCloseEvent[/color][color=8000FF])
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]giHasStarted [/color][color=8000FF]= [/color][color=000000]0
                                    MFStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Foundation was closed."
                                    [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=000000]MFStatus [/color][color=8000FF]+ [/color][color=0000C0]$CRLF
                                    CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                        
                                    [/color][color=0000C0]CALL [/color][color=000000]CoUninitialize  [/color][color=007F00]'removes COM libraries
                                [/color][color=0000C0]END IF
                            END METHOD
                        
                        
                        
                            INTERFACE  [/color][color=000000]IMFAsyncCallbackImpl [/color][color=007F00]'MyInterface $MyIfaceGuid  'IMFAsyncCallbackImpl
                                [/color][color=0000C0]INHERIT IUNKNOWN [/color][color=007F00]'IDISPATCH
                        
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]Initialize[/color][color=8000FF]() [/color][color=0000C0]AS LONG                         [/color][color=007F00]'CPlayer method
                                    [/color][color=000000]ME.Create[/color][color=8000FF]()
                                [/color][color=0000C0]END METHOD
                        
                                METHOD [/color][color=000000]Shutdown[/color][color=8000FF]() [/color][color=0000C0]AS LONG                           [/color][color=007F00]'CPlayer method
                                    '// If FALSE, the app did not call Shutdown().
                        
                                    '// When CPlayer calls IMediaEventGenerator::BeginGetEvent on the
                                    '// media session, it causes the media session to hold a reference
                                    '// count on the CPlayer.
                        
                                    '// This creates a circular reference count between CPlayer and the
                                    '// media session. Calling Shutdown breaks the circular reference
                                    '// count.
                        
                                    '// If CreateInstance fails, the application will not call
                                    '// Shutdown. To handle that case, call Shutdown in the destructor.
                        
                                    [/color][color=000000]ME.Destroy[/color][color=8000FF]()
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'//  Close the media source.
                                [/color][color=0000C0]METHOD [/color][color=000000]CloseMediaSource[/color][color=8000FF]() [/color][color=0000C0]AS LONG
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF])
                                    [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"No Source created."
                                    [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=000000]SourceStatus [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                    [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                        
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'////////////////////////////////////////////////
                                ' ORIGINAL VARIABLES
                                '  PCWSTR pszURL _
                                ', IMFMediaSource **ppSource _
                                '////////////////////////////////////////////////
                                '//  Create a media source from a URL.
                                [/color][color=0000C0]METHOD [/color][color=000000]OpenMyMediaSource[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pszUrl [/color][color=0000C0]AS WSTRINGZ [/color][color=8000FF]* [/color][color=000000]255 [/color][color=0000C0]_                   [/color][color=007F00]' __in LPCWSTR pszUrl
                                   [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppMediaSource [/color][color=0000C0]AS [/color][color=000000]IMFMediaSource [/color][color=0000C0]_            [/color][color=007F00]' __out IMFMediaSource **ppMediaSource
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr               [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]pObjectType      [/color][color=0000C0]AS LONG  [/color][color=007F00]'MF_OBJECT_TYPE
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pSourceResolver  [/color][color=0000C0]AS [/color][color=000000]IMFSourceResolver
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pProps           [/color][color=0000C0]AS [/color][color=000000]IPropertyStore
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pSource          [/color][color=0000C0]AS IUNKNOWN
                        
                                    [/color][color=007F00]'MF_OBJECT_TYPE ObjectType = %MF_OBJECT_INVALID
                                    'IMFSourceResolver* pSourceResolver = NOTHING
                                    'IUNKNOWN* pSource = NOTHING
                        
                                    '? pszUrl
                        
                                    'I have tried BeginCreateObjectFromURL to no avail
                        
                                    [/color][color=000000]pObjectType [/color][color=8000FF]= [/color][color=000000]%MF_OBJECT_INVALID
                        
                                    [/color][color=007F00]'// Create the source resolver.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateSourceResolver[/color][color=8000FF]([/color][color=000000]pSourceResolver[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                    ? [/color][color=C020C0]"The Source Resolver was created."
                        
                                    [/color][color=007F00]'// Use the source resolver to create the media source.
                        
                                    '// Note: For simplicity this sample uses the synchronous method to create
                                    '// the media source. However, creating a media source can take a noticeable
                                    '// amount of time, especially for a network source. For a more responsive
                                    '// UI, use the asynchronous BeginCreateObjectFromURL method.
                        
                                    ' ' =====================================================================================
                                    ' METHOD CreateObjectFromURL ( _                       ' VTable offset = 12
                                    '   BYREF pwszURL AS WSTRINGZ _                        ' __in LPCWSTR pwszURL
                                    ' , BYVAL dwFlags AS DWORD _                           ' __in DWORD dwFlags
                                    ' , BYVAL pProps AS IPropertyStore _                   ' __in IPropertyStore *pProps
                                    ' , BYVAL pObjectType AS LONG _                        ' __out MF_OBJECT_TYPE *pObjectType
                                    ' , BYREF ppObject AS IUnknown _                       ' __out IUnknown **ppObject
                                    ' ) AS LONG                                            ' HRESULT
                                    ' ' =====================================================================================
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pSourceResolver.CreateObjectFromURL[/color][color=8000FF]( [/color][color=0000C0]_
                                         [/color][color=000000]pszUrl [/color][color=0000C0]_                     [/color][color=007F00]'// URL of the source.  Null-terminated string that contains the URL to resolve
                                       [/color][color=8000FF], [/color][color=000000]%MF_RESOLUTION_MEDIASOURCE [/color][color=0000C0]_ [/color][color=007F00]'// Create a source object.
                                       [/color][color=8000FF], [/color][color=000000]pProps [/color][color=0000C0]_                     [/color][color=007F00]'// Optional property store.
                                       [/color][color=8000FF], [/color][color=000000]pObjectType [/color][color=0000C0]_                [/color][color=007F00]'// Receives the created object type.
                                       [/color][color=8000FF], [/color][color=000000]pSource [/color][color=0000C0]_                    [/color][color=007F00]'// Receives a pointer to the media source.
                                       [/color][color=8000FF])
                        
                                    [/color][color=007F00]'///////////////////////////////////
                                    '////////  NEVER GETS HERE  ////////
                                    '///////////////////////////////////
                        
                                    [/color][color=0000C0]? [/color][color=C020C0]"The media source may have been created."
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Get the IMFMediaSource interface from the media source.
                                    'hr = pSource.QueryInterface(IID_PPV_ARGS(ppMediaSource))
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pSource[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]ppMediaSource [/color][color=8000FF]= [/color][color=000000]pSource
                                    [/color][color=0000C0]END IF
                                    [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"The Media Source was created."
                                    [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=000000]SourceStatus [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                    [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                        
                                done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pProps[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSourceResolver[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSource[/color][color=8000FF])
                        
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'///////////////////////////////////////////////////////////////////////////
                                ' ORIGINAL VARIABLES
                                '     IMFTopology *pTopology _    '// Topology.
                                '   , IMFActivate *pActivate _    '// Media sink activation object.    DOES NOT MATCH
                                '   , BYVAL dwId AS DWORD _       '// Identifier of the stream sink.   DOES NOT MATCH
                                '   , IMFTopologyNode **ppNode _  '// Receives the node pointer.
                                '///////////////////////////////////////////////////////////////////////////
                                '// Add an output node to a topology.
                                [/color][color=0000C0]METHOD [/color][color=000000]AddOutputNode[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology [/color][color=0000C0]_                   [/color][color=007F00]' __in IMFTopology *pTopology           '// Topology.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pActivate [/color][color=0000C0]AS [/color][color=000000]IMFActivate [/color][color=0000C0]_   [/color][color=007F00]DNM in not out  ' __out IMFActivate **ppEnablerActivate '// Media sink activation object.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwId [/color][color=0000C0]AS DWORD _                        [/color][color=007F00]DNM   ' __in MFSequencerElementId dwId        '// Identifier of the stream sink.
                                   [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode [/color][color=0000C0]_                  [/color][color=007F00]' __out IMFTopologyNode **ppNode        '// Receives the node pointer.
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode
                                    [/color][color=007F00]'IMFTopologyNode *pNode = NOTHING
                        
                                    '// Create the node.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateTopologyNode[/color][color=8000FF]([/color][color=000000]%MF_TOPOLOGY_OUTPUT_NODE[/color][color=8000FF], [/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Set the object pointer.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetObject[/color][color=8000FF]([/color][color=000000]pActivate[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Set the stream sink ID attribute.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetUINT32[/color][color=8000FF]([/color][color=000000]$MF_TOPONODE_STREAMID[/color][color=8000FF], [/color][color=000000]dwId[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetUINT32[/color][color=8000FF]([/color][color=000000]$MF_TOPONODE_NOSHUTDOWN_ON_REMOVE[/color][color=8000FF], [/color][color=000000]%FALSE[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Add the node to the topology.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pTopology.AddNode[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]''// Return the pointer to the caller.
                                    '*ppNode = pNode
                                    '(*ppNode).AddRef()
                        
                                    ''// Return the pointer to the caller.
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]ppNode [/color][color=8000FF]= [/color][color=000000]pNode
                                    [/color][color=0000C0]END IF
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'///////////////////////////////////////////////////////////////////////////
                                ' ORIGINAL VARIABLES
                                '     IMFTopology *pTopology _          '// Topology.
                                '   , IMFMediaSource *pSource _         '// Media source.
                                '   , IMFPresentationDescriptor *pPD _  '// Presentation descriptor.
                                '   , IMFStreamDescriptor *pSD _        '// Stream descriptor.   DOES NOT MATCH
                                '   , IMFTopologyNode **ppNode _        '// Receives the node pointer.
                                '///////////////////////////////////////////////////////////////////////////
                                '// Add a source node to a topology.
                                [/color][color=0000C0]METHOD [/color][color=000000]AddSourceNode[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology [/color][color=0000C0]_                      [/color][color=007F00]' __in IMFTopology *pTopology                    '// Topology.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pMediaSource [/color][color=0000C0]AS [/color][color=000000]IMFMediaSource [/color][color=0000C0]_                [/color][color=007F00]' __in IMFMediaSource *pMediaSource              '// Media source.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pPD [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor [/color][color=0000C0]_              [/color][color=007F00]' __in IMFPresentationDescriptor *pPD            '// Presentation descriptor.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pSD [/color][color=0000C0]AS [/color][color=000000]IMFStreamDescriptor [/color][color=0000C0]_      [/color][color=007F00]DNM in not out' __out IMFStreamDescriptor **ppStreamDescriptor '// Stream descriptor.
                                   [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode [/color][color=0000C0]_                     [/color][color=007F00]' __out IMFTopologyNode **ppNode                 '// Receives the node pointer.
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode
                                    [/color][color=007F00]'IMFTopologyNode *pNode = NOTHING
                        
                                    '// Create the node.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateTopologyNode[/color][color=8000FF]([/color][color=000000]%MF_TOPOLOGY_SOURCESTREAM_NODE[/color][color=8000FF], [/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Set the attributes.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetUnknown[/color][color=8000FF]([/color][color=000000]$MF_TOPONODE_SOURCE[/color][color=8000FF], [/color][color=000000]pMediaSource[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetUnknown[/color][color=8000FF]([/color][color=000000]$MF_TOPONODE_PRESENTATION_DESCRIPTOR[/color][color=8000FF], [/color][color=000000]pPD[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pNode.SetUnknown[/color][color=8000FF]([/color][color=000000]$MF_TOPONODE_STREAM_DESCRIPTOR[/color][color=8000FF], [/color][color=000000]pSD[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Add the node to the topology.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pTopology.AddNode[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]''// Return the pointer to the caller.
                                    '*ppNode = pNode
                                    '(*ppNode).AddRef()
                        
                                    ''// Return the pointer to the caller.
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]ppNode [/color][color=8000FF]= [/color][color=000000]pNode
                                    [/color][color=0000C0]END IF
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pNode[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'///////////////////////////////////////////////////////////////////////////
                                ' ORIGINAL VARIABLES
                                '     IMFStreamDescriptor *pSourceSD _    '// Pointer to the stream descriptor.     DOES NOT MATCH
                                '   , hVideoWindow AS DWORD _             '// Handle to the video clipping window.
                                '   , IMFActivate **ppActivate _                                                    DOES NOT MATCH
                                '///////////////////////////////////////////////////////////////////////////
                                '//  Create an activation object for a renderer, based on the stream media type.
                                [/color][color=0000C0]METHOD [/color][color=000000]CreateMediaSinkActivate[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYREF [/color][color=000000]pSourceSD [/color][color=0000C0]AS [/color][color=000000]IMFStreamDescriptor [/color][color=0000C0]_ [/color][color=007F00]DNM in not out' __out IMFStreamDescriptor **ppStreamDescriptor '// Pointer to the stream descriptor.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hVideoWindow [/color][color=0000C0]AS DWORD _                          [/color][color=007F00]' HWND                                           '// Handle to the video clipping window.
                                   [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppEnablerActivate [/color][color=0000C0]AS [/color][color=000000]IMFActivate [/color][color=0000C0]_           [/color][color=007F00]DNM ' __out IMFActivate **ppEnablerActivate
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pHandler [/color][color=0000C0]AS [/color][color=000000]IMFMediaTypeHandler
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pActivate [/color][color=0000C0]AS [/color][color=000000]IMFActivate
                        
                                    [/color][color=007F00]'IMFMediaTypeHandler *pHandler = NOTHING
                                    'IMFActivate *pActivate = NOTHING
                        
                                    '// Get the media type handler for the stream.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pSourceSD.GetMediaTypeHandler[/color][color=8000FF]([/color][color=000000]pHandler[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Get the major media type.
                                    [/color][color=0000C0]LOCAL [/color][color=000000]guidMajorType [/color][color=0000C0]AS GUID
                                    [/color][color=007F00]'GUID guidMajorType
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pHandler.GetMajorType[/color][color=8000FF]([/color][color=000000]guidMajorType[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Create an IMFActivate object for the renderer, based on the media type.
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]$MFMediaType_Audio [/color][color=8000FF]= [/color][color=000000]guidMajorType[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// Create the audio renderer.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateAudioRendererActivate[/color][color=8000FF]([/color][color=000000]pActivate[/color][color=8000FF])
                                    [/color][color=0000C0]ELSEIF [/color][color=8000FF]([/color][color=000000]$MFMediaType_Video [/color][color=8000FF]= [/color][color=000000]guidMajorType[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// Create the video renderer.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateVideoRendererActivate[/color][color=8000FF]([/color][color=000000]hVideoWindow[/color][color=8000FF], [/color][color=000000]pActivate[/color][color=8000FF])
                                    [/color][color=0000C0]ELSE
                                        [/color][color=007F00]'// Unknown stream type.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=0000C0]%E_FAIL
                                        [/color][color=007F00]'// Optionally, you could deselect this stream instead of failing.
                                    [/color][color=0000C0]END IF
                                    IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]''// Return IMFActivate pointer to caller.
                                    '*ppActivate = pActivate
                                    '(*ppActivate).AddRef()
                        
                                    '// Return IMFActivate pointer to caller.
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pActivate[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]ppEnablerActivate [/color][color=8000FF]= [/color][color=000000]pActivate
                                    [/color][color=0000C0]END IF
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pHandler[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pActivate[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                        
                        
                                [/color][color=007F00]'//  Add a topology branch for one stream.
                                '//
                                '//  For each stream, this function does the following:
                                '//
                                '//    1. Creates a source node associated with the stream.
                                '//    2. Creates an output node for the renderer.
                                '//    3. Connects the two nodes.
                                '//
                                '//  The media session will add any decoders that are needed.
                        
                                '///////////////////////////////////////////////////////////////////////////
                                ' ORIGINAL VARIABLES
                                '     IMFTopology *pTopology _        '// Topology.
                                '   , IMFMediaSource *pSource _       '// Media source.
                                '   , IMFPresentationDescriptor *pPD _'// Presentation descriptor.
                                '   , DWORD iStream _                 '// Stream index.
                                '   , BYVAL hVideoWnd AS DWORD _      '// Window for video playback.
                                '///////////////////////////////////////////////////////////////////////////
                                [/color][color=0000C0]METHOD [/color][color=000000]AddBranchToPartialTopology[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology [/color][color=0000C0]_                   [/color][color=007F00]' __in IMFTopology *pTopology         '// Topology.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pMediaSource [/color][color=0000C0]AS [/color][color=000000]IMFMediaSource [/color][color=0000C0]_             [/color][color=007F00]' __in IMFMediaSource *pMediaSource   '// Media source.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pPD [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor [/color][color=0000C0]_           [/color][color=007F00]' __in IMFPresentationDescriptor *pPD '// Presentation descriptor.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]MyStreamIdx [/color][color=0000C0]AS DWORD _                       [/color][color=007F00]' __in ??????                         '// Stream index.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hVideoWnd [/color][color=0000C0]AS DWORD _                         [/color][color=007F00]'HWND ????                            '// Window for video playback.
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pSD [/color][color=0000C0]AS [/color][color=000000]IMFStreamDescriptor
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pSinkActivate [/color][color=0000C0]AS [/color][color=000000]IMFActivate
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pSourceNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pOutputNode [/color][color=0000C0]AS [/color][color=000000]IMFTopologyNode
                                    [/color][color=0000C0]LOCAL [/color][color=000000]fSelected [/color][color=0000C0]AS LONG
                        
                                    [/color][color=007F00]'IMFStreamDescriptor *pSD = NOTHING
                                    'IMFActivate         *pSinkActivate = NOTHING
                                    'IMFTopologyNode     *pSourceNode = NOTHING
                                    'IMFTopologyNode     *pOutputNode = NOTHING
                                    [/color][color=000000]fSelected [/color][color=8000FF]= [/color][color=000000]%FALSE
                                    [/color][color=007F00]'BOOL fSelected = %FALSE
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPD.GetStreamDescriptorByIndex[/color][color=8000FF]([/color][color=000000]MyStreamIdx[/color][color=8000FF], [/color][color=000000]fSelected[/color][color=8000FF], [/color][color=000000]pSD[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    IF [/color][color=8000FF]([/color][color=000000]fSelected[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// Create the media sink activation object.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.CreateMediaSinkActivate[/color][color=8000FF]([/color][color=000000]pSD[/color][color=8000FF], [/color][color=000000]hVideoWnd[/color][color=8000FF], [/color][color=000000]pSinkActivate[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                        
                                        [/color][color=007F00]'// Add a source node for this stream.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.AddSourceNode[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF], [/color][color=000000]pMediaSource[/color][color=8000FF], [/color][color=000000]pPD[/color][color=8000FF], [/color][color=000000]pSD[/color][color=8000FF], [/color][color=000000]pSourceNode[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                        
                                        [/color][color=007F00]'// Create the output node for the renderer.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.AddOutputNode[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF], [/color][color=000000]pSinkActivate[/color][color=8000FF], [/color][color=000000]0[/color][color=8000FF], [/color][color=000000]pOutputNode[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                        
                                        [/color][color=007F00]'// Connect the source node to the output node.
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pSourceNode.ConnectOutput[/color][color=8000FF]([/color][color=000000]0[/color][color=8000FF], [/color][color=000000]pOutputNode[/color][color=8000FF], [/color][color=000000]0[/color][color=8000FF])
                                    [/color][color=0000C0]END IF
                                    [/color][color=007F00]'// else: If not selected, don't add the branch.
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSD[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSinkActivate[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSourceNode[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pOutputNode[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                        
                                   [/color][color=007F00]'////////////////////////////////////////////////
                                   ' ORIGINAL VARIABLES
                                   '  IMFMediaSource *pSource _
                                   ', IMFPresentationDescriptor *pPD _
                                   ', BYVAL hVideoWnd AS DWORD _
                                   ',IMFTopology **ppTopology _
                                   '////////////////////////////////////////////////
                                [/color][color=0000C0]METHOD [/color][color=000000]CreatePlaybackTopology[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pMediaSource [/color][color=0000C0]AS [/color][color=000000]IMFMediaSource [/color][color=0000C0]_     [/color][color=007F00]' __in IMFMediaSource *pMediaSource
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pPD [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor [/color][color=0000C0]_   [/color][color=007F00]' __in IMFPresentationDescriptor *pPD
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hVideoWnd [/color][color=0000C0]AS DWORD _                 [/color][color=007F00]'???? HWND                              '// Video window.
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]ppTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology [/color][color=0000C0]_          [/color][color=007F00]' __out_opt IMFTopology **ppTopology    '// Receives a pointer to the topology.
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology
                                    [/color][color=0000C0]LOCAL [/color][color=000000]cSourceStreams [/color][color=0000C0]AS DWORD
                                    LOCAL [/color][color=000000]i [/color][color=0000C0]AS DWORD
                        
                                    [/color][color=007F00]'// Create a new topology.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateTopology[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Get the number of streams in the media source.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPD.GetStreamDescriptorCount[/color][color=8000FF]([/color][color=000000]cSourceStreams[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// For each stream, create the topology nodes and add them to the topology.
                                    [/color][color=0000C0]FOR [/color][color=000000]i [/color][color=8000FF]= [/color][color=000000]0 [/color][color=0000C0]TO [/color][color=000000]cSourceStreams [/color][color=8000FF]- [/color][color=000000]1 [/color][color=007F00]'(DWORD i = 0 i < cSourceStreams i++)
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.AddBranchToPartialTopology[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF], [/color][color=000000]pMediaSource[/color][color=8000FF], [/color][color=000000]pPD[/color][color=8000FF], [/color][color=000000]i[/color][color=8000FF], [/color][color=000000]hVideoWnd[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                                    NEXT [/color][color=000000]i
                        
                                    [/color][color=007F00]'// Return the IMFTopology pointer to the caller.
                                    '*ppTopology = pTopology
                                    '(*ppTopology).AddRef()
                        
                                    '// Return the IMFTopology pointer to the caller.
                                    [/color][color=000000]ppTopology [/color][color=8000FF]= [/color][color=000000]pTopology
                                    [/color][color=007F00]'ppTopology.AddRef()
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                        
                                METHOD [/color][color=000000]CPlayer[/color][color=8000FF]( [/color][color=0000C0]_             [/color][color=007F00]'CPlayer method
                                     [/color][color=0000C0]BYVAL [/color][color=000000]hVideo [/color][color=0000C0]AS DWORD _     [/color][color=007F00]' HWND  hVideo
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hEvent [/color][color=0000C0]AS DWORD _     [/color][color=007F00]' HWND
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                        [/color][color=007F00]'            pMediaSession(NULL)
                        '            pMediaSource(NULL)
                        '            pVideoDisplay(NULL)
                        '            m_hwndVideo(hVideo)
                        '            m_hwndEvent(hEvent)
                        '            m_state(%Closed)
                        '            m_hCloseEvent(NULL)
                        '            m_nRefCount(1)
                        '            pCallback(NULL)
                        
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pVideoDisplay[/color][color=8000FF])
                                    [/color][color=000000]m_hwndVideo [/color][color=8000FF]= [/color][color=000000]hVideo
                                    m_hwndEvent [/color][color=8000FF]= [/color][color=000000]hEvent
                                    m_state [/color][color=8000FF]= [/color][color=000000]%Closed
                                    CloseHandle[/color][color=8000FF]([/color][color=000000]m_hCloseEvent[/color][color=8000FF])
                                    [/color][color=000000]m_nRefCount [/color][color=8000FF]= [/color][color=000000]1
                                    SafeRelease[/color][color=8000FF]([/color][color=000000]pCallback[/color][color=8000FF])
                        
                                [/color][color=0000C0]END METHOD
                        
                        
                                [/color][color=007F00]'// IUnknown methods
                        
                        '        METHOD QueryInterface( _                      'CPlayer method
                        '             REFIID riid _
                        '           , void** ppv _
                        '           ) AS LONG
                        '
                        '            STATIC CONST QITAB qit[] =
                        '            {
                        '                'example QITABENT(CClass, IPersistStream)
                        '                QITABENT(CPlayer, IMFAsyncCallback),
                        '                { 0 }
                        '            }
                        '            FUNCTION = QISearch(THIS, qit, riid, ppv)
                        '        END METHOD
                        
                        '        METHOD AddRef() AS LONG                                       'CPlayer method
                        '            method = InterlockedIncrement(m_nRefCount)
                        '        END METHOD
                        '
                        '        METHOD Release() AS LONG                                     'CPlayer method
                        '            LOCAL uCount AS LONG
                        '            uCount = InterlockedDecrement(m_nRefCount)      'ulong
                        '            IF (uCount = 0) THEN
                        '                'DELETE THIS     ??????
                        '            END IF
                        '            method = uCount
                        '        END METHOD
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]StateCallback[/color][color=8000FF]()                     [/color][color=007F00]'CPlayer method (void)  PROTECTED
                                    [/color][color=000000]pPlayer.OnPlayerStateChange[/color][color=8000FF]([/color][color=000000]m_state[/color][color=8000FF])
                                [/color][color=0000C0]END METHOD
                        
                        
                                [/color][color=007F00]'//  Start playback from paused or stopped.
                                [/color][color=0000C0]METHOD [/color][color=000000]PlayIt[/color][color=8000FF]() [/color][color=0000C0]AS LONG                         [/color][color=007F00]'CPlayer Method PROTECTED
                        
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Paused [/color][color=8000FF]AND [/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Stopped[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=000000]%MF_E_INVALIDREQUEST
                                        [/color][color=0000C0]GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                    IF [/color][color=8000FF](ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) OR ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%E_UNEXPECTED
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]pPlayer.StartPlayback[/color][color=8000FF]()
                                [/color][color=000000]done[/color][color=8000FF]:
                                [/color][color=0000C0]END METHOD
                        
                        
                                [/color][color=007F00]'//  Pause playback.
                                [/color][color=0000C0]METHOD [/color][color=000000]Pause[/color][color=8000FF]() [/color][color=0000C0]AS LONG              [/color][color=007F00]'CPlayer Method
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    IF [/color][color=8000FF]([/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Started[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=000000]%MF_E_INVALIDREQUEST
                                        [/color][color=0000C0]GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                    IF [/color][color=8000FF](ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) OR ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%E_UNEXPECTED
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.Pause[/color][color=8000FF]()
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Paused
                                        pPlayer.StateCallback[/color][color=8000FF]()
                                    [/color][color=0000C0]END IF
                        
                                    METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                done[/color][color=8000FF]:
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'// Stop playback.
                                [/color][color=0000C0]METHOD [/color][color=000000]StopIt[/color][color=8000FF]() [/color][color=0000C0]AS LONG                   [/color][color=007F00]'CPlayer Method
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    IF [/color][color=8000FF]([/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Started [/color][color=8000FF]AND [/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Paused[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=000000]%MF_E_INVALIDREQUEST
                                        [/color][color=0000C0]GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                    IF [/color][color=8000FF](ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%E_UNEXPECTED
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.Stop[/color][color=8000FF]()
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Stopped
                                        pPlayer.StateCallback[/color][color=8000FF]()
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                done[/color][color=8000FF]:
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'//  Repaint the video window. Call this method on WM_PAINT.
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]Repaint[/color][color=8000FF]() [/color][color=0000C0]AS LONG               [/color][color=007F00]'CPlayer Method
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pVideoDisplay[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=000000]pVideoDisplay.RepaintVideo[/color][color=8000FF]()
                                    [/color][color=0000C0]ELSE
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                    END IF
                                END METHOD
                        
                                [/color][color=007F00]'//  Resize the video rectangle.
                                '//
                                '//  Call this method if the size of the video window changes.
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]ResizeVideo[/color][color=8000FF]( [/color][color=0000C0]_            [/color][color=007F00]'CPlayer Method
                                     [/color][color=0000C0]BYVAL [/color][color=000000]x_width [/color][color=0000C0]AS WORD _
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]y_height [/color][color=0000C0]AS WORD _
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]rcDest [/color][color=0000C0]AS [/color][color=000000]RECT
                        
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pVideoDisplay[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// Set the destination rectangle.
                                        '// Leave the default source rectangle (0,0,1,1).
                                        'RECT rcDest = { 0, 0, x_WIDTH, y_height }
                                        [/color][color=000000]rcDest.nLeft [/color][color=8000FF]= [/color][color=000000]0
                                        rcDest.nTop [/color][color=8000FF]= [/color][color=000000]0
                                        rcDest.nRight [/color][color=8000FF]= [/color][color=000000]x_width
                                        rcDest.nBottom [/color][color=8000FF]= [/color][color=000000]y_height
                        
                                        [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]pVideoDisplay.SetVideoPosition[/color][color=8000FF]([/color][color=0000C0]$NUL[/color][color=8000FF], [/color][color=000000]rcDest[/color][color=8000FF])
                                    [/color][color=0000C0]ELSE
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                    END IF
                                END METHOD
                        
                        
                                     [/color][color=007F00]'/////////////////////////////////////
                                     'ORIGINAL VARIABLES
                                     'IMFMediaEvent *pEvent _
                                     '/////////////////////////////////////
                        
                                '//  Start playback from the current position.
                                [/color][color=0000C0]METHOD [/color][color=000000]StartPlayback[/color][color=8000FF]() [/color][color=0000C0]AS LONG                [/color][color=007F00]'CPlayer Method  PROTECTED
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]varStart [/color][color=0000C0]AS [/color][color=000000]PROPVARIANT [/color][color=007F00]'ANY
                                    'PROPVARIANT varStart
                        
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) [/color][color=0000C0]THEN [/color][color=007F00]' <> %NULL     '?????  assert( pMediaSession != NULL)
                                        [/color][color=000000]PropVariantInit[/color][color=8000FF]([/color][color=000000]varStart[/color][color=8000FF])
                        
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.Start[/color][color=8000FF]([/color][color=000000]$GUID_NULL[/color][color=8000FF], [/color][color=000000]varStart[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                            [/color][color=007F00]'// Note: Start is an asynchronous operation. However, we
                                            '// can treat our state as being already started. If Start
                                            '// fails later, we'll get an MESessionStarted event with
                                            '// an error code, and we will update our state then.
                                            [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Started
                                            pPlayer.StateCallback[/color][color=8000FF]()
                                        [/color][color=0000C0]END IF
                                        [/color][color=000000]PropVariantClear[/color][color=8000FF]([/color][color=000000]varStart[/color][color=8000FF])
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                METHOD [/color][color=000000]OnTopologyStatus[/color][color=8000FF]( [/color][color=0000C0]_                  [/color][color=007F00]'CPlayer Method PROTECTED
                                     [/color][color=0000C0]BYVAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]StatusX [/color][color=0000C0]AS DWORD
                                    [/color][color=007F00]'UINT32 STATUS
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pEvent.GetUINT32[/color][color=8000FF]([/color][color=000000]$MF_EVENT_TOPOLOGY_STATUS[/color][color=8000FF], [/color][color=000000]StatusX[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) AND ([/color][color=000000]StatusX [/color][color=8000FF]= [/color][color=000000]%MF_TOPOSTATUS_READY[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pVideoDisplay[/color][color=8000FF])
                        
                                        [/color][color=007F00]'// Get the IMFVideoDisplayControl interface from EVR. This call is
                                        '// expected to fail if the media file does not have a video stream.
                        
                                     '   MFGetService(pMediaSession, $MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(pVideoDisplay))  '(void) ?????????????????
                        
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.StartPlayback[/color][color=8000FF]()
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                        
                                     [/color][color=007F00]'////////////////////////////////////
                                     'ORIGINAL VARIABLE
                                     'UINT_PTR pEventPtr _
                                     '////////////////////////////////////
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]HandleEvent[/color][color=8000FF]( [/color][color=0000C0]_                 [/color][color=007F00]'CPlayer Method
                                     [/color][color=0000C0]BYVAL [/color][color=000000]pEventPtr [/color][color=0000C0]AS DWORD _
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hrStatus [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                        
                                    [/color][color=000000]hrStatus [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                    LOCAL [/color][color=000000]meType [/color][color=0000C0]AS LONG
                                    [/color][color=000000]meType [/color][color=8000FF]= [/color][color=000000]%MEUnknown
                                    [/color][color=007F00]'MediaEventType meType = %MEUnknown
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent
                        
                        [/color][color=007F00]'            IMFMediaEvent *pEvent = (IMFMediaEvent*)pEventPtr        '??????????????????? unfinished
                        
                                    [/color][color=0000C0]IF [/color][color=8000FF](ISFALSE [/color][color=0000C0]ISOBJECT[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        METHOD [/color][color=8000FF]= [/color][color=0000C0]%E_POINTER
                                    END IF
                        
                                    [/color][color=007F00]'// Get the event type.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pEvent.GetType[/color][color=8000FF]([/color][color=000000]meType[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Get the event status. If the operation that triggered the event
                                    '// did not succeed, the status is a failure code.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pEvent.GetStatus[/color][color=8000FF]([/color][color=000000]hrStatus[/color][color=8000FF])
                        
                                    [/color][color=007F00]'// Check if the async operation succeeded.
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) AND [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hrStatus[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]hrStatus
                                    [/color][color=0000C0]END IF
                        
                                    IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    SELECT CASE [/color][color=000000]meType
                                        [/color][color=0000C0]CASE [/color][color=000000]%MESessionTopologyStatus
                                            hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OnTopologyStatus[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])
                        
                                        [/color][color=0000C0]CASE [/color][color=000000]%MEEndOfPresentation
                                            hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OnPresentationEnded[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])
                        
                                        [/color][color=0000C0]CASE [/color][color=000000]%MENewPresentation
                                            hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OnNewPresentation[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])
                        
                                        [/color][color=0000C0]CASE ELSE
                                            [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OnSessionEvent[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF], [/color][color=000000]meType[/color][color=8000FF])
                                    [/color][color=0000C0]END SELECT
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                        
                                METHOD [/color][color=000000]OnSessionEvent[/color][color=8000FF]( [/color][color=0000C0]_                 [/color][color=007F00]'CPlayer Method    CPlaylist
                                     [/color][color=0000C0]BYVAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_
                                   [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]meType [/color][color=0000C0]AS DWORD _
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                [/color][color=007F00]'HRESULT CPlaylist::OnSessionEvent(IMFMediaEvent *pEvent, MediaEventType meType)
                        
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]meType [/color][color=8000FF]= [/color][color=000000]%MESessionNotifyPresentationTime[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]m_PresentationTimeOffset [/color][color=8000FF]= [/color][color=000000]MFGetAttributeUINT64[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF], [/color][color=000000]$MF_EVENT_PRESENTATION_TIME_OFFSET[/color][color=8000FF], [/color][color=000000]0[/color][color=8000FF])
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                END METHOD
                        
                        
                                [/color][color=007F00]'/// Protected methods
                        
                                     '///////////////////////////////
                                     'ORIGINAL VARIABLES
                                     'IMFMediaEvent* /*pEvent*/ _
                                     '///////////////////////////////
                        
                                '//  Handler for MEEndOfPresentation event.
                                [/color][color=0000C0]METHOD [/color][color=000000]OnPresentationEnded[/color][color=8000FF]( [/color][color=0000C0]_                    [/color][color=007F00]'CPlayer Method PROTECTED
                                     [/color][color=0000C0]BYVAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    [/color][color=007F00]'// The session puts itself into the stopped state automatically.
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Stopped
                                    pPlayer.StateCallback[/color][color=8000FF]()
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                END METHOD
                        
                                   [/color][color=007F00]'//////////////////////////////////////////////////////////
                                   ' ORIGINAL VARIABLES
                                   '  IMFMediaEvent *pEvent _
                                   ', Q **ppObject _
                                   '//////////////////////////////////////////////////////////
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]GetEventObject[/color][color=8000FF]( [/color][color=0000C0]_
                                     BYVAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_                    [/color][color=007F00]' __in IMFMediaEvent *pEvent
                                   [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                   [/color][color=007F00]DNM  ' __out IUnknown **ppObject
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]varx [/color][color=0000C0]AS [/color][color=000000]PROPVARIANT [/color][color=007F00]'ANY
                                    'PROPVARIANT varx
                        
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]ppObject[/color][color=8000FF])   [/color][color=007F00]'// zero output
                                    '*ppObject = NULL   '// zero output
                        
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pEvent.GetValue[/color][color=8000FF]([/color][color=000000]varx[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        IF [/color][color=8000FF]([/color][color=000000]varx.vt [/color][color=8000FF]= [/color][color=0000C0]%VT_UNKNOWN[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            ? [/color][color=C020C0]"here 01"
                                        [/color][color=007F00]'    hr = varx.punkVal.QueryInterface(ppObject)    '????????????????
                                        [/color][color=0000C0]ELSE
                                            [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]%MF_E_INVALIDTYPE
                                        [/color][color=0000C0]END IF
                                        [/color][color=000000]PropVariantClear[/color][color=8000FF]([/color][color=000000]varx[/color][color=8000FF])
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'//  Handler for MENewPresentation event.
                                '//
                                '//  This event is sent if the media source has a new presentation, which
                                '//  requires a new topology.
                                     '//////////////////////////////////////
                                     'ORIGINAL VARIABLES
                                     'IMFMediaEvent *pEvent _
                                     '//////////////////////////////////////
                        
                                [/color][color=0000C0]METHOD [/color][color=000000]OnNewPresentation[/color][color=8000FF]( [/color][color=0000C0]_                        [/color][color=007F00]'CPlayer Method protected
                                     [/color][color=0000C0]BYVAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_                    [/color][color=007F00]' __in IMFMediaEvent *pEvent
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pPD [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor
                                    [/color][color=007F00]'IMFPresentationDescriptor *pPD = NOTHING
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology
                        
                                    [/color][color=007F00]'// Get the presentation descriptor from the event.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.GetEventObject[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF], [/color][color=000000]pPD[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Create a partial topology.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.CreatePlaybackTopology[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF], [/color][color=000000]pPD[/color][color=8000FF],  [/color][color=000000]m_hwndVideo[/color][color=8000FF],[/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Set the topology on the media session.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.SetTopology[/color][color=8000FF]([/color][color=000000]0[/color][color=8000FF], [/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%OpenPending
                                    pPlayer.StateCallback[/color][color=8000FF]()
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pPD[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                                END METHOD
                        
                        
                                [/color][color=007F00]'//  Close the media session.
                                [/color][color=0000C0]METHOD [/color][color=000000]CloseSession[/color][color=8000FF]() [/color][color=0000C0]AS LONG                    [/color][color=007F00]'CPlayer Method PROTECTED
                        
                                    '//  The IMFMediaSession::Close method is asynchronous, but the
                                    '//  CPlayer::CloseSession method waits on the MESessionClosed event.
                                    '//
                                    '//  MESessionClosed is guaranteed to be the last event that the
                                    '//  media session fires.
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                        
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pVideoDisplay[/color][color=8000FF])
                        
                                    [/color][color=007F00]'// First close the media session.
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        LOCAL [/color][color=000000]dwWaitResult [/color][color=0000C0]AS DWORD
                                        [/color][color=007F00]'DWORD dwWaitResult = 0
                        
                                        [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Closing
                                        pPlayer.StateCallback[/color][color=8000FF]()
                        
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.Close[/color][color=8000FF]()
                                        [/color][color=007F00]'// Wait for the close operation to complete
                                        [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                            [/color][color=000000]dwWaitResult [/color][color=8000FF]= [/color][color=000000]WaitForSingleObject[/color][color=8000FF]([/color][color=000000]m_hCloseEvent[/color][color=8000FF], [/color][color=000000]5000[/color][color=8000FF])
                                            [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]dwWaitResult [/color][color=8000FF]= [/color][color=000000]%WAIT_TIMEOUT[/color][color=8000FF]) [/color][color=0000C0]THEN
                                                [/color][color=007F00]'assert(FALSE)  ????
                                            [/color][color=0000C0]END IF
                                            [/color][color=007F00]'// Now there will be no more events from this session.
                        
                                        [/color][color=0000C0]END IF
                                    END IF
                        
                                    [/color][color=007F00]'// Complete shutdown operations.
                                    [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]SUCCEEDED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF])) [/color][color=0000C0]THEN
                                        [/color][color=007F00]'// Shut down the media source. (Synchronous operation, no events.)
                                        [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            ? [/color][color=C020C0]"made it here"
                                            [/color][color=000000]pMediaSource.Shutdown[/color][color=8000FF]()        [/color][color=007F00]'void
                                        [/color][color=0000C0]END IF
                                        [/color][color=007F00]'// Shut down the media session. (Synchronous operation, no events.)
                                        [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            [/color][color=000000]pMediaSession.Shutdown[/color][color=8000FF]()       [/color][color=007F00]'void
                                        [/color][color=0000C0]END IF
                                    END IF
                        
                                    [/color][color=007F00]'SafeRelease(pMediaSource)
                                    [/color][color=000000]pMediaSource [/color][color=8000FF]= [/color][color=0000C0]NOTHING
                                    [/color][color=000000]pMediaSession [/color][color=8000FF]= [/color][color=0000C0]NOTHING
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Closed
                                    pPlayer.StateCallback[/color][color=8000FF]()
                        
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                    SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is closed."
                                    [/color][color=000000]SourceStatus [/color][color=8000FF]= [/color][color=C020C0]"No Source created."
                                [/color][color=0000C0]END METHOD
                        
                        
                                [/color][color=007F00]'//  Create a new instance of the media session.
                                [/color][color=0000C0]METHOD [/color][color=000000]OpenSession[/color][color=8000FF]() [/color][color=0000C0]AS LONG           [/color][color=007F00]'CPlayer Method  PROTECTED
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr           [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]punkState    [/color][color=0000C0]AS IUNKNOWN
                        
                                    [/color][color=007F00]'// Close the old session, if any.
                                    'hr = pPlayer.CloseSession()
                                    'IF FAILED(hr) THEN
                                    '    GOTO done
                                    'END IF
                        
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Closed
                                    pConfiguration [/color][color=8000FF]= [/color][color=0000C0]NOTHING
                        
                                    [/color][color=007F00]'// Create the media session.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]MFCreateMediaSession[/color][color=8000FF]([/color][color=000000]pConfiguration[/color][color=8000FF], [/color][color=000000]pMediaSession[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Start pulling events from the media session
                                    '// For all other events, get the next event in the queue.
                                    'After the session has been created, you need to specify a
                                    'callback object that will receive asynchronous events
                                    'from the session.
                                    [/color][color=0000C0]IF ISOBJECT[/color][color=8000FF]([/color][color=000000]pMediaSession[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.BeginGetEvent[/color][color=8000FF]([/color][color=000000]pCallback[/color][color=8000FF], [/color][color=000000]punkState[/color][color=8000FF])
                                        [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                            [/color][color=007F00]'? "The session events were not linked."
                                            [/color][color=0000C0]GOTO [/color][color=000000]done
                                        [/color][color=0000C0]END IF
                        
                                        [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Ready
                        
                                        [/color][color=007F00]'? "The events were linked to the session."
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Ready
                                    pPlayer.StateCallback[/color][color=8000FF]()
                        
                                    [/color][color=000000]SessionStatus [/color][color=8000FF]= [/color][color=C020C0]"Media Session is open."
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                [/color][color=007F00]'' ============================== EXAMPLE ==============================================
                                'METHOD CreateInstance( _                             ' VTable offset = 64
                                '  BYVAL pUnkOuter AS IUnknown _                      ' __in IUnknown *pUnkOuter
                                ', BYREF riid AS GUID _                               ' __in REFIID riid
                                ', BYREF ppvObj AS IUnknown _                         ' __out PVOID *ppvObj
                                ') AS LONG                                            ' HRESULT
                                '' =====================================================================================
                                '//  Static class method to create the CPlayer object.
                        '        METHOD CreateInstance( _           'CPlayer method
                        '             BYVAL hVideo AS DWORD _       '// IN HWND Video window.
                        '           , BYVAL hEvent AS DWORD _       '// IN HWND Window to receive notifications.
                        '           , BYVAL ppPlayer AS IMFAsyncCallbackImpl _   '???? '// OUT CPlayer **ppPlayer Receives a pointer to the CPlayer object.
                        '           ) AS LONG
                        '
                        '            LOCAL hr AS LONG
                        '            IF (ISFALSE ISOBJECT(ppPlayer)) THEN
                        '                METHOD = %E_POINTER
                        '            END IF
                        '
                        '            '  CPlayer *pPlayer = NEW (std::nothrow) CPlayer(hVideo, hEvent)   ?????????????
                        '            IF (ISFALSE ISOBJECT(pPlayer)) THEN
                        '                METHOD = %E_OUTOFMEMORY
                        '            END IF
                        '
                        '            hr = ME.Create()   'Initialize()
                        '            IF (SUCCEEDED(hr)) THEN
                        '                ppPlayer = pPlayer
                        '            ELSE
                        '                pPlayer.Release()
                        '            END IF
                        '            METHOD = hr
                        '        END METHOD
                        
                        
                                'METHOD SetStateCallback( _                        'CPlayer method (void) PROTECTED
                                '     WebmMfUtil::MfPlayerCallback* ptr_callback)    '????????
                                '
                                '    pCallback = ptr_callback
                                'END METHOD
                        
                                     '///////////////////////////////////////////
                                     'ORIGINAL VARIABLE
                                     'CONST WCHAR *sURL _
                                     '///////////////////////////////////////////
                        
                                '//  Open a URL for playback.
                                [/color][color=0000C0]METHOD [/color][color=000000]OpenURL[/color][color=8000FF]( [/color][color=0000C0]_                        [/color][color=007F00]'CPlayer Method
                                     [/color][color=0000C0]BYREF [/color][color=000000]psURL [/color][color=0000C0]AS WSTRINGZ _           [/color][color=007F00]' const WCHAR *sURL
                                   [/color][color=8000FF]) [/color][color=0000C0]AS LONG
                        
                                    [/color][color=007F00]'// 1. Create a new media session.
                                    '// 2. Create the media source.
                                    '// 3. Create the topology.
                                    '// 4. Queue the topology [asynchronous]
                                    '// 5. Start playback [asynchronous - does not happen in this method.]
                        
                                    [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                    LOCAL [/color][color=000000]pTopology [/color][color=0000C0]AS [/color][color=000000]IMFTopology
                                    [/color][color=0000C0]LOCAL [/color][color=000000]pSourcePD [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor
                                    [/color][color=007F00]'IMFPresentationDescriptor* pSourcePD = NOTHING
                        
                                    '// Create the media session.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OpenSession[/color][color=8000FF]()
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Create the media source.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.OpenMyMediaSource[/color][color=8000FF]([/color][color=000000]psURL[/color][color=8000FF], [/color][color=000000]pMediaSource[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Create the presentation descriptor for the media source.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSource.CreatePresentationDescriptor[/color][color=8000FF]([/color][color=000000]pSourcePD[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Create a partial topology.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pPlayer.CreatePlaybackTopology[/color][color=8000FF]([/color][color=000000]pMediaSource[/color][color=8000FF], [/color][color=000000]pSourcePD[/color][color=8000FF], [/color][color=000000]m_hwndVideo[/color][color=8000FF], [/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=007F00]'// Set the topology on the media session.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.SetTopology[/color][color=8000FF]([/color][color=000000]0[/color][color=8000FF], [/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%OpenPending
                                    pPlayer.StateCallback[/color][color=8000FF]()
                        
                                    [/color][color=007F00]'// If SetTopology succeeds, the media session will queue an
                                    '// MESessionTopologySet event.
                        
                                [/color][color=000000]done[/color][color=8000FF]:
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]m_state [/color][color=8000FF]= [/color][color=000000]%Closed
                                        pPlayer.StateCallback[/color][color=8000FF]()
                                    [/color][color=0000C0]END IF
                        
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pSourcePD[/color][color=8000FF])
                                    [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pTopology[/color][color=8000FF])
                                    [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=000000]hr
                                [/color][color=0000C0]END METHOD
                        
                                METHOD [/color][color=000000]onPlayerStateChange[/color][color=8000FF]([/color][color=0000C0]BYVAL [/color][color=000000]eventx [/color][color=0000C0]AS LONG[/color][color=8000FF]) [/color][color=0000C0]AS LONG
                                [/color][color=007F00]'    Closed = 0     '// No session.
                                '    Ready          '// Session was created, ready to open a file.
                                '    OpenPending    '// Session is opening a file.
                                '    Started        '// Session is playing a file.
                                '    Paused         '// Session is paused.
                                '    Stopped        '// Session is stopped (ready to play).
                                '    Closing        '// Application has closed the session, but is waiting for MESessionClosed.
                        
                                    [/color][color=0000C0]IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]0[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]=  [/color][color=C020C0]"The Session is closed." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "No session."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]1[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"The Session is open." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Session was created, ready to open a file."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]2[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"Session is opening a file." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Session is opening a file."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]3[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"Session is playing a file." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Session is playing a file."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]4[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"Session is paused." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Session is paused."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]5[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"Session is stopped (ready to play)." [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Session is stopped (ready to play)."
                                    [/color][color=0000C0]END IF
                        
                                    IF[/color][color=8000FF]([/color][color=000000]eventx [/color][color=8000FF]= [/color][color=000000]6[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        [/color][color=000000]SSMessages [/color][color=8000FF]= [/color][color=C020C0]"The session is closing."  [/color][color=8000FF]+ [/color][color=0000C0]$CRLF [/color][color=8000FF]+ [/color][color=000000]SSMessages
                                        [/color][color=0000C0]CONTROL SET TEXT [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%TextboxText[/color][color=8000FF], [/color][color=000000]SSMessages
                                        [/color][color=007F00]'? "Application has closed the session, but is waiting for MESessionClosed."
                                    [/color][color=0000C0]END IF
                                    METHOD [/color][color=8000FF]= [/color][color=000000]eventx
                                [/color][color=0000C0]END METHOD
                        
                            END INTERFACE
                        END CLASS
                        
                        
                        
                        
                        [/color][color=007F00]'SUB PropVariantinit (BYREF p AS PROPVARIANT)
                        '   ZeroMemory(BYVAL VARPTR(p), SIZEOF(PROPVARIANT))
                        'END SUB
                        
                        
                        '_________________________________________________________________
                        '
                        ' FileExists - make sure a file or folder exists
                        '_________________________________________________________________
                        
                        [/color][color=0000C0]FUNCTION [/color][color=000000]FileExists[/color][color=8000FF]([/color][color=000000]sFileName [/color][color=0000C0]AS ASCIIZ[/color][color=8000FF]) [/color][color=0000C0]AS LONG
                            LOCAL [/color][color=000000]sFN [/color][color=0000C0]AS STRING
                            [/color][color=000000]sFN [/color][color=8000FF]= [/color][color=0000C0]REMOVE$[/color][color=8000FF]([/color][color=000000]sFileName[/color][color=8000FF], [/color][color=0000C0]$CRLF[/color][color=8000FF])
                            [/color][color=0000C0]FUNCTION [/color][color=8000FF]= [/color][color=000000]PathFileExists[/color][color=8000FF]([/color][color=0000C0]BYVAL STRPTR[/color][color=8000FF]([/color][color=000000]sFN[/color][color=8000FF])) [/color][color=007F00]'Return non-zero if file or folder exist.
                        
                        [/color][color=0000C0]END FUNCTION
                        
                        [/color][color=007F00]'_________________________________________________________________
                        '
                        ' FileNam Get file name part of given path & name
                        '_________________________________________________________________
                        
                        [/color][color=0000C0]FUNCTION [/color][color=000000]FileNam [/color][color=8000FF]([/color][color=0000C0]BYVAL [/color][color=000000]Src [/color][color=0000C0]AS STRING[/color][color=8000FF]) [/color][color=0000C0]AS STRING
                            LOCAL [/color][color=000000]x [/color][color=0000C0]AS LONG
                        
                            [/color][color=000000]x [/color][color=8000FF]= [/color][color=0000C0]INSTR[/color][color=8000FF](-[/color][color=000000]1[/color][color=8000FF], [/color][color=000000]Src[/color][color=8000FF], [/color][color=0000C0]ANY [/color][color=C020C0]":/\"[/color][color=8000FF])
                            [/color][color=0000C0]IF [/color][color=000000]x [/color][color=0000C0]THEN
                                FUNCTION [/color][color=8000FF]= [/color][color=0000C0]MID$[/color][color=8000FF]([/color][color=000000]Src[/color][color=8000FF], [/color][color=000000]x [/color][color=8000FF]+ [/color][color=000000]1[/color][color=8000FF])
                            [/color][color=0000C0]ELSE
                                FUNCTION [/color][color=8000FF]= [/color][color=000000]Src
                            [/color][color=0000C0]END IF
                        
                        END FUNCTION
                        
                        
                        
                        CLASS [/color][color=000000]CMFAsyncCallback [/color][color=0000C0]AS COM
                        
                        INTERFACE [/color][color=000000]IMFAsyncCallback $IID_IMFAsyncCallback
                        
                            [/color][color=0000C0]INHERIT IUNKNOWN
                        
                            [/color][color=007F00]'//////////////////////////////////////////////////////////////////////////////////////
                            '// These are Public methods
                            '//////////////////////////////////////////////////////////////////////////////////////
                            ' =====================================================================================
                            '// IMFAsyncCallback methods
                            ' =====================================================================================
                            [/color][color=0000C0]METHOD [/color][color=000000]GetParameters [/color][color=8000FF]( [/color][color=0000C0]_                             [/color][color=007F00]' VTable offset = 12
                              [/color][color=0000C0]BYREF [/color][color=000000]pdwFlags [/color][color=0000C0]AS DWORD _                          [/color][color=007F00]' __out DWORD *pdwFlags
                            [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pdwQueue [/color][color=0000C0]AS DWORD _                          [/color][color=007F00]' __out DWORD *pdwQueue
                            [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                            [/color][color=0000C0]END METHOD
                            [/color][color=007F00]' =====================================================================================
                            [/color][color=0000C0]METHOD [/color][color=000000]Invoke [/color][color=8000FF]( [/color][color=0000C0]_                                    [/color][color=007F00]' VTable offset = 16
                              [/color][color=0000C0]BYVAL [/color][color=000000]pAsyncResult [/color][color=0000C0]AS [/color][color=000000]IMFAsyncResult [/color][color=0000C0]_             [/color][color=007F00]' __in IMFAsyncResult *pAsyncResult
                            [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                            '/////////////////////////////////////////////////////
                            ' ORIGINAL VARIABLES
                            '     IMFAsyncResult *pResult _
                            '/////////////////////////////////////////////////////
                            '//  Callback for the asynchronous BeginGetEvent method.
                            'PART OF IMFAsyncCallback
                            'METHOD Invoke( _                            'CPlayer Method
                            '     BYVAL pResult AS IMFAsyncResult _                  ' __in IMFAsyncResult *pResult
                            '   ) AS LONG
                            '
                                '? "Invoke"
                        
                                [/color][color=0000C0]LOCAL [/color][color=000000]hr [/color][color=0000C0]AS LONG
                                LOCAL [/color][color=000000]meType [/color][color=0000C0]AS LONG [/color][color=007F00]'MediaEventType
                                [/color][color=0000C0]LOCAL [/color][color=000000]pEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent
                        
                                [/color][color=007F00]'MediaEventType meType = %MEUnknown  '// Event type       ???
                                'IMFMediaEvent *pEvent = NOTHING
                                [/color][color=000000]meType [/color][color=8000FF]= [/color][color=000000]%MEUnknown  [/color][color=007F00]'// Event type       ???
                        
                                '// Get the event from the event queue.
                                [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.EndGetEvent[/color][color=8000FF]([/color][color=000000]pAsyncResult[/color][color=8000FF], [/color][color=000000]pEvent[/color][color=8000FF])
                                [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                    GOTO [/color][color=000000]done
                                [/color][color=0000C0]END IF
                        
                                [/color][color=007F00]'// Get the event type.
                                [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pEvent.GetType[/color][color=8000FF]([/color][color=000000]meType[/color][color=8000FF])
                                [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                    GOTO [/color][color=000000]done
                                [/color][color=0000C0]END IF
                        
                                IF [/color][color=8000FF]([/color][color=000000]meType [/color][color=8000FF]= [/color][color=000000]%MESessionClosed[/color][color=8000FF]) [/color][color=0000C0]THEN
                                    [/color][color=007F00]'// The session was closed.
                                    '// The application is waiting on the m_hCloseEvent event handle.
                                    '// Sets the specified event object to the signaled state.
                                    [/color][color=000000]SetEvent[/color][color=8000FF]([/color][color=000000]m_hCloseEvent[/color][color=8000FF])
                                [/color][color=0000C0]ELSE
                                    [/color][color=007F00]'' =====================================================================================
                                    'METHOD BeginGetEvent ( _                             ' VTable offset = 16
                                    '  BYVAL pCallback AS IMFAsyncCallback _              ' __in IMFAsyncCallback *pCallback
                                    ', BYVAL punkState AS IUnknown _                      ' __in IUnknown *punkState
                                    ') AS LONG                                            ' HRESULT
                                    '' =====================================================================================
                                    'Reference found in:
                                    'IMFMediaSession
                                    'IMFMediaSource
                                    'IMFMediaStream
                                    'IMFStreamSink
                                    'IMFMediaEventQueue
                                    [/color][color=0000C0]LOCAL [/color][color=000000]punkState [/color][color=0000C0]AS IUNKNOWN
                        
                                    [/color][color=007F00]'// For all other events, get the next event in the queue.
                                    [/color][color=000000]hr [/color][color=8000FF]= [/color][color=000000]pMediaSession.BeginGetEvent[/color][color=8000FF]([/color][color=000000]pCallback[/color][color=8000FF], [/color][color=000000]punkState[/color][color=8000FF])            [/color][color=007F00]'(THIS, %NULL) ?????
                                    [/color][color=0000C0]IF [/color][color=000000]FAILED[/color][color=8000FF]([/color][color=000000]hr[/color][color=8000FF]) [/color][color=0000C0]THEN
                                        GOTO [/color][color=000000]done
                                    [/color][color=0000C0]END IF
                                END IF
                        
                                [/color][color=007F00]'// Check the application state.
                        
                                '// If a call to IMFMediaSession::Close is pending, it means the
                                '// application is waiting on the m_hCloseEvent event and
                                '// the application's message loop is blocked.
                        
                                '// Otherwise, post a private window message to the application.
                        
                                [/color][color=0000C0]IF [/color][color=8000FF]([/color][color=000000]m_state [/color][color=8000FF]<> [/color][color=000000]%Closing[/color][color=8000FF]) [/color][color=0000C0]THEN
                                    [/color][color=007F00]'// Leave a reference count on the event.
                                    [/color][color=000000]pEvent.AddRef[/color][color=8000FF]()
                        
                                    [/color][color=007F00]'PostMessage(m_hwndEvent, %WM_APP_PLAYER_EVENT, pEvent, meType) '(WPARAM)pEvent, (LPARAM)meType)   '?????????????
                                    'CONTROL SEND CBHNDL, %TrackbarSpeed, %TBM_SETPOS, pEvent, meType  'Set initial position
                                    [/color][color=0000C0]CONTROL SEND [/color][color=000000]hDlg[/color][color=8000FF], [/color][color=000000]%WM_APP_PLAYER_EVENT[/color][color=8000FF], [/color][color=000000]%BM_CLICK[/color][color=8000FF], [/color][color=000000]%NULL[/color][color=8000FF], [/color][color=000000]meType
                                [/color][color=0000C0]END IF
                        
                            [/color][color=000000]done[/color][color=8000FF]:
                                [/color][color=000000]SafeRelease[/color][color=8000FF]([/color][color=000000]pEvent[/color][color=8000FF])
                                [/color][color=0000C0]METHOD [/color][color=8000FF]= [/color][color=0000C0]%S_OK
                            END METHOD
                        
                        END INTERFACE
                        
                        END CLASS
                        
                        
                        [/color][color=007F00]'_________________________________________________________________
                        '
                        ' SUB SetButtonFocus(hDlgName, %ID_SELECTEDBUTTON, %ID_DEFAULTBUTTON)
                        '_________________________________________________________________
                        
                        [/color][color=0000C0]SUB [/color][color=000000]SetButtonFocus[/color][color=8000FF]([/color][color=0000C0]BYVAL [/color][color=000000]hDlgName [/color][color=0000C0]AS DWORD[/color][color=8000FF], [/color][color=000000]AAA [/color][color=0000C0]AS INTEGER[/color][color=8000FF], [/color][color=000000]BBB [/color][color=0000C0]AS INTEGER[/color][color=8000FF])
                        
                          [/color][color=0000C0]CONTROL SEND [/color][color=000000]hDlgName[/color][color=8000FF], [/color][color=000000]AAA[/color][color=8000FF], [/color][color=000000]%BM_SETSTYLE[/color][color=8000FF], [/color][color=0000C0]%BS_PUSHBUTTON[/color][color=8000FF], [/color][color=000000]%TRUE
                          [/color][color=0000C0]CONTROL SET FOCUS [/color][color=000000]hDlgName[/color][color=8000FF], [/color][color=000000]BBB
                          [/color][color=0000C0]CONTROL SEND [/color][color=000000]hDlgName[/color][color=8000FF], [/color][color=000000]BBB[/color][color=8000FF], [/color][color=000000]%BM_SETSTYLE[/color][color=8000FF], [/color][color=0000C0]%BS_DEFPUSHBUTTON[/color][color=8000FF], [/color][color=000000]%TRUE
                        
                        [/color][color=0000C0]END SUB
                        
                        
                        [/color][color=007F00]' ########################################################################################
                        ' Interface name = IMFMediaSource
                        ' IID = 279A808D-AEC7-40C8-9C6B-A6B492C78A66
                        ' Inherited interface = IMFMediaEventGenerator
                        ' ########################################################################################
                        
                        '#IF NOT %DEF(%IMFMediaSource_INTERFACE_DEFINED)
                        '    %IMFMediaSource_INTERFACE_DEFINED = 1
                        '
                        '$IID_IMFMediaSource = GUID$("{279A808D-AEC7-40C8-9C6B-A6B492C78A66}")
                        '
                        [/color][color=0000C0]INTERFACE [/color][color=000000]IMFMediaSource $IID_IMFMediaSource
                        
                           [/color][color=0000C0]INHERIT IUNKNOWN
                        
                           [/color][color=007F00]' =====================================================================================
                           ' IMFMediaEventGenerator methods
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]GetEvent [/color][color=8000FF]( [/color][color=0000C0]_                                  [/color][color=007F00]' VTable offset = 12
                             [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_                   [/color][color=007F00]' __out IMFMediaEvent **ppEvent
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]BeginGetEvent [/color][color=8000FF]( [/color][color=0000C0]_                             [/color][color=007F00]' VTable offset = 16
                             [/color][color=0000C0]BYVAL [/color][color=000000]pCallback [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallback [/color][color=0000C0]_              [/color][color=007F00]' __in IMFAsyncCallback *pCallback
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]punkState [/color][color=0000C0]AS IUNKNOWN _                      [/color][color=007F00]' __in IUnknown *punkState
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]EndGetEvent [/color][color=8000FF]( [/color][color=0000C0]_                               [/color][color=007F00]' VTable offset = 20
                             [/color][color=0000C0]BYVAL [/color][color=000000]pResult [/color][color=0000C0]AS [/color][color=000000]IMFAsyncResult [/color][color=0000C0]_                  [/color][color=007F00]' __in IMFAsyncResult *pResult
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppEvent [/color][color=0000C0]AS [/color][color=000000]IMFMediaEvent [/color][color=0000C0]_                   [/color][color=007F00]' __out IMFMediaEvent **ppEvent
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]QueueEvent [/color][color=8000FF]( [/color][color=0000C0]_                                [/color][color=007F00]' VTable offset = 24
                             [/color][color=0000C0]BYVAL [/color][color=000000]met [/color][color=0000C0]AS DWORD _                               [/color][color=007F00]' __in MediaEventType met
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]guidExtendedType [/color][color=0000C0]AS GUID _                   [/color][color=007F00]' __in REFGUID guidExtendedType
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]hrStatus [/color][color=0000C0]AS LONG _                           [/color][color=007F00]' __in HRESULT hrStatus
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pvValue [/color][color=0000C0]AS [/color][color=000000]PROPVARIANT [/color][color=0000C0]_                     [/color][color=007F00]' __in const PROPVARIANT *pvValue
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                        
                           ' =====================================================================================
                           ' IMFMediaSource methods
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]GetCharacteristics [/color][color=8000FF]( [/color][color=0000C0]_                        [/color][color=007F00]' VTable offset = 28
                             [/color][color=0000C0]BYREF [/color][color=000000]pdwCharacteristics [/color][color=0000C0]AS DWORD _                [/color][color=007F00]' __out DWORD *pdwCharacteristics
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]CreatePresentationDescriptor [/color][color=8000FF]( [/color][color=0000C0]_              [/color][color=007F00]' VTable offset = 32
                             [/color][color=0000C0]BYREF [/color][color=000000]ppPresentationDescriptor [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor [/color][color=0000C0]_ [/color][color=007F00]' __out IMFPresentationDescriptor **ppPresentationDescriptor
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]Start [/color][color=8000FF]( [/color][color=0000C0]_                                     [/color][color=007F00]' VTable offset = 36
                             [/color][color=0000C0]BYVAL [/color][color=000000]pPresentationDescriptor [/color][color=0000C0]AS [/color][color=000000]IMFPresentationDescriptor [/color][color=0000C0]_ [/color][color=007F00]' __in IMFPresentationDescriptor *pPresentationDescriptor
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pguidTimeFormat [/color][color=0000C0]AS GUID _                    [/color][color=007F00]' __in const GUID *pguidTimeFormat
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pvarStartPosition [/color][color=0000C0]AS [/color][color=000000]PROPVARIANT [/color][color=0000C0]_           [/color][color=007F00]' __in const PROPVARIANT *pvarStartPosition
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD STOP [/color][color=8000FF]( [/color][color=0000C0]_                                      [/color][color=007F00]' VTable offset = 40
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]Pause [/color][color=8000FF]( [/color][color=0000C0]_                                     [/color][color=007F00]' VTable offset = 44
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]Shutdown [/color][color=8000FF]( [/color][color=0000C0]_                                  [/color][color=007F00]' VTable offset = 48
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                        
                        [/color][color=0000C0]END INTERFACE
                        
                        
                        [/color][color=007F00]' ########################################################################################
                        ' Interface name = IMFSourceResolver
                        ' IID = FBE5A32D-A497-4b61-BB85-97B1A848A6E3
                        ' Inherited interface = IUnknown
                        ' ########################################################################################
                        
                        '#IF NOT %DEF(%IMFSourceResolver_INTERFACE_DEFINED)
                        '    %IMFSourceResolver_INTERFACE_DEFINED = 1
                        '
                        '$IID_IMFSourceResolver = GUID$("{FBE5A32D-A497-4b61-BB85-97B1A848A6E3}")
                        
                        [/color][color=0000C0]INTERFACE [/color][color=000000]IMFSourceResolver $IID_IMFSourceResolver
                        
                           [/color][color=0000C0]INHERIT IUNKNOWN
                        
                           [/color][color=007F00]' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]CreateObjectFromURL [/color][color=8000FF]( [/color][color=0000C0]_                       [/color][color=007F00]' VTable offset = 12
                             [/color][color=0000C0]BYREF [/color][color=000000]pwszURL [/color][color=0000C0]AS WSTRINGZ _                        [/color][color=007F00]' __in LPCWSTR pwszURL
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pProps [/color][color=0000C0]AS [/color][color=000000]IPropertyStore [/color][color=0000C0]_                   [/color][color=007F00]' __in IPropertyStore *pProps
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pObjectType [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __out MF_OBJECT_TYPE *pObjectType
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                       [/color][color=007F00]' __out IUnknown **ppObject
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]CreateObjectFromByteStream [/color][color=8000FF]( [/color][color=0000C0]_                [/color][color=007F00]' VTable offset = 16
                             [/color][color=0000C0]BYVAL [/color][color=000000]pByteStream [/color][color=0000C0]AS [/color][color=000000]IMFByteStream [/color][color=0000C0]_               [/color][color=007F00]' __in IMFByteStream *pByteStream
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pwszURL [/color][color=0000C0]AS WSTRINGZ _                        [/color][color=007F00]' __in LPCWSTR pwszURL
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pProps [/color][color=0000C0]AS [/color][color=000000]IPropertyStore [/color][color=0000C0]_                   [/color][color=007F00]' __in IPropertyStore *pProps
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pObjectType [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __out MF_OBJECT_TYPE *pObjectType
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                       [/color][color=007F00]' __out IUnknown **ppObject
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]BeginCreateObjectFromURL [/color][color=8000FF]( [/color][color=0000C0]_                  [/color][color=007F00]' VTable offset = 20
                             [/color][color=0000C0]BYREF [/color][color=000000]pwszURL [/color][color=0000C0]AS WSTRINGZ _                        [/color][color=007F00]' __in LPCWSTR pwszURL
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pProps [/color][color=0000C0]AS [/color][color=000000]IPropertyStore [/color][color=0000C0]_                   [/color][color=007F00]' __in IPropertyStore *pProps
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppIUnknownCancelCookie [/color][color=0000C0]AS IUNKNOWN _         [/color][color=007F00]' __out IUnknown **ppIUnknownCancelCookie
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pCallback [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallback [/color][color=0000C0]_              [/color][color=007F00]' __in IMFAsyncCallback *pCallback
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]punkState [/color][color=0000C0]AS IUNKNOWN _                      [/color][color=007F00]' __in IUnknown *punkState
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]EndCreateObjectFromURL [/color][color=8000FF]( [/color][color=0000C0]_                    [/color][color=007F00]' VTable offset = 24
                             [/color][color=0000C0]BYVAL [/color][color=000000]pResult [/color][color=0000C0]AS [/color][color=000000]IMFAsyncResult [/color][color=0000C0]_                  [/color][color=007F00]' __in IMFAsyncResult *pResult
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pObjectType [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __out MF_OBJECT_TYPE *pObjectType
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                       [/color][color=007F00]' __out IUnknown **ppObject
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]BeginCreateObjectFromByteStream [/color][color=8000FF]( [/color][color=0000C0]_           [/color][color=007F00]' VTable offset = 28
                             [/color][color=0000C0]BYVAL [/color][color=000000]pByteStream [/color][color=0000C0]AS [/color][color=000000]IMFByteStream [/color][color=0000C0]_               [/color][color=007F00]' __in IMFByteStream *pByteStream
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pwszURL [/color][color=0000C0]AS WSTRINGZ _                        [/color][color=007F00]' __in LPCWSTR pwszURL
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pProps [/color][color=0000C0]AS [/color][color=000000]IPropertyStore [/color][color=0000C0]_                   [/color][color=007F00]' __in IPropertyStore *pProps
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppIUnknownCancelCookie [/color][color=0000C0]AS IUNKNOWN _         [/color][color=007F00]' __out IUnknown **ppIUnknownCancelCookie
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pCallback [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallback [/color][color=0000C0]_              [/color][color=007F00]' __in IMFAsyncCallback *pCallback
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]punkState [/color][color=0000C0]AS IUNKNOWN _                      [/color][color=007F00]' __in IUnknown *punkState
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]EndCreateObjectFromByteStream [/color][color=8000FF]( [/color][color=0000C0]_             [/color][color=007F00]' VTable offset = 32
                             [/color][color=0000C0]BYVAL [/color][color=000000]pResult [/color][color=0000C0]AS [/color][color=000000]IMFAsyncResult [/color][color=0000C0]_                  [/color][color=007F00]' __in IMFAsyncResult *pResult
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pObjectType [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __out MF_OBJECT_TYPE *pObjectType
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                       [/color][color=007F00]' __out IUnknown **ppObject
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]CancelObjectCreation [/color][color=8000FF]( [/color][color=0000C0]_                      [/color][color=007F00]' VTable offset = 36
                             [/color][color=0000C0]BYVAL [/color][color=000000]pIUnknownCancelCookie [/color][color=0000C0]AS IUNKNOWN _          [/color][color=007F00]' __in IUnknown *pIUnknownCancelCookie
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                        
                        [/color][color=0000C0]END INTERFACE
                        
                        
                        [/color][color=007F00]' ########################################################################################
                        ' Interface name = IMFSchemeHandler
                        ' IID = 6D4C7B74-52A0-4BB7-B0DB-55F29F47A668
                        ' Inherited interface = IUnknown
                        ' ########################################################################################
                        
                        '#IF NOT %DEF(%IMFSchemeHandler_INTERFACE_DEFINED)
                            [/color][color=000000]%IMFSchemeHandler_INTERFACE_DEFINED [/color][color=8000FF]= [/color][color=000000]1
                        
                        [/color][color=007F00]'$IID_IMFSchemeHandler = GUID$("{6D4C7B74-52A0-4BB7-B0DB-55F29F47A668}")
                        
                        [/color][color=0000C0]INTERFACE [/color][color=000000]IMFSchemeHandler $IID_IMFSchemeHandler
                        
                           [/color][color=0000C0]INHERIT IUNKNOWN
                        
                           [/color][color=007F00]' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]BeginCreateObject [/color][color=8000FF]( [/color][color=0000C0]_                         [/color][color=007F00]' VTable offset = 12
                             [/color][color=0000C0]BYREF [/color][color=000000]pwszURL [/color][color=0000C0]AS WSTRINGZ _                        [/color][color=007F00]' __in LPCWSTR pwszURL
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]dwFlags [/color][color=0000C0]AS DWORD _                           [/color][color=007F00]' __in DWORD dwFlags
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pProps [/color][color=0000C0]AS [/color][color=000000]IPropertyStore [/color][color=0000C0]_                   [/color][color=007F00]' __in IPropertyStore *pProps
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppIUnknownCancelCookie [/color][color=0000C0]AS IUNKNOWN _         [/color][color=007F00]' __out IUnknown **ppIUnknownCancelCookie
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]pCallback [/color][color=0000C0]AS [/color][color=000000]IMFAsyncCallback [/color][color=0000C0]_              [/color][color=007F00]' __in IMFAsyncCallback *pCallback
                           [/color][color=8000FF], [/color][color=0000C0]BYVAL [/color][color=000000]punkState [/color][color=0000C0]AS IUNKNOWN _                      [/color][color=007F00]' __in IUnknown *punkState
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]EndCreateObject [/color][color=8000FF]( [/color][color=0000C0]_                           [/color][color=007F00]' VTable offset = 16
                             [/color][color=0000C0]BYVAL [/color][color=000000]pResult [/color][color=0000C0]AS [/color][color=000000]IMFAsyncResult [/color][color=0000C0]_                  [/color][color=007F00]' __in IMFAsyncResult *pResult
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]pObjectType [/color][color=0000C0]AS LONG _                        [/color][color=007F00]' __out MF_OBJECT_TYPE *pObjectType
                           [/color][color=8000FF], [/color][color=0000C0]BYREF [/color][color=000000]ppObject [/color][color=0000C0]AS IUNKNOWN _                       [/color][color=007F00]' __out IUnknown **ppObject
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                           [/color][color=0000C0]METHOD [/color][color=000000]CancelObjectCreation [/color][color=8000FF]( [/color][color=0000C0]_                      [/color][color=007F00]' VTable offset = 20
                             [/color][color=0000C0]BYVAL [/color][color=000000]pIUnknownCancelCookie [/color][color=0000C0]AS IUNKNOWN _          [/color][color=007F00]' __in IUnknown *pIUnknownCancelCookie
                           [/color][color=8000FF]) [/color][color=0000C0]AS LONG                                            [/color][color=007F00]' HRESULT
                           ' =====================================================================================
                        
                        [/color][color=0000C0]END INTERFACE[/color]

                        Comment


                        • #52

                          This is the Event Viewer for MediaFoundation-Platform -> Media Foundation Platform

                          MFStartup returned 0x0
                          Source Resolver Context(0x96efa0) Resolve C:\Users\Public\Music\Billy Idol\The Very Best of Billy Idol\05 Eyes Without a Face.mp3 flags 0x1
                          Query Media Source clsid {477ec299-1421-4bdd-971f-7ccb933f21ad} do not use: false.
                          Source Resolver Context(0x96efa0) Trying Scheme Handler "File Scheme Handler"
                          Source Resolver Context(0x96efa0) SchemeHandler Result 0x0
                          Query Media Source clsid {a82e50ba-8e92-41eb-9df2-433f50ec2993} do not use: false.
                          Source Resolver Context(0x96efa0) Trying Byte Scheme Handler CLSID("MP3 Byte Stream Handler")
                          Source Resolver Context(0x96efa0) Byte stream Handler Result 0x0

                          It stops there and crashes the program.

                          The next step would be:
                          Source Resolver Context(0x96efa0) Resolving file:///C:/Users/Public/Music/Billy%20Idol/The%20Very%20Best%20of%20Billy%20Idol/05%20Eyes%20Without%20a%20Face.mp3 returned 0x0

                          but it doesn't get there.

                          The program memory allocation goes from 1.6 MB to 3 MB and then crashes. So it appears that the stream Handler is reading the file and trying to resolve it.
                          Any ideas?


                          Last edited by Jim Fritts; 14 Jun 2018, 02:05 PM.

                          Comment


                          • #53
                            The Source Resolver cannot resolve anything. Not even a short wav file. What gives?

                            Now I'm trying CreateObjectFromByteStream but it will not compile insisting that the dwFlags Parameter mismatches definition.

                            Even though I assigned it as a local DWORD and your include MFIDL identifies it as a dword value. This is crazy.


                            ' =====================================================================================
                            METHOD CreateObjectFromByteStream ( _ ' VTable offset = 16
                            BYVAL pByteStream AS IMFByteStream _ ' __in IMFByteStream *pByteStream
                            , BYREF pwszURL AS WSTRINGZ _ ' __in LPCWSTR pwszURL
                            , BYVAL dwFlags AS DWORD _ ' __in DWORD dwFlags
                            , BYVAL pProps AS IPropertyStore _ ' __in IPropertyStore *pProps
                            , BYREF pObjectType AS LONG _ ' __out MF_OBJECT_TYPE *pObjectType
                            , BYREF ppObject AS IUnknown _ ' __out IUnknown **ppObject
                            ) AS LONG ' HRESULT
                            ' =====================================================================================

                            The compiler will not accept this %MF_RESOLUTION_MEDIASOURCE either...

                            Unbelievable!

                            As it turns out the dwFlags was a problem with my app. I switched over to another development app and dwFlags now is accepted by the compiler. Whew! Will attempt the CreateObjectFromByteStream again. Soon
                            Last edited by Jim Fritts; 15 Jun 2018, 06:09 PM.

                            Comment


                            • #54
                              Code:
                              ' METHOD CreateObjectFromURL ( _                       ' VTable offset = 12
                                          '   BYREF pwszURL AS WSTRINGZ _                        ' __in LPCWSTR pwszURL
                                          ' , BYVAL dwFlags AS DWORD _                           ' __in DWORD dwFlags
                                          ' , BYVAL pProps AS IPropertyStore _                   ' __in IPropertyStore *pProps
                                          [color=red]' , BYVAL pObjectType AS LONG[/color] _                        ' __out MF_OBJECT_TYPE *pObjectType
                                          ' , BYREF ppObject AS IUnknown _                       ' __out IUnknown **ppObject
                                          ' ) AS LONG                                            ' HRESULT
                              If this is how it's defined in whatever headers you're using, then it's wrong. That param should be byref otherwise the function will never return success.

                              Comment


                              • #55
                                I thought so too when I first looked at it. Jose' includes do not provide MF_OBJECT_TYPE per se only the values that are passed.
                                Code:
                                ' enum MF_OBJECT_TYPE
                                %MF_OBJECT_MEDIASOURCE = 0
                                %MF_OBJECT_BYTESTREAM  = %MF_OBJECT_MEDIASOURCE + 1
                                %MF_OBJECT_INVALID     = %MF_OBJECT_BYTESTREAM  + 1
                                EndCreateObjectFromURL which is an asynchronous method has it BYREF but that is the counterpart to BeginCreateObjectFromURL.

                                Sadly the asynchronous methods crash as well. At this point I am mentally challenged when it comes to creating a media source. No matter what I try it never works.

                                Too bad Jose' is not that interested. Allegedly.

                                Comment


                                • #56
                                  It is obvious that I did a mistake and that this parameter must be declared BYREF. It should also be obvious that you must pass a LONG variable that will receive ine of the MF_OBJECT_xxx values, not that you have to pass one of these values.

                                  > Too bad Jose' is not that interested. Allegedly.

                                  I said that I have no time to study all these interfaces and translate all that C++ code. If you were in the right track and only needed some help, I will help you willingly, but it is evident that you don't fully understand how to work with COM with PB and you're trying to do a literal translation of the C++ code.

                                  For example, why you're calling this function

                                  Code:
                                  FUNCTION SafeRelease(BYREF ppT AS IUNKNOWN) AS LONG
                                      IF ISOBJECT(ppT) THEN
                                          ppT.Release
                                          ppT = NOTHING
                                      END IF
                                  END FUNCTION
                                  SafeRelease(pMediaSource), etc.

                                  When you only need to use pMediaSource = NOTHING ?

                                  Do you know what setting an object variable to NOTHING does? I will tell you: to call the release method.

                                  Why are you implementing IMFAsyncCallbackImpl inside the CPLayer class, and without the correct GUID? Do you know how events sinks work?
                                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                                  Comment


                                  • #57
                                    Sorry Jose' I know you are busy. I used the SafeRelease just in case I missed something by using = NOTHING. I had = NOTHING in the previous version. So far I have not found the CPlayer class GUID or IID. The invoke seems to work nicely when the Session is closed. I have to have a Source created to test it further. I used the IMFAsyncCallbackImpl for the CPlayer for no special reason. Like I said I am mentally challenged right now.

                                    I just needed your assurance that changing to BYREF was the right thing to do. Thank you.

                                    Yahoo!!!!
                                    The Media Source was created.

                                    Comment


                                    • #58
                                      This is a start, to show you how to translate the code. Read the comments.
                                      I haven't time to finish it. See if you can continue.
                                      Don't forget to modify CreateObjectFromURL in the "mfidl.inc" file.

                                      Code:
                                      #COMPILE EXE
                                      #DIM ALL
                                      %UNICODE = 1
                                      #INCLUDE ONCE "windows.inc"
                                      #INCLUDE ONCE "mfapi.inc"
                                      #INCLUDE ONCE "mfidl.inc"
                                      #INCLUDE ONCE "evr.inc"  'needed for video display control
                                      #INCLUDE ONCE "Mferror.inc"
                                      
                                      ENUM PlayerState  'm_state values
                                         Closed = 0     '// No session.
                                         Ready          '// Session was created, ready to open a file.
                                         OpenPending    '// Session is opening a file.
                                         Started        '// Session is playing a file.
                                         Paused         '// Session is paused.
                                         Stopped        '// Session is stopped (ready to play).
                                         Closing        '// Application has closed the session, but is waiting for MESessionClosed.
                                      END ENUM
                                      
                                      CLASS CPlayer
                                      
                                         INSTANCE m_pSession AS IMFMediaSession
                                         INSTANCE m_pSource AS IMFMediaSource
                                         INSTANCE m_pVideoDisplay AS IMFVideoDisplayControl
                                         INSTANCE m_hwndVideo AS DWORD
                                         INSTANCE m_hwndEvent AS DWORD
                                         INSTANCE m_state AS LONG
                                         INSTANCE m_hCloseEvent AS DWORD
                                      '   INSTANCE m_pContentProtectionManager AS IMFContentProtectionManager
                                      
                                         CLASS METHOD Create
                                         END METHOD
                                      
                                         CLASS METHOD Destroy
                                         END METHOD
                                      
                                         INTERFACE IPlayer : INHERIT IUnknown
                                      
                                         ' ///////////////////////////////////////////////////////////////////////
                                         ' //  Name: CreateInstance
                                         ' //  Description:  Static class method to create the CPlayer object.
                                         ' //  
                                         ' //  hVideo:   Handle to the video window.
                                         ' //  hEvent:   Handle to the window to receive notifications.
                                         ' //  ppPlayer: Receives an AddRef's pointer to the CPlayer object.
                                         ' //            The caller must release the pointer.
                                         ' /////////////////////////////////////////////////////////////////////////
                                         ' // Note: We create an instance of the class with
                                         ' // DIM pPlayer AS CPlayer : pPlayer = CLASS "CPlayer" and the PB class manages
                                         ' // automatically reference counting. Therefore all we need is to store the passed values
                                         ' // and call the Initialize method.
                                         METHOD CreateInstance (BYVAL hVideo AS DWORD, BYVAL hEvent AS DWORD) AS LONG
                                            m_hwndVideo = hVideo
                                            m_hwndEvent = hEvent
                                            m_state = %PlayerState.Ready
                                            METHOD = ME.Initialize
                                         END METHOD
                                      
                                         ' //////////////////////////////////////////////////////////////////////
                                         ' //  Name: Initialize
                                         ' //  Initializes the CPlayer object. This method is called by the
                                         ' //  CreateInstance method.
                                         ' /////////////////////////////////////////////////////////////////////////
                                      
                                         METHOD Initialize () AS LONG
                                            LOCAL hr AS LONG
                                            hr = %S_OK
                                            IF m_hCloseEvent THEN METHOD = %MF_E_ALREADY_INITIALIZED : EXIT METHOD
                                            ' // Start up Media Foundation platform.
                                            hr = MFStartup(%MF_VERSION, 0)
                                            IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                            m_hCloseEvent = CreateEventW(BYVAL %NULL, %FALSE, %FALSE, BYVAL %NULL)
                                            IF m_hCloseEvent = %NULL THEN
                                               METHOD = HRESULT_FROM_WIN32(GetLastError)
                                               EXIT METHOD
                                            END IF
                                            METHOD = hr
                                         END METHOD
                                      
                                         ' // Note: The C++ methods AddRef, Release and QueryInterface aren't needed in a PB class
                                      
                                      
                                         ' ///////////////////////////////////////////////////////////////////////
                                         ' //  Name: OpenURL
                                         ' //  Description:  Opens a URL for playback.
                                         ' /////////////////////////////////////////////////////////////////////////
                                      
                                         METHOD OpenURL(BYREF sURL AS WSTRINGZ) AS LONG
                                            ' // 1. Create a new media session.
                                            ' // 2. Create the media source.
                                            ' // 3. Create the topology.
                                            ' // 4. Queue the topology [asynchronous]
                                            ' // 5. Start playback [asynchronous - does not happen in this method.]
                                      
                                            LOCAL hr AS LONG
                                            LOCAL pTopology AS IMFTopology
                                      
                                            ' // Create the media session.
                                            hr = ME.CreateSession
                                            IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            ' // Create the media source.
                                            hr = ME.CreateMediaSource(sURL)
                                            IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            ' // Create a partial topology.
                                      '      hr = ME.CreateTopologyFromSource(pTopology)
                                      '      IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            ' // Set the topology on the media session.
                                      '      hr = ME.SetTopology(0, pTopology)
                                      '      IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            ' // Set our state to "open pending"
                                            m_state = %PlayerState.OpenPending
                                      
                                            METHOD = hr
                                      
                                         END METHOD
                                      
                                         ' ///////////////////////////////////////////////////////////////////////
                                         ' //  Name: CreateSession
                                         ' //  Description:  Creates a new instance of the media session.
                                         ' /////////////////////////////////////////////////////////////////////////
                                      
                                         METHOD CreateSession () AS LONG
                                            LOCAL hr AS LONG
                                            hr = %S_OK
                                      
                                            LOCAL pAttributes AS IMFAttributes
                                            LOCAL pEnablerActivate AS IMFActivate
                                      
                                            ' // Close the old session, if any.
                                      '      hr = ME.CloseSession
                                      '      IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            m_state = %PlayerState.Closed
                                      
                                            ' // Create a new attribute store.
                                            hr = MFCreateAttributes(pAttributes, 1)
                                            IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                           ' // *** The following code will need to write a ContentProtectionManager class ***
                                      '       // Create the content protection manager.
                                      '       assert(m_pContentProtectionManager == NULL); // Was released in CloseSession
                                      '       CHECK_HR(hr = ContentProtectionManager::CreateInstance(
                                      '               m_hwndEvent,
                                      '               &m_pContentProtectionManager
                                      '               ));
                                      '       // Set the MF_SESSION_CONTENT_PROTECTION_MANAGER attribute with a pointer
                                      '       // to the content protection manager.
                                      '       CHECK_HR(hr = pAttributes->SetUnknown(
                                      '               MF_SESSION_CONTENT_PROTECTION_MANAGER,
                                      '               (IMFContentProtectionManager*)m_pContentProtectionManager
                                      '               ));
                                      '       // Create the PMP media session.
                                      '       CHECK_HR(hr = MFCreatePMPMediaSession(
                                      '               0, // Can use this flag: MFPMPSESSION_UNPROTECTED_PROCESS
                                      '               pAttributes,
                                      '               &m_pSession,
                                      '               &pEnablerActivate
                                      '               ));
                                      
                                      '       // TODO:
                                      
                                      '       // If MFCreatePMPMediaSession fails it might return an IMFActivate pointer.
                                      '       // This indicates that a trusted binary failed to load in the protected process.
                                      '       // An application can use the IMFActivate pointer to create an enabler object, which
                                      '       // provides revocation and renewal information for the component that failed to
                                      '       // load.
                                      
                                      '       // This sample does not demonstrate that feature. Instead, we simply treat this
                                      '       // case as a playback failure.
                                      
                                      
                                      '       // Start pulling events from the media session
                                      '       CHECK_HR(hr = m_pSession->BeginGetEvent((IMFAsyncCallback*)this, NULL));
                                      
                                            METHOD = hr
                                      
                                         END METHOD
                                      
                                         ' ///////////////////////////////////////////////////////////////////////
                                         ' //  Name: CreateMediaSource
                                         ' //  Description:  Create a media source from a URL.
                                         ' //
                                         ' //  sURL: The URL to open.
                                         ' /////////////////////////////////////////////////////////////////////////
                                      
                                         METHOD CreateMediaSource(BYREF sURL AS WSTRINGZ) AS LONG
                                            LOCAL hr AS LONG
                                            hr = %S_OK
                                            LOCAL ObjectType AS LONG
                                            ObjectType = %MF_OBJECT_INVALID
                                      
                                            LOCAL pSourceResolver AS IMFSourceResolver
                                            LOCAL pSource AS IUnknown
                                      
                                            m_pSource = NOTHING
                                      
                                            ' // Create the source resolver.
                                            hr = MFCreateSourceResolver(pSourceResolver)
                                            IF hr <> %S_OK THEN METHOD = hr : EXIT METHOD
                                      
                                            ' // Use the source resolver to create the media source.
                                      
                                            ' // Note: For simplicity this sample uses the synchronous method on
                                            ' // IMFSourceResolver to create the media source. However, creating a
                                            ' // media source can take a noticeable amount of time, especially for
                                            ' // a network source. For a more responsive UI, use the asynchronous
                                            ' // BeginCreateObjectFromURL method.
                                      
                                            hr = pSourceResolver.CreateObjectFromURL ( _
                                                        sURL, _                        ' // URL of the source.
                                                        %MF_RESOLUTION_MEDIASOURCE, _  ' // Create a source object.
                                                        NOTHING, _                     ' // Optional property store.
                                                        ObjectType, _                  ' // Receives the created object type.
                                                        pSource _                      ' // Receives a pointer to the media source.
                                                     )
                                      
                                            ' // Get the IMFMediaSource interface from the media source.
                                            ' CHECK_HR(hr = pSource->QueryInterface(__uuidof(IMFMediaSource), (void**)&m_pSource));
                                            ' Note: When assigning an object variable to another, PB does an automatic call to QueryInterface
                                            m_pSource = pSource
                                      
                                            METHOD = hr
                                         END METHOD
                                      
                                         END INTERFACE
                                      
                                      END CLASS
                                      
                                      FUNCTION PBMAIN
                                         ? "Ok"
                                      END FUNCTION
                                      Forum: http://www.jose.it-berater.org/smfforum/index.php

                                      Comment


                                      • #59
                                        Excellent Thank you

                                        Comment


                                        • #60
                                          All,

                                          Historic Event! Today was the first time I was
                                          able to create a topology for my Media Foundation
                                          test app. This process took 22 days. I had to
                                          translate C/C++ code to PowerBasic source code.
                                          However, it is still not playing. I'll get there eventually.

                                          This book is every helpful...

                                          Developing Microsoft Media Foundation Applications

                                          The electronic version is online and free.

                                          Comment

                                          Working...
                                          X