加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在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

  

  

  

   
 
    
 
   http://soundbible.com/mp3/Evil_laugh_Male_9-Himan-1598312646.mp3 

  

  

   
 
    
 
   http://hackoo.alwaysdata.net/Intro_DJ.mp3 

  
http://hackoo.alwaysdata.net/Best of Avicii Megamix 2014.mp3

  

   
 
    
 
   http://hackoo.alwaysdata.net/David_Guetta_Miami_2014.mp3 

  
http://hackoo.alwaysdata.net/Megamix 90.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
'***********************************************************

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读