主题:用mediaplayer控件开发的mp3播放器不能够自动播放?
我用windowsmediaplay些写了一个mp3播放器,是用windowsMediaplay10版本开发的,其中:
播放文件的代码:
Private Sub MenuSubFile_Click()
'打开文件并播放,同时清除播放列表里的文件名并在列表里加入打开的文件
CommonDialog1.Filter = "mp3音乐文件 ¦*.mp3"
CommonDialog1.ShowOpen
mp3FileName = CommonDialog1.FileName
MediaPlayer.settings.autoStart = True
MediaPlayer.URL = mp3FileName
List1.Clear
List1.AddItem mp3FileName
End Sub
往列表里加入文件的代码:
Private Sub MenuSubAdd_Click()
'在播放列表里添加文件
CommonDialog1.Filter = "mp3音乐文件 ¦*.mp3"
CommonDialog1.ShowOpen
mp3FileName = CommonDialog1.FileName
List1.AddItem mp3FileName
End Sub
连续播放列表文件的代码:
dim playfilename as integer
Private Sub MediaPlayer_PlayStateChange(ByVal NewState As Long)
'按播放列表的顺序自动播放
PlayFileNumber = List1.ListIndex
If MediaPlayer.playState = wmppsMediaEnded Then
If List1.ListIndex < List1.ListCount - 1 Then
PlayFileNumber = PlayFileNumber + 1
List1.Selected(PlayFileNumber) = True
MediaPlayer.settings.autoStart = True
MediaPlayer.URL = List1.List(List1.ListIndex)
Else
List1.ListIndex = 0
MediaPlayer.URL = List1.List(List1.ListIndex)
End If
End If
End Sub
文件就是不能自动播放,必须按一下播放按钮才能够播放,我明明是设置了自动播放啊,不知如何连续自动播放,请指教?谢谢高手
播放文件的代码:
Private Sub MenuSubFile_Click()
'打开文件并播放,同时清除播放列表里的文件名并在列表里加入打开的文件
CommonDialog1.Filter = "mp3音乐文件 ¦*.mp3"
CommonDialog1.ShowOpen
mp3FileName = CommonDialog1.FileName
MediaPlayer.settings.autoStart = True
MediaPlayer.URL = mp3FileName
List1.Clear
List1.AddItem mp3FileName
End Sub
往列表里加入文件的代码:
Private Sub MenuSubAdd_Click()
'在播放列表里添加文件
CommonDialog1.Filter = "mp3音乐文件 ¦*.mp3"
CommonDialog1.ShowOpen
mp3FileName = CommonDialog1.FileName
List1.AddItem mp3FileName
End Sub
连续播放列表文件的代码:
dim playfilename as integer
Private Sub MediaPlayer_PlayStateChange(ByVal NewState As Long)
'按播放列表的顺序自动播放
PlayFileNumber = List1.ListIndex
If MediaPlayer.playState = wmppsMediaEnded Then
If List1.ListIndex < List1.ListCount - 1 Then
PlayFileNumber = PlayFileNumber + 1
List1.Selected(PlayFileNumber) = True
MediaPlayer.settings.autoStart = True
MediaPlayer.URL = List1.List(List1.ListIndex)
Else
List1.ListIndex = 0
MediaPlayer.URL = List1.List(List1.ListIndex)
End If
End If
End Sub
文件就是不能自动播放,必须按一下播放按钮才能够播放,我明明是设置了自动播放啊,不知如何连续自动播放,请指教?谢谢高手