当前位置: 首页 > >

VB制作简单的MP3播放器

发布时间:

简单的 MP3 播放器
一、系统完成功能及框图
系统完成功能:用户进入打开播放器,选取文件就可播放了!

运行

打开文件

选取文件

播放音频或视频文件

播放结束
图 1 系统功能框图

二、 核心算法及说明
1. 添加 mediaplayer1 及 CommonDialog1 控件
右击工具箱的空白处,选择“部件” ,然后选取控件,如下图:

把相关控件添加到窗体上; 在 windows media player 的属性窗口中把 windows media player1 名称改为 media player1

2.动态链接文件
Private Sub Command1_Click() CommonDialog1.Action = 1 MediaPlayer1.URL = CommonDialog1.FileName If CommonDialog1.FileName <> "" Then Caption = "正在播放:" & CommonDialog1.FileName Command3.Enabled = True Command4.Enabled = True End If End Sub

三、 界面设计

程序代码如下: Private Sub Command1_Click() CommonDialog1.Action = 1 MediaPlayer1.URL = CommonDialog1.FileName If CommonDialog1.FileName <> "" Then Caption = "正在播放:" & CommonDialog1.FileName Command3.Enabled = True Command4.Enabled = True End If End Sub Private Sub Command2_Click() Caption = "正在播放:" & CommonDialog1.FileName MediaPlayer1.Controls.play Command2.Enabled = False

Command3.Enabled = True Command4.Enabled = True End Sub Private Sub Command3_Click() MediaPlayer1.Controls.pause Command3.Enabled = False Command2.Enabled = True End Sub Private Sub Command4_Click() MediaPlayer1.Close Command4.Enabled = False Command2.Enabled = True End Sub Private Sub Command5_Click() End End Sub Private Sub Form_Load() Caption = "正在播放:" Command1.Caption = "打开" Command2.Caption = "播放" Command3.Caption = "暂停" Command4.Caption = "停止" Command5.Caption = "退出" Command2.Enabled = False Command3.Enabled = False Command4.Enabled = False End Sub




友情链接: