2

Would it be possible to execute a mp3 silently from batch I have tried:

@echo off
1.mp3
pause

It works but it doest do it silently it launches WMP. does any one know how I could accomplish this. I am making a program and the track it one of the sound effects.

09stephenb
  • 9,358
  • 15
  • 53
  • 91
  • You cannot "execute" a batch file any more than you can execute a text file. In both cases, you just instruct an application to read the file and do something with it. So which application would that be in your case? – Jon Jan 21 '14 at 13:38
  • I think you misunderstood I need the bat file to play the sound with no output like a program poping up. – 09stephenb Jan 21 '14 at 13:42
  • 1
    may be you rahter need command line mp3 player ? My first hot from google : http://mpg321.sourceforge.net/ – npocmaka Jan 21 '14 at 13:48
  • @09stephenb: No misunderstanding there. I 'm telling you that you need a program to play the mp3. It can't play itself any more than text can display itself or images can draw themselves. – Jon Jan 21 '14 at 13:52
  • But what should I use. – 09stephenb Jan 21 '14 at 13:55
  • 1
    I'd try powershell. `$PLAYER = New-Object -ComObject 'Mediaplayer.Mediaplayer'; $PLAYER.Filename="C:\1.mp3"; $PLAYER.Play();` You don't need any program to play MP3 when you have a ComObject. – Knuckle-Dragger Jan 21 '14 at 13:57
  • wv player is a small command line, and gui, audio player - http://www.webxpace.net – foxidrive Jan 21 '14 at 16:24

1 Answers1

3

Here is a Bat/VBS to play an audio file :

@echo off
set file=track12.mp3
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
  echo Sound.URL = "%file%"
  echo Sound.Controls.play
  echo do while Sound.currentmedia.duration = 0
  echo wscript.sleep 100
  echo loop
  echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min sound.vbs

Or you can use this small command i wrote in Autoit (playsound.exe)

Use : playsound.exe "youraudiofile.mp3/wav"

SachaDee
  • 9,245
  • 3
  • 23
  • 33