如何使用AxWindowsMediaPlayer正确管理播放列表/播放列表编辑器? [英] How can I properly manage a playlist/playlist editor using AxWindowsMediaPlayer?

查看:220
本文介绍了如何使用AxWindowsMediaPlayer正确管理播放列表/播放列表编辑器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用AxWindowsMediaPlayer制作一个MP3播放器,但我还没想出如何制作一首歌曲然后播放下一首而不使用wmp.playlist。当我尝试使用播放列表时,我遇到了一个问题。我有一个列表框,其中包含播放列表中的文件,我希望能够双击某个项目并播放它。如果我更改了listbox1.doubleClick事件中的player.currentMedia,播放器会忘记上一个播放列表,只播放一个文件直到完成。我尝试将playlist.item索引与listbox.selectedindex进行比较,然后根据需要多次移动到下一首歌曲(或之前的歌曲)以获得列表框中选择的正确歌曲。我想出了这个代码,但它没有正常工作,只要我双击列表框中的任何项目,它就会前进到播放列表中的下一个项目。

Hi,

I'm making an mp3 player using the AxWindowsMediaPlayer but I haven't figured out how to make one song play followed by the next without using wmp.playlist. And when I tried using the playlist I ran into a problem. I have a listbox with the files on the playlist and I want to be able to double click on an item and play it. If I change the player.currentMedia on the listbox1.doubleClick event, the player forgets about the previous playlist and just plays the one file until it finishes. I tried comparing the playlist.item index to the listbox.selectedindex and then move to the next song (or previous) as many times as needed to get to the right song selected on the listbox. I came up with this code but it's not working properly, it just advances to the next item on the playlist whenever i double click any item on the listbox.

If Player.playState = WMPPlayState.wmppsPlaying Then 'And TrackBar1.Value = 1 Then
            For i = 0 To Player.currentPlaylist.count - 1
                If Player.currentMedia.isIdentical(Player.currentPlaylist.Item(i)) Then
                    If i < ListBox1.SelectedIndex Then
                        MsgBox(i.ToString + vbCrLf + ListBox1.SelectedIndex.ToString)
                        While i < ListBox1.SelectedIndex
                            Player.Ctlcontrols.next()
                            i += 1
                        End While
                    End If
                    If i > ListBox1.SelectedIndex Then
                        While i > ListBox1.SelectedIndex
                            Player.Ctlcontrols.previous()
                            i -= 1
                        End While
                    End If
                    'Label3.Text = "Currently Playing Media Index: " & i.ToString
                    'MsgBox("Currently Playing Media Index: " & i.ToString)
                End If
            Next
        End If



如果播放列表索引大于listbox.selectedindex(我选择了一首正在播放的歌曲)它可以正常工作。当我试图选择一首正在播放的歌曲之后,它将无效。任何想法?

我一直在网上搜索试图找到例子,但我只是找到一首能播放一首歌的简单代码。没有什么关于循环播放或随机播放或任何东西。

如果有人对我如何做到这一点有更好的了解,那将对我有很大的帮助!


If the playlist index is greater than the listbox.selectedindex (I selected a song that's before the one that's playing) it works just fine. It's when I try to select a song that's after the one that's playing that it won't work. Any ideas?
I've been searching the web trying to find examples but I just find simple code that plays one song. Nothing about loop playing or shuffle playing or anything.
If someone has a better idea of how I could do this it would be of great help to me!

推荐答案

Public Sub PlayNext( )

尝试

ColorSliderProgress.Value = 0

如果不是ListBox2.SelectedIndex< 0然后

如果ListBox1.SelectedIndex> ListBox1.Items.Count - 1然后

ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1

AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem

AxWindowsMediaPlayer1。 Ctlcontrols.play()

结束如果

结束如果



Catch ex As Exception



结束尝试
Public Sub PlayNext()
Try
ColorSliderProgress.Value = 0
If Not ListBox2.SelectedIndex < 0 Then
If ListBox1.SelectedIndex > ListBox1.Items.Count - 1 Then
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
End If

Catch ex As Exception

End Try


这篇关于如何使用AxWindowsMediaPlayer正确管理播放列表/播放列表编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆