How to play audio file on windows from command line?

前端 未结 11 976
臣服心动
臣服心动 2020-12-10 02:41

In Windows, is there a simple way (i.e. something you could type on a single command line) to just play a couple of .mp3 files and then exit on its own?

wmplayer, f

11条回答
  •  伪装坚强ぢ
    2020-12-10 03:30

    I am using this improve version of Mayra Delgado's answer:

    Set objArgs = Wscript.Arguments
    
    if (objArgs.Count = 0) then
        Wscript.echo "I need a sound file as argument!"
        WScript.Quit 123
    end if
    Wscript.echo "Playing: " & objArgs(0) & "..."
    
    Set objPlayer = createobject("Wmplayer.OCX.7")
    
    With objPlayer  ' saves typing
        .settings.autoStart = True
        .settings.volume = 50  ' 0 - 100
        .settings.balance = 0  ' -100 to 100
        .settings.enableErrorDialogs = False
        .enableContextMenu = False
        .URL = objArgs(0)
        ' Wait until play finish
        While .Playstate <> 1
            Wscript.Sleep 100
        Wend
    End With
    
    MsgBox "if WMP is still playing, clicking OK will end it", _
        vbInformation, "WMP Demo finished"
    

提交回复
热议问题