Empecemos, en el Cliente:
Proyecto>>Referencias>> Seleccionamos: 'ActiveMovie control type Library'
En el clsAudio buscamos:
- 'States wether sound effects are currently activated or not
- Dim sEffectsActivated As Boolean
Y Abajo agregamos:
- '**** Used By MP3 Playing. *****
- Dim IMC As IMediaControl
- Dim IBA As IBasicAudio
- Dim IME As IMediaEvent
- Dim IMPos As IMediaPosition
Ahora al final del clsAudio agregan:
- Public Function MusicMP3Empty() As Boolean
- '**************************************
- '* Created by: Fredrik Alexandersson *
- '* Modify Date: 20/5/2003 *
- '**************************************
- On Error GoTo ErrorHandl
- If ObjPtr(IMC) > 0 Then
- Call MusicMP3Stop
- End If
- Set IBA = Nothing
- Set IME = Nothing
- Set IMPos = Nothing
- Set IMC = Nothing
- MusicMP3Empty = True
- Exit Function
- ErrorHandl:
- MusicMP3Empty = False
- End
- End Function
- ''
- ' Loads a new MP3 file.
- '
- ' @param FilePath The path to the file to be loaded.
- ' @return True If file was properly loaded and started playing, False otherwise.
- Public Function MusicMP3Load(ByVal FilePath As String, Optional ByVal Volume As Long = 0, Optional ByVal Balance As Long = 0) As Boolean '**** Loads a MP3 *****
- '**************************************
- '* Created by: Fredrik Alexandersson *
- '* Modify Date: 20/5/2003 *
- '**************************************
- On Error GoTo ErrorHandl
- If Not FileExist(FilePath, vbArchive) Then Exit Function
- If Not MusicMP3Empty() = True Then GoTo ErrorHandl
- Set IMC = New FilgraphManager
- Call IMC.RenderFile(FilePath)
- Set IBA = IMC
- If Volume < -4000 Then Volume = -4000
- IBA.Volume = Volume
- If Balance > 5000 Then Balance = 5000
- If Balance < -5000 Then Balance = -5000
- IBA.Balance = Balance
- Set IME = IMC
- Set IMPos = IMC
- If ObjPtr(IMPos) Then IMPos.Rate = 1#
- IMPos.CurrentPosition = 0
- MusicMP3Load = True
- Exit Function
- ErrorHandl:
- MusicMP3Load = False
- End Function
- ''
- ' Plays a new MP3 file.
- '
- ' @param FilePath The path to the file to be loaded. If the path is null then play the loaded MP3.
- '
- ' @return True If file was properly loaded and started playing, False otherwise.
- Public Function MusicMP3Play(Optional ByVal FilePath As String = "") As Boolean
- '**************************************
- '* Created by: Fredrik Alexandersson *
- '* Modify Date: 20/5/2003 *
- '**************************************
- On Error GoTo ErrorHandl
- If Not MusicActivated Then Exit Function
- If Not Music Then Exit Function
- If LenB(FilePath) > 0 Then
- If Not MusicMP3Load(FilePath) Then Exit Function
- Else
- If IMC Is Nothing Then Exit Function
- End If
- Call IMC.Run
- MusicMP3Play = True
- Exit Function
- ErrorHandl:
- MusicMP3Play = False
- End Function
- ''
- ' Check if the song need looping.
- Public Sub MusicMP3GetLoop()
- On Error GoTo ErrorHandl
- If IMPos.StopTime = IMPos.CurrentPosition Then
- MusicMP3Stop
- MusicMP3Play
- End If
- ErrorHandl:
- End Sub
- ''
- ' Stop a the current MP3 file.
- '
- ' @return True If file was properly stop, False otherwise.
- Public Function MusicMP3Stop() As Boolean
- '**************************************
- '* Created by: Fredrik Alexandersson *
- '* Modify Date: 20/5/2003 *
- '**************************************
- On Error GoTo ErrorHandl
- ' IMC.Stop
- ' IMPos.CurrentPosition = 0
- MusicMP3Stop = True
- Exit Function
- ErrorHandl:
- MusicMP3Stop = False
- End Function
- ''
- ' Pause a the current MP3 file.
- '
- ' @return True If file was properly pause, False otherwise.
- Public Function MusicMP3Pause() As Boolean
- '***************************************************
- ' Created by: Juan Martín Sotuyo Dodero
- ' Modify Date: 25/6/2004
- '***************************************************
- On Error GoTo ErrorHandl
- Call IMC.Pause
- MusicMP3Pause = True
- Exit Function
- ErrorHandl:
- MusicMP3Pause = False
- End Function
- ''
- ' Set the volume to the current MP3.
- '
- ' @param SoundVolume The new volume to the current MP3.
- ' @return True If the volume was properly change, False otherwise.
- Public Function MusicMP3VolumeSet(ByVal SoundVolume As Long) As Boolean
- '**************************************
- '* Created by: Fredrik Alexandersson *
- '* Modify Date: 20/5/2003 *
- '**************************************
- On Error GoTo ErrorHandl
- If SoundVolume > 0 Then SoundVolume = 0
- If SoundVolume < -4000 Then SoundVolume = -4000
- IBA.Volume = SoundVolume
- MusicMP3VolumeSet = True
- Exit Function
- ErrorHandl:
- MusicMP3VolumeSet = False
- End Function
Listo, con eso ya tienen un sistema de MP3 en su Cliente.
Preguntas:
¿Como hago para cargar el sonido?
Fácil:
- Call Audio.MusicMP3Play(App.path & "\MP3\1.mp3") 'El 1 lo cambian por el Numero del MP3
Ahi cargamos el mp3 1 de la carpeta mp3.
Espero que les sirba.
Adiós.






361![Dragon Ancestral [6] Dragon Ancestral [6]](./images/ranks/Rango35.gif)
![Oraculo [5] Oraculo [5]](./images/ranks/Rango29.gif)

![Legendario Inmortal [2] Legendario Inmortal [2]](./images/ranks/Rango37.gif)
