Using the media component

Post your Gambas programming questions here.
Post Reply
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Using the media component

Post by bill-lancaster »

If I run this code:-

Code: Select all

Private gPlayer As New MediaPlayer

Public Sub Form_Open()

gPlayer.URL = User.Home &/ "a.mp3"

End

Public Sub Button1_Click()
Print gPlayer.State;; gPlayer.Length
gPlayer.Play()

End
I get 'cannot set status', what is missing?
v 3.11.4
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Using the media component

Post by vuott »

Hello,

about audio file path you have to use:

gPlayer.URL = Media.URL(User.Home &/ "a.mp3")
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
bill-lancaster
Posts: 190
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Using the media component

Post by bill-lancaster »

Thanks vuott
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Using the media component

Post by vuott »

Just a little example:
Private gPlayer As New MediaPlayer

Public Sub Main()
  
  gPlayer.URL = Media.URL(User.Home &/ "a.mp3")

  gPlayer.Play()

  Print Date(0, 0, 0, 0, 0, 0, gPlayer.Length * 1000)

  Repeat
    Write "\r" & CStr(Date(0, 0, 0, 0, 0, 0, gPlayer.Position * 1000))
    Wait 0.001
  Until gPlayer.Position >= gPlayer.Length

  gPlayer.Close

End
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
Post Reply