音乐播放器代码Option ExplicitDim i As IntegerDim pa, a, k As StringPrivate Sub Form_Load() RandomizeEnd SubPrivate Sub Check1_Click()WindowsMediaPlayer1.settings.setMode “loop”, TrueEnd SubPrivate Sub Command1_Click()Dim song As StringWith CommonDialog1.FileName = “”.Filter = “.MP3|.mp3;.AVI|.avi;.WAV|.wav;.WMA|.wma;.M4A|.m4a;.FLAC|.flac;.AAC|.aac;.AC3|.ac3;.MID|.mid”.Flags = 512.ShowOpensong = .FileNameEnd WithIf song = “” Then Exit Suba = ""For i = Len(song) To 1 Step -1k = Mid(song, i, 1)If k = " " Then '多首歌的分隔符List1.AddItem aa = ""ElseIf k = “” Then '一首歌时歌名与路径的分隔符List1.AddItem apa = Left(song, i)Exit SubElsea = k & aEnd IfNext iEnd SubPrivate Sub Command2_Click()WindowsMediaPlayer1.URL = pa & List1.TextEnd SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Command4_Click()WindowsMediaPlayer1.Controls.pauseEnd SubPrivate Sub Command5_Click()WindowsMediaPlayer1.Controls.playEnd SubPrivate Sub Command6_Click()WindowsMediaPlayer1.CloseEnd SubPrivate Sub Command7_Click()WindowsMediaPlayer1.Controls.pause WindowsMediaPlayer1.Controls.stop List1.Selected(List1.ListIndex - 1) = True WindowsMediaPlayer1.URL = List1.List(List1.ListIndex) WindowsMediaPlayer1.Controls.play '播放上一个文件End SubPrivate Sub Command8_Click()WindowsMediaPlayer1.Controls.pause WindowsMediaPlayer1.Controls.stop List1.Selected(List1.ListIndex + 1) = True WindowsMediaPlayer1.URL = List1.List(List1.ListIndex) WindowsMediaPlayer1.Controls.play '播放下一个文件End SubPrivate Sub List1_DblClick()Me.Caption = “我的播放器 当前播放” & pa & List1.TextWindowsMediaPlayer1.URL = pa & List1.TextEnd SubPrivate Sub Timer1_Timer()If Option1.Value = True And Option2.Value = False Then '单曲循环播放If WindowsMediaPlayer1.playState = 1 ThenList1.ListIndex = List1.ListIndexWindowsMediaPlayer1.URL = List1.TextEnd IfEnd IfIf Option2.Value = True And Option1.Value = False Then '顺序循环播放If WindowsMediaPlayer1.playState = 1 ThenList1.ListIndex = List1.ListIndex + 1WindowsMediaPlayer1.URL = List1.TextEnd IfEnd IfIf Option3.Value = True And Option1.Value = False And Option2.Value = False Then '随机播放If WindowsMediaPlayer1.playState = 1 Then List1.ListIndex = Int(Rnd * List1.ListCount) List1.ListIndex = List1.ListIndex WindowsMediaPlayer1.URL = List1.List(List1.ListIndex)WindowsMediaPlayer1.URL = List1.TextEnd IfEnd IfIf Option2.Value = False And Option1.Value = False ThenIf WindowsMediaPlayer1.playState = 1 ThenWindowsMediaPlayer1.Controls.pauseEnd IfEnd IfEnd Sub视频播放器代码Dim i As IntegerDim pa, a, k As StringPrivate Sub Form_Load() RandomizeEnd SubPrivate Sub btnOpen_Click() Dim song As StringWith CommonDialog1.FileName = “”.Filter = “.mp4;.avi;.wmv;.mov|.mp4;.avi;.wmv;.mov”.Flags = 512.ShowOpensong = .FileNameEnd With If song = “” Then Exit Suba = ""For i = Len(song) To 1 Step -1k = Mid(song, i, 1)If k = " " Then '多首歌的分隔符txtVideoFileList.AddItem aa = ""ElseIf k = “” Then '一首歌时歌名与路径的分隔符txtVideoFileList.AddItem apa = Left(song, i)Exit SubElsea = k & aEnd IfNext i End SubPrivate Sub btnPlay_Click()MediaPlayer1.URL = pa & txtVideoFileList.Text '播放End SubPrivate Sub btnStop_Click() MediaPlayer1.Controls.stop '停止End SubPrivate Sub btnPause_Click() MediaPlayer1.Controls.pause '暂停End SubPrivate Sub btnResume_Click() MediaPlayer1.Controls.play '继续End SubPrivate Sub btnRandom_Click() Dim selectedIndex As Integer selectedIndex = Int(Rnd * txtVideoFileList.ListCount) txtVideoFileList.ListIndex = selectedIndex MediaPlayer1.URL = txtVideoFileList.List(selectedIndex)End SubPrivate Sub btnSequence_Click() If txtVideoFileList.ListIndex <> -1 Then If txtVideoFileList.ListIndex < txtVideoFileList.ListCount - 1 Then txtVideoFileList.ListIndex = txtVideoFileList.ListIndex + 1 Else txtVideoFileList.ListIndex = 0 End If MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex) End IfEnd SubPrivate Sub btnLoop_Click() MediaPlayer1.settings.setMode “loop”, True '循环播放 MediaPlayer1.Controls.playEnd SubPrivate Sub btnNext_Click() If txtVideoFileList.ListIndex < txtVideoFileList.ListCount - 1 Then txtVideoFileList.ListIndex = txtVideoFileList.ListIndex + 1 End If MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex)End SubPrivate Sub btnPrevious_Click() If txtVideoFileList.ListIndex > 0 Then txtVideoFileList.ListIndex = txtVideoFileList.ListIndex - 1 End If MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex)End SubPrivate Function GetIndex(MyArray() As String, MyString As String) As Integer '查找字符串在字符串数组中的索引值 Dim i As Integer For i = LBound(MyArray) To UBound(MyArray) If MyArray(i) = MyString Then GetIndex = i Exit Function End If NextEnd Function以上是程序代码内容。现在介绍一下程序功能,程序1里是音乐播放器程序代码,首先要检查程序是否缺少控件,例如,WindowsMediaPlayer1控件和CommonDialog1控件,然后再检查程序代码是否能正常使用,然后就可以打开音乐文件听歌了(可以是MP3文件也可以是wav文件)。程序2里,是视频播放器程序代码,也是一样,首先要检查程序是否缺少控件,例如,WindowsMediaPlayer1控件和CommonDialog1控件,然后再检查程序代码是否能正常使用,然后就可以打开视频文件欣赏了(注意是MP4文件)。对于初学者来说,还有就是在下载了源代码后不知道怎么使用,可以直接选择.vbp文件打开(注意:我这里使用的是vb6.0中文企业版开发工具),一般都是打开这个文件就可以把全部的文件都打开了,还有就是有时候如果这个.vbp的文件出现打不开的情况,就直接关闭退出,再选择.frm的文件,再打开就可以正常使用了。还有,如果缺少某些需要的文件,对于一些简单的文本文件(例如,.txt)或者缺少声音文件(例如,.MP3)或者缺少图片文件(例如,.JPEG)等情况,因为不同电脑里的文件目录路径可能有所不同,可以自己设计编写或添加进去或者更改为实际文件路径,对于自己不会编写的文件或内容,可以在评论区给我留言或提问,当我看到评论,我会尽快回复。如果还有其他问题,可以联系创作者本人,可以发评论留言或者提问,可以发消息给我,当我看到及时尽快回复。以下是本程序源代码和下载网址。这个:音频视频播放器源代码ZQ,是文件名称。ZQ表示拼音:正确的首字母的意思(在这里我只是简单标记一下)。vb6.0指的是软件开发工具(vb6.0版本的简体中文企业版)如果是vb.net指的是软件开发工具(vb.net版本的简体中文版2022版本)音频视频播放器源代码ZQ.zipvb6.0下载网址:https://download.csdn.net/download/qq_32257509/88514792

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐