TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Play a numbered mp3 file with the TRIGGERcmd Smart Home Alexa skill

    Alexa
    1
    1
    144
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR
      Russ
      last edited by

      I made this video to show how it works:
      https://youtu.be/MjB-K6NXRV4

      This is the Windows batch script I had ChatGPT create for me:

      @echo off
      setlocal EnableDelayedExpansion
      
      REM Check if the script is provided with a valid parameter
      if "%1"=="" (
          echo Please provide a line number.
          exit /b 1
      )
      
      REM Check if the parameter is a positive integer
      set "param=%1"
      set /a "param=param+0" 2>nul
      if not defined param (
          echo Invalid parameter. Please provide a valid positive integer.
          exit /b 1
      )
      
      REM Check if the parameter is within the valid range (greater than 0)
      if %param% leq 0 (
          echo Invalid parameter. Please provide a valid positive integer.
          exit /b 1
      )
      
      REM Set the path to your text file containing the list of MP3 files
      set "textFilePath=d:\playlist.m3u"
      
      REM Check if the text file exists
      if not exist "%textFilePath%" (
          echo Text file not found: %textFilePath%
          exit /b 1
      )
      
      REM Read the corresponding line from the text file
      set "mp3File="
      for /f "skip=%param% delims=" %%A in ('type "%textFilePath%"') do (
          set "mp3File=%%A"
          goto :PlayFile
      )
      
      REM If the parameter is greater than the number of lines in the file
      echo Line number exceeds the number of lines in the file.
      exit /b 1
      
      :PlayFile
      REM Play the selected MP3 file
      echo Playing: %mp3File%
      start "" "%mp3File%"
      
      exit /b 0
      

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • First post
        Last post