[项目]音乐播放器

作者在 2007-12-27 14:01:38 发布以下内容

最近想自己写一个软件,可以不停的播放网上的音乐,先收集一下所需的资料

走过路过的给点意见啊~

1 确定使用的工具

做这种小软件,肯定是vb莫属了

2 怎么播放音乐

VB中添加部件"Windows Media Player"

拉一个控件到窗体上,改名成wmp,以下代码可以开始播放音乐

Private Sub Command1_Click()
    wmp.URL = "http://music3.tianya.cn/upmusicfile/2007/12/22/111494_13220228.mp3"
End Sub

在网上找了这个控件的属性和事件,比较长,另外写了一篇日志

http://hi.bc-cn.net/202661/viewspace-8683

3 怎么连续的播放音乐

wmp有播放列表的功能

wmp.currentPlaylist.appendItem()

4 音乐的地址怎么来

就在百度的mp3里面找

5 怎么找到准确的音乐地址

获取网页源码,然后使用正则表达式获取

6 怎么获取网页源码

可以用WebBrower控件,VB中添加"Microsoft Internet Controls"这个部件,就有WebBrower控件,具体获得源码的方法看这个网页(我没测试过):http://www.bc-cn.net/vb/f389112002.html

还可以用inet控件,VB中添加"Microsoft Internet transfer Control 6.0",然后使用以下方法

Private Sub Command2_Click()
    Text1.Text = Inet1.OpenURL("http://www.baidu.com")
End Sub

7 怎么使用正则表达式

VB中自带有正则表达式,工程->引用->Microsoft VBScript. Regular Expressions 5.5

下面是一个匹配的函数

Function TestRegExp(myPattern As String, myString As String)
   ''Create objects.
   Dim objRegExp As RegExp
   Dim objMatch As Match
   Dim colMatches   As MatchCollection
   Dim RetStr As String

   '' Create a regular expression object.
   Set bjRegExp = New RegExp

   ''Set the pattern by using the Pattern property.
   objRegExp.Pattern = myPattern

   '' Set Case Insensitivity.
   objRegExp.IgnoreCase = True

   ''Set global applicability.
   objRegExp.Global = True

   ''Test whether the String can be compared.
   If (objRegExp.Test(myString) = True) Then

   ''Get the matches.
    Set colMatches = objRegExp.Execute(myString)   '' Execute search.

    For Each objMatch In colMatches   '' Iterate Matches collection.
      RetStr = RetStr & "Match found at position "
      RetStr = RetStr & objMatch.FirstIndex & ". Match Value is ''"
      RetStr = RetStr & objMatch.Value & "''." & vbCrLf
    Next
   Else
    RetStr = "String Matching Failed"
   End If
   TestRegExp = RetStr
End Function

另外有关于VB正则表达式的简单介绍

http://hi.baidu.com/notwing/blog/item/368c8b9492e7ca1fd21b70be.html

8 怎么判断网址是否可以打开

目前想法:可以根据wmp的PlayState属性来判断

9 怎么在一首歌播放完后再播一首

目前想法:用播放列表

原创 | 阅读 2373 次
文章评论,共0条
游客请输入验证码