2016-02-27 2 views
1

Я пытаюсь получить скрипт vbs, чтобы запросить URL-адрес видео с YouTube и воспроизвести аудио. У меня это до сих порИзвлечение или воспроизведение звука youtube с Vbscript

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 
    '********************************************************** 

ответ

0

попробовать что-то вроде этого:

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 
'*********************************************************** 
+0

если я поставить в новый адрес он будет играть различные видео. –

+0

@AlienVilliger дайте мне этот новый адрес, чтобы испытать с вами – Hackoo

+0

https://www.youtube.com/watch?v=y8Kyi0WNg40 –

Смежные вопросы