如何在vbscript中播放Windows播放器中的所有歌曲?
发布时间:2020-12-13 20:38:40 所属栏目:Windows 来源:网络整理
导读:你能帮忙写一个脚本,通过vbscript播放特定文件夹中的所有歌曲. Set wmp = CreateObject("WMPlayer.OCX")wmp.openPlayer("xxx.mp3") 上面的脚本可以运行单个文件. 谢谢 我制作了一个可以从文本文件中读取歌曲路径列表(本地或在线)的vbscript,可能会给你一个想
你能帮忙写一个脚本,通过vbscript播放特定文件夹中的所有歌曲.
Set wmp = CreateObject("WMPlayer.OCX") wmp.openPlayer("xxx.mp3") 上面的脚本可以运行单个文件. 谢谢
我制作了一个可以从文本文件中读取歌曲路径列表(本地或在线)的vbscript,可能会给你一个想法,当然你可以改进它:)
因此,要测试此脚本,必须创建名为PlayList.txt的文本文件 http://soundjay.com/mechanical/bomb-falling-and-exploding-01.mp3 并使用以下代码进行测试: '**********************Description************************ 'Play a PlayList contained in a text file ? Hackoo ? 2014 '********************************************************* Option Explicit On Error Resume Next Call Play() If Err <> 0 Then Ws.popup Err.Description,"3",Err.Description & Copyright,VbCritical Err.Clear End If '********************************************************* Sub Play() Dim Sound,Xwmp Dim File,fso,F,ReadME,PlayList,i,Ws,Copyright,Name,Duration Copyright = " ? Hackoo ? 2014" File = "PlayList.txt" Set Ws = CreateObject("wscript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(File) Then Ws.popup Err.Description,VbCritical End IF Set F = fso.OpenTextFile(File,1) ReadMe = F.ReadAll PlayList = split(ReadMe,vbcrlf) Set Sound = CreateObject("WMPlayer.OCX.7") Sound.settings.volume = 100 Sound.currentPlaylist.Clear For i = Lbound(PlayList) to Ubound(PlayList) Set Xwmp = Sound.newMedia(PlayList(i)) Sound.currentPlaylist.insertItem(i),Xwmp Sound.Controls.Play() Do while Sound.currentmedia.duration = 0 wscript.sleep 100 Loop wscript.sleep(int(Sound.currentmedia.duration)+1)*1000 Next End Sub '*********************************************************** (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |