PowerBuilder Forum

Members Login
Username 
 
Password 
    Remember Me  
Post Info TOPIC: Embedded Windows Media Player


Veteran Member

Status: Offline
Posts: 40
Date:
Embedded Windows Media Player


This thread will discuss handling the Windows Media Player OLE object embedded in a PowerBuilder window.

__________________


Veteran Member

Status: Offline
Posts: 40
Date:

Step 1

With the window painter open, select the OLE object.  This will bring up the window to select the type of OLE object you want to embedd on the window.  Scroll down on the "Create New" tab until you see "Windows Media Player", and select it, and then click the "OK" button.  Then place it on the window.

For future reference, I named this object "ax".  Why?  It comes from when I first started messing around with the object a few years back in VisualBasic, and it was defaulted to "axMediaPlayer_1"...  I shortened it to "ax" because I'm lazy.  So in the future, any code relating to ax.SomeFunctionality( ) is referring to this object.


__________________


Veteran Member

Status: Offline
Posts: 40
Date:

Basic Playback

Basic playback is very simple!

Let's say you have the path to an MP3 file, which is: "C:\Music\myMusicFile.mp3", and it is stored in the variable ls_path. To play this file, all you have to do is set ax's URL property. So,

ax.Object.URL = ls_path

This is supposing that you have not set ax's AutoStart property from its default of TRUE. Personally, I don't like anything to start without me telling it to, so in the open event of my window, I set the AutoStart property:

ax.Object.Settings.AutoStart = FALSE

So now, when the URL property is assigned, how do we get it to play? Easy...

ax.Object.URL = ls_path
ax.Object.Controls.Play( )


-- Edited by thekl0wn at 16:52, 2008-09-15

__________________


Veteran Member

Status: Offline
Posts: 40
Date:

Pausing Playback

Pausing playback is very straightforward as well.  In this example, suppose we have a button named "cb_pause", and when ax is playing, we can hit this button to pause playback, and hit it again to resume where we paused at.  In the Clicked! event of cb_pause:

Long ll_state

ll_state = ax.Object.PlayState

CHOOSE CASE ll_state
  CASE 2
    //ax is paused
    ax.Object.Controls.Play( )

  CASE 3
    //ax is playing
    ax.Object.Controls.Pause( )

  CASE ELSE
    //no action needed...  The ELSE statement itself isn't needed

END CHOOSE



__________________


Newbie

Status: Offline
Posts: 1
Date:

This thread helped me a lot.
Thank you so much!



-- Edited by Peyrock on Wednesday 26th of July 2023 06:23:53 PM

__________________
Page 1 of 1  sorted by
Quick Reply

Please log in to post quick replies.

Tweet this page Post to Digg Post to Del.icio.us


Create your own FREE Forum
Report Abuse
Powered by ActiveBoard