gpt4 book ai didi

audio - 使用Vbscript提取或播放youtube音频

转载 作者:行者123 更新时间:2023-12-02 23:42:59 25 4
gpt4 key购买 nike

我正在尝试获取vbs脚本,以请求youtube视频的网址并播放音频。我到目前为止

    Option Explicit
Dim Msg,Question,PathSound,URL
URL = InputBox("What url would you like to play from?")
PathSound = "URL"
Question = MsgBox(Msg,VbQuestion+VbYesNo,Msg)
If Question = VbYes Then
Call Play(PathSound)
Else
Wscript.Quit()
End If
'**********************************************************
Sub Play(SoundFile)
Dim Sound
Set Sound = CreateObject("WMPlayer.OCX")
Sound.URL = SoundFile
Sound.settings.volume = 100
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep(int(Sound.currentmedia.duration)+1)*1000
End Sub
'**********************************************************

最佳答案

试试这样的事情:

Option Explicit
Dim Msg,Question,URL,Title
Title = "Extract or play youtube audio with Vbscript by Hackoo 2016"
Msg = "Did you want to continue with this script to play music ? or stop music and quit this script ?"
Question = MsgBox(Msg,VbQuestion+VbYesNo,Title)
If Question = VbYes Then
URL = InputBox("What url would you like to play from ?" , "Play Sound from internet",_
"https://www.youtube.com/watch?v=4Aa9GwWaRv0")
'http://www.chocradios.ch/djbuzzradio_windows.mp3.asx
If URL = "" Then Wscript.Quit()
If Instr(URL,"youtube") > 0 Then
Call Play_Youtube(URL)
Else
Call Play(URL)
End If
Else
Call Kill("iexplore.exe")
Call Kill("Wscript.exe")
Wscript.Quit()
End If
'**********************************************************
Sub Play(SoundFile)
Dim Sound
Set Sound = CreateObject("WMPlayer.OCX")
Sound.URL = SoundFile
Sound.settings.volume = 100
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep(int(Sound.currentmedia.duration)+1)*1000
End Sub
'**********************************************************
Sub Play_Youtube(URL)
Dim ie
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate(URL)
ie.Visible=false
DO WHILE ie.busy
LOOP
End Sub
'**********************************************************
Sub Kill(Process)
Dim Command,Ws,Execution
Set Ws = CreateObject("Wscript.Shell")
Command = "cmd /c Taskkill /F /IM "& Process &""
Execution = Ws.Run(Command,0,True)
End Sub
'***********************************************************

关于audio - 使用Vbscript提取或播放youtube音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35665986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com