在vb中的Private Sub Form_Load()中编译时说变量未定义,是怎么回事,里面是windows mediaplayer的,详情见
PrivateSubForm_Load()DimstrMusic(3)AsString'字符串数组,存放4首歌的URLDimcMediaAsIWMPMedia'Wmp媒体...
Private Sub Form_Load()
Dim strMusic(3) As String '字符串数组,存放4首歌的URL
Dim cMedia As IWMPMedia 'Wmp媒体变量,其实就是string
Dim i As Integer '循环变量
'4首歌的URL赋初值
strMusic(0) = VB.App.Path & "\Law of the Lord.mp3"
strMusic(1) = VB.App.Path & "\轻音乐 - 是忧伤还是快乐.mp3"
strMusic(2) = VB.App.Path & "\Sea of Clarity 清澈海洋.mp3"
strMusic(3) = VB.App.Path & "\轻音乐 - 牧羊曲.mp3"
WindowsMediaPlayer1.settings.playCount = 10 '当前播放列表重复播放次数
For i = 0 To 3
'Wmp媒体变量赋值
Set cMedia = WindowsMediaPlayer1.newMedia(strMusic(i))
If WindowsMediaPlayer1.currentPlaylist.Count = 0 Then '当前播放列表为空时
WindowsMediaPlayer1.currentMedia = cMedia
Else '当前列表不为空时
WindowsMediaPlayer1.currentPlaylist.appendItem cMedia
End If
Next i
Set cMedia = Nothing
End Sub
做的是背景音乐,怎么回事,谢谢,工程引用什么,还可以怎么做? 展开
Dim strMusic(3) As String '字符串数组,存放4首歌的URL
Dim cMedia As IWMPMedia 'Wmp媒体变量,其实就是string
Dim i As Integer '循环变量
'4首歌的URL赋初值
strMusic(0) = VB.App.Path & "\Law of the Lord.mp3"
strMusic(1) = VB.App.Path & "\轻音乐 - 是忧伤还是快乐.mp3"
strMusic(2) = VB.App.Path & "\Sea of Clarity 清澈海洋.mp3"
strMusic(3) = VB.App.Path & "\轻音乐 - 牧羊曲.mp3"
WindowsMediaPlayer1.settings.playCount = 10 '当前播放列表重复播放次数
For i = 0 To 3
'Wmp媒体变量赋值
Set cMedia = WindowsMediaPlayer1.newMedia(strMusic(i))
If WindowsMediaPlayer1.currentPlaylist.Count = 0 Then '当前播放列表为空时
WindowsMediaPlayer1.currentMedia = cMedia
Else '当前列表不为空时
WindowsMediaPlayer1.currentPlaylist.appendItem cMedia
End If
Next i
Set cMedia = Nothing
End Sub
做的是背景音乐,怎么回事,谢谢,工程引用什么,还可以怎么做? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |