audio stream intro mode

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jdfnnl
Posts: 22
Joined: 10 Mar 2022, 01:21

audio stream intro mode

10 Jan 2024, 00:56

I am trying to create a script that plays a series of internet audio streams consecutively for 20 sec each.
This is what chatgpt suggested trying with v1.0:

Code: Select all

; Open VLC and play each playlist for 20 seconds

; Define the URLs of your playlists
Playlist1 := "http://yourplaylisturl1.com"
Playlist2 := "http://yourplaylisturl2.com"
; Add more playlists as needed

; Set the duration in milliseconds (20 seconds)
Duration := 20000

; Function to open VLC, load a playlist, and play it
OpenAndPlay(Playlist) {
    Run, "C:\Program Files\VideoLAN\VLC\vlc.exe" %Playlist% ; Adjust the path to your VLC installation
    WinWait, ahk_exe vlc.exe
    WinActivate ; Activate VLC window
    Sleep, 1000 ; Wait for VLC to load
    Send, ^o ; Open playlist
    Sleep, 1000 ; Wait for the "Open Media" window
    SendInput, %Playlist%{Enter} ; Enter the playlist URL
    Sleep, 1000 ; Wait for VLC to load the playlist
    Send, p ; Play the current playlist
    Sleep, %Duration% ; Wait for the specified duration
    Send, s ; Stop playback
    Sleep, 1000 ; Give VLC some time to process the stop command
    WinClose ; Close VLC
}

; Press F1 to start playing the playlists
F1::
    OpenAndPlay(Playlist1)
    OpenAndPlay(Playlist2)
    ; Add more playlists as needed
return
The effect of this script is that it will load the first two consecutively without letting either load and strangely none of the following playlists.
william_ahk
Posts: 639
Joined: 03 Dec 2018, 20:02

Re: audio stream intro mode

10 Jan 2024, 03:32

Here's a better response after a few tries:

Code: Select all

#NoEnv
SetBatchLines -1
SendMode Input

; Add your list of audio stream URLs here
audioStreams := ["http://example.com/stream1", "http://example.com/stream2", "http://example.com/stream3"]

; Path to VLC executable
vlcPath := "C:\Path\to\VLC\vlc.exe"

; Time to play each stream (in seconds)
streamDuration := 20

Loop
{
    ; Iterate through each audio stream
    for index, streamURL in audioStreams
    {
        ; Run VLC with the stream URL
        Run % vlcPath . " " . streamURL
        
        ; Wait for the stream to start playing
        Sleep 2000
        
        ; Wait for the specified duration
        Sleep streamDuration * 1000
        
        ; Close VLC
        Process, Close, vlc.exe
        
        ; Pause between streams (if needed)
        Sleep 1000
    }
    
    ; Repeat the loop indefinitely
}

; Exit script when Esc key is pressed
Esc::
ExitApp
jdfnnl
Posts: 22
Joined: 10 Mar 2022, 01:21

Re: audio stream intro mode

14 Jan 2024, 06:24

Would there be an easy way to use F1 to toggle the loop function on and off while keeping the player open?
william_ahk
Posts: 639
Joined: 03 Dec 2018, 20:02

Re: audio stream intro mode

14 Jan 2024, 10:05

Yes, add F1::Pause at the bottom.
jdfnnl
Posts: 22
Joined: 10 Mar 2022, 01:21

Re: audio stream intro mode

04 May 2024, 09:59

I have a different more simple script I use to open my complete playlist in VLC:

Code: Select all

;VLC
`::
app := "C:\Program Files\VideoLAN\VLC\radio.xspf"
If WinExist("ahk_exe" "C:\Program Files\VideoLAN\VLC\vlc.exe")
 WinClose
Else Run % app
Return
I would like to be able to use the same tilde key --> `
to either pause or kill the intro mode script so I can keep VLC open to the current state
would this be troublesome to accomplish and should otherwise be thinking of a different key?

I have 'esc' assigned to a different function for google chrome
but maybe there is a way to have 'esc' function this way with #IfWinActive?
jdfnnl
Posts: 22
Joined: 10 Mar 2022, 01:21

Re: audio stream intro mode

04 May 2024, 13:17

how can I kill or pause the script using the 'esc' key using #IfWinActive
I am not sure how to define the window title of VLC
would it be better to kill or pause the script?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 103 guests