如何在vbscript中播放Windows播放器中的所有歌曲?

你能帮忙写一个脚本,通过vbscript播放特定文件夹中的所有歌曲.
Set wmp = CreateObject("WMPlayer.OCX")
wmp.openPlayer("xxx.mp3")

上面的脚本可以运行单个文件.

谢谢

我制作了一个可以从文本文件中读取歌曲路径列表(本地或在线)的vbscript,可能会给你一个想法,当然你可以改进它:)

因此,要测试此脚本,必须创建名为PlayList.txt的文本文件

http://soundjay.com/mechanical/bomb-falling-and-exploding-01.mp3

  

  

  

  

  

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

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...