Programación General > Visual Basic para principiantes
reproducir mp3, videos en visual basic
maxvaleryedwin:
hola a todos quiciera saber si alguien me puede ayudar a reproducir mp3 en visual necesito un codigo pequeño gracias
:comp:
Jimbenit:
Haz llegado al sitio correcto
Coloca 4 command button, un label y un commoDialog
--- Código: Text ---Option Explicit'Función Api GetShortPathName para obtener _los paths de los archivos en formato cortoPrivate Declare Function GetShortPathName _ Lib "kernel32" _ Alias "GetShortPathNameA" ( _ ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, _ ByVal lBuffer As Long) As Long 'Función Api mciExecute para reproducir los archivos de músicaPrivate Declare Function mciExecute _ Lib "winmm.dll" ( _ ByVal lpstrCommand As String) As LongDim ret As Long, path As String 'Le pasamos el comando PlayPrivate Sub Command1_Click() ejecutar ("Play ") Habilitar "Play"End Sub Private Sub Command2_Click() 'Le pasamos el comando Stop ejecutar ("Stop ") Habilitar "Stop"End Sub 'Le pasamos el comando PausePrivate Sub Command3_Click() ejecutar ("Pause ") Habilitar "Pause"End Sub 'Le pasamos el comando Close a MciExecute para cerrar el dispositivoPrivate Sub Form_Unload(Cancel As Integer) mciExecute "Close All"End Sub 'Botón para abrir seleccionar los archivos de audioPrivate Sub Command4_Click() With CommonDialog1 .Filter = "Archivos Wav|*.wav|Archivos Mp3|*.mp3|Archivos MIDI|*.mid" .ShowOpen If .FileName = "" Then Habilitar "Iniciar" Exit Sub Else 'Le pasamos a la sub que obtiene con _ el Api GetShortPathName el nombre corto del archivo PathCorto .FileName Label1 = .FileName 'cerramos todo mciExecute "Close All" 'Para Habilitar y deshabilitar botones Habilitar "Stop" End If End WithEnd Sub 'Sub que obtiene el path corto del archivo a reproducirPrivate Sub PathCorto(archivo As String)Dim temp As String * 250 'Buffer path = String(255, 0) 'Obtenemos el Path corto ret = GetShortPathName(archivo, temp, 164) 'Sacamos los nulos al path path = Replace(temp, Chr(0), "")End Sub 'Procedimiento que ejecuta el comando con el Api mciExecute'************************************************************Private Sub ejecutar(comando As String) If path = "" Then MsgBox "Error", vbCritical: Exit Sub 'Llamamos a mciExecute pasandole un string que tiene el comando y la ruta mciExecute comando & path End Sub Private Sub Form_Load() Command1.Caption = "Play >>" Command2.Caption = "Stop ||||" Command3.Caption = "Pause ||" Command4.Caption = ":::: Abrir archivo de música ::::" Habilitar "Iniciar" Label1 = "": Label1.AutoSize = TrueEnd Sub Private Sub Habilitar(Accion As String) Select Case Accion Case "Iniciar" Command1.Enabled = False Command2.Enabled = False Command3.Enabled = False Case "Play" Command1.Enabled = False Command2.Enabled = True Command3.Enabled = True Case "Stop" Command1.Enabled = True Command2.Enabled = False Command3.Enabled = False Case "Pause" Command1.Enabled = True Command2.Enabled = True Command3.Enabled = False End SelectEnd Sub
Te sirve???
:good:
maxvaleryedwin:
GRACIAS PUES CLARO Q ME SIRVE TE LO AGRADESCO :beer:
Jimbenit:
Espero volver a verte por aca... no te olvides de esta pagina. Siempre estamos aqui B)
Te aseguro que tus aportes (en lo que puedas aportar, no importa cuan pequeño sea) le serviran a mucha gente especialmente a los que tengan menos experiencia que tu. ^_^
Esta es una forma en la que todos podamos aprender.
Saludos y BIENVENIDO.
:lol:
fraj:
gracias mam , x el dato :D :D
Navegación
[#] Página Siguiente
Ir a la versión completa