InicioHazlo Tu MismoComo hacer un reproductor con Item (lista de reproducción)

Como hacer un reproductor con Item (lista de reproducción)

Hazlo Tu Mismo10/30/2011
Comenzamos con el Visual Basic 2008

Se necesitan:

8 botones (abrir, borrar, borrar todo, play, pausar, parar, siguiente, anterior)

1 OpenFileDialog (Para abrir los archivos)

2 ListBox (Poner el listbox1 en un extremo, y el listbox2 sobre el listbox1)

1 AxWindowsMediaPlayer (si no lo tienen, hagan click derecho sobre cualquier icono o herramienta dentro del cuadro de herramientas y presiona el botón “Elegir Elementos”, vas a la pestaña “Componentes COM” y buscan “Windows Media Player” esta casi al final de la lista y lo seleccionan y apretan en aceptar. Una vez lo buscamos en el cuadro de Herramientas, lo seleccionan y lo ponen en el form, tardará unos segundos para realizar el procedimiento de agregarlo al form)

Cubrir los controles del AxWindowsMediaPlayer (Opcional) (vamos a darle click, y en sus propiedades buscamos personalizar, y buscamos donde dice full y le ponemos a none)

Ok ahora todo ordenado y a por los códigos:

Código del Botón Abrir:

OpenFileDialog1.Title = "Abrir Archivo"
OpenFileDialog1.Filter = "Mp3[*.Mp3*]|*.Mp3|Wav[*.Wav*]|*.Wav|Todos los Archivos[*.*]|*.*"
OpenFileDialog1.FileName = ""
OpenFileDialog1.ShowDialog()
Try
OpenFileDialog1.OpenFile()
ListBox1.Items.Add(OpenFileDialog1.FileName)
ListBox2.Items.Add(OpenFileDialog1.SafeFileName)
Catch ex As Exception

End Try




Código Botón Borrar: (Este código lo arreglare en poco, mientras pueden usar lo que les dejo)

ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox2.Items.Remove(ListBox2.SelectedItem)



Código Botón Borrar Todo:

ListBox1.Items.Clear()
ListBox2.Items.Clear()



Código Botón Play:

If ListBox2.Items.Count = 0 Then
MsgBox("No hay archivos"
Else
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then
AxWindowsMediaPlayer1.Ctlcontrols.play()
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
Else
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
End If
End If


Código Pausar:


If Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then
Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
Timer1.Start()
Else
Me.AxWindowsMediaPlayer1.Ctlcontrols.pause()
Timer1.Start()
End If



Código Parar:

Me.AxWindowsMediaPlayer1.Ctlcontrols.stop()
Timer1.Stop()



Código Siguiente:

If ListBox1.Items.Count = 0 Then
MsgBox("No hay archivos"
Else
If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
ListBox1.SelectedIndex = 0
ListBox2.SelectedIndex = 0
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
Else
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
ListBox2.SelectedIndex = ListBox2.SelectedIndex + 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
End If
End If



Código Anterior:

If ListBox1.Items.Count = 0 Then
MsgBox("No hay archivos"
Else
If ListBox1.SelectedIndex = 0 Then
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
ListBox2.SelectedIndex = ListBox2.Items.Count - 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
Else
ListBox1.SelectedIndex = ListBox1.SelectedIndex - 1
ListBox2.SelectedIndex = ListBox2.SelectedIndex - 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Timer1.Start()
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name
End If
End If



Código List2 (en el menu de los códigos en la parte donde dice “Click” buscan en “Doubleclick” y ponen este código:

AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Me.Text = "Reproduciendo actualmente: " + AxWindowsMediaPlayer1.currentMedia.name



Hay pienso que ya les salió un reproductor como siempre quisieron en Visual Basic 2008. Ahora pasamos a lo que es en VB6 (Cuando hablo de VB quiero decir Visual Basic para los nuevos en esto).


En Visual Basic 6

Se necesitan:

8 botones (abrir, borrar, borrar todo, play, pausar, parar, anterior, siguiente)

1 CommonDialog (si no lo tienen, hagan click derecho sobre cualquier icono o herramienta dentro del cuadro de herramientas y presiona el botón “Componentes…”, y buscan “Microsoft Commond Dialog Control 6.0” esta casi al final de la lista y lo seleccionan y apretan en aceptar. Una vez lo buscamos en el cuadro de Herramientas, lo seleccionan y lo ponen en el form)

1 Label (Ocúltenlo si es posible; pulsando ensima y en opciones buscan “Visible” y ponen “False”)

2 ListBox (Poner el listbox1 en un extremo, y el listbox2 sobre el listbox1)

1 WindowsMediaPlayer (si no lo tienen, hagan click derecho sobre cualquier icono o herramienta dentro del cuadro de herramientas y presiona el botón “Componentes…”, y buscan “Windows Media Player” esta casi al final de la lista y lo seleccionan y apretan en aceptar. Una vez lo buscamos en el cuadro de Herramientas, lo seleccionan y lo ponen en el form, tardará unos segundos para realizar el procedimiento de agregarlo al form)

Ahora van los códigos:

Código Play:


If Me.WindowsMediaPlayer1.playState = wmppsPaused Then
Me.WindowsMediaPlayer1.Controls.play
Else
If Label1.Caption = "" Then
a =MsgBox("Selecione un archivo para reproducir", vbInformation, "Sin Archivo"
Else
Dim color As Long
Dim pepe As Integer
pepe = List2.ListIndex
List1.ListIndex = List2.ListIndex
color = List2.ItemData(List2.ListIndex)
Label1.Caption = List1.List(List1.ListIndex)
WindowsMediaPlayer1.URL = Label1.Caption
Me.Caption = "Reproduciendo: " + "[ " + Form1.WindowsMediaPlayer1.currentMedia.Name + " ]"
End If
End If


Código Pausar:


If Me.WindowsMediaPlayer1.playState = wmppsPaused Then
Me.WindowsMediaPlayer1.Controls.play
Else
Me.WindowsMediaPlayer1.Controls.pause
End If



Código Parar:


Me.WindowsMediaPlayer1.Controls.stop



Código Anterior:


If List1.ListIndex = -1 Then
MsgBox("No hay Archivos" )
Else
If List1.ListIndex < 1 Then
List1.ListIndex = List1.ListCount - 1
Label1.Caption = List1.List(List1.ListIndex)
List2.ListIndex = List1.ListCount - 1
Label1.Caption = List2.List(List2.ListIndex)
WindowsMediaPlayer1.URL = Label1.Caption
Form1.Caption = "Reproduciendo: " + "[ " + Me.WindowsMediaPlayer1.currentMedia.Name + " ]"
Else
List1.ListIndex = List1.ListIndex - 1
Label1.Caption = List1.List(List1.ListIndex)
List2.ListIndex = List2.ListIndex - 1
Label1.Caption = List2.List(List2.ListIndex)
WindowsMediaPlayer1.URL = Label1.Caption
Form1.Caption = "Reproduciendo: " + "[ " + Me.WindowsMediaPlayer1.currentMedia.Name + " ]"
End If
End If



Código Siguiente:


Dim PRIMERO As STRING
PRIMERO = List1.ListCount - 1
If List1.ListIndex < PRIMERO Then
List2.ListIndex = List2.ListIndex + 1
Label1.Caption = List1.List(Form1.List1.ListIndex)
WindowsMediaPlayer1.URL = Label1.Caption
Me.Caption = "Reproduciendo: " + "[ " + Me.WindowsMediaPlayer1.currentMedia.Name + " ]"

Else
If List1.ListIndex = -1 Then
a = MsgBox("No se encuentra ningun archivo en el PlayList", vbCritical, "Error"
Else
List2.ListIndex = All
List2.ListIndex = List1.ListIndex
Label1.Caption = List1.List(Form1.List1.ListIndex)
WindowsMediaPlayer1.URL = Label1.Caption
Form1.Caption = "Reproduciendo: " + "[ " + Me.WindowsMediaPlayer1.currentMedia.Name + " ]"
End If
End If



Código Abrir:


On Local Error GoTo E
CommonDialog1.Filter = "Mp3 [*.Mp3*]|*.Mp3|Mp4 [*.Mp4*]|*.Mp4|Wav [*.Wav*]|*.Wav|Avi [*.Avi*]|*.Avi|Wma [*.Wma*]|*.Wma| Todos los Archivos [*.*]|*.*”
CommonDialog1.DialogTitle = "Abrir Archivo"
CommonDialog1.ShowOpen
If CommonDialog1.CancelError = False Then
If CommonDialog1.FileName = "" Then
Else
List1.AddItem(CommonDialog1.FileName)
List2.AddItem(CommonDialog1.FileTitle)
End If
End If
Exit Sub
E:



Código Borrar:


On Error Resume Next
Label1.Caption = List1.List(List1.ListIndex)
List1.ListIndex = List2.ListIndex
Label1.Caption = ""
List1.RemoveItem(List1.ListIndex)
List1.SetFocus

List2.RemoveItem(List2.ListIndex)
List2.SetFocus



Código Borrar Todo:


List1.Clear
List2.Clear
Label1.Caption = ""



Código List2:


Dim x As Long
Dim y As Integer
List1.ListIndex = List2.ListIndex
x = List2.ItemData(List2.ListIndex)
Label1.Caption = List1.List(List1.ListIndex)



Código ListBox2 (en el menu de los códigos en la parte donde dice “Click” buscan y pulsan en “DBLclick” y ponen este código):

Dim X As Long
Dim y As Integer
pepe = List2.ListIndex
List1.ListIndex = List2.ListIndex
X = List2.ItemData(List2.ListIndex)
Form1.Label1.Caption = List1.List(List1.ListIndex)
Form1.WindowsMediaPlayer1.URL = Form1.Label1.Caption
Form1.Caption = "Reproduciendo: " + "[ " + Me.WindowsMediaPlayer1.currentMedia.Name + " ]"




Espero haberles ayudado en algo, o tal vez, en mucho
Datos archivados del Taringa! original
24puntos
3,367visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
2visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

h
harrisonloco🇦🇷
Usuario
Puntos0
Posts27
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.