It is currently March 28th, 2024, 7:04 pm

play and stop audio files

Get help with installing and using Rainmeter.
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

play and stop audio files

Post by Cellinarac »

Hello, I need some help with a project I am working on. I have a "banner" on the screen and when I left click it plays audio. but I also want to make it so that if the audio is playing, I can stop it by either clicking with the same button again, or clicking with another button. not sure how to do this, I have tried a couple things with no luck and this is the commands I have right now.
I have tried a few different methods for the play command to see if it made a difference but no luck there either lol

Code: Select all

LeftMouseUpAction=[PLAY "#@#Sounds\Christmas.wav"]
MiddleMouseUpAction=[STOP "#@#Sounds\Christmas.wav"]
any help would be very appreciated
thanks

Code: Select all

LeftMouseUpAction=[PLAY "#@#Sounds\Christmas.wav"]
MiddleMouseUpAction=[PLAYSTOP]
https://docs.rainmeter.net/manual-beta/bangs/#PlayStop
Cellinarac
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

Re: play and stop audio files

Post by Cellinarac »

another thing I would like to figure out is how to make it play a random audio file in the folder so that each time I click the banner it will play a different song. (yes this is for a Christmas desktop I am making lol) I don't want to tie in an audio player with this and I have converted the MP3's I am using to WAV and they all work, just can't get the stop play on click or a random function figured out
Cellinarac
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: play and stop audio files

Post by jsmorley »

Cellinarac wrote:another thing I would like to figure out is how to make it play a random audio file in the folder so that each time I click the banner it will play a different song. (yes this is for a Christmas desktop I am making lol) I don't want to tie in an audio player with this and I have converted the MP3's I am using to WAV and they all work, just can't get the stop play on click or a random function figured out
https://docs.rainmeter.net/manual-beta/plugins/quote/

Using the Quote plugin is relatively simple, but has one downside. It's "random" in the sense of throwing a dice, not in the sense of picking and discarding a card from a deck. So the fewer wav files you have in the folder, the more likely it is that you will get a "repeat" when clicking.

This can be solved, but it's a bit more involved. It requires using two measure types, one a couple of FileView plugin measure to get the .wav files in the folder and the count of files, and one a Calc measure to generate a UniqueRandom random number.

https://docs.rainmeter.net/manual-beta/plugins/fileview/
https://docs.rainmeter.net/manual-beta/measures/calc/#UniqueRandom
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: play and stop audio files

Post by fonpaolo »

About the first question, in the same docs, Play section:
"Rainmeter uses a single-threaded call to embedded Windows functionality to play the sound, and only one sound at a time can be managed, Rainmeter-wide. Playing a sound in any skin will stop any other currently playing sounds."

For the second question:
https://docs.rainmeter.net/manual-beta/plugins/quote/
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

Re: play and stop audio files

Post by Cellinarac »


Sweet!, this works to make it play the files in random as well?, also does this allow for the "play, stop" function? or is there a command I need to get it to stop playing? as for the single sound rainmeter can play at once, yea, I only have the one meter that plays sound, so clicking it again just restarts the song. I need a way where if the song is playing and I click it again it stops lol
Cellinarac
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: play and stop audio files

Post by jsmorley »

Cellinarac wrote:Sweet!, this works to make it play the files in random as well?, also does this allow for the "play, stop" function? or is there a command I need to get it to stop playing? as for the single sound rainmeter can play at once, yea, I only have the one meter that plays sound, so clicking it again just restarts the song. I need a way where if the song is playing and I click it again it stops lol
Playing a second sound will always stop the first one.
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

Re: play and stop audio files

Post by Cellinarac »

ok never mind the random part of that question, I didn't see where you said it plays random as in throwing dice until after I posted that, thats cool, thats pretty much what I need for that part of what I am trying to do. now just to figure out a command or something for a "stop" function lol
Cellinarac
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

Re: play and stop audio files

Post by Cellinarac »

the reason I need a "stop command" is because the audio files are entire songs and if I start the sound for someone I am showing it to and decide I don't want to play the whole song, I want to stop it lol. I also use my computer for phone calls, so if I have a song playing and a call comes in, I need to be able to stop it
Cellinarac
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: play and stop audio files

Post by jsmorley »

Cellinarac wrote:ok never mind the random part of that question, I didn't see where you said it plays random as in throwing dice until after I posted that, thats cool, thats pretty much what I need for that part of what I am trying to do. now just to figure out a command or something for a "stop" function lol
You aren't going to be able to have your cake and eat it too. If you want a click to stop a sound, you just use the PLAYSTOP bang to do so. If you want the click to play another random sound from the folder, you just have it update the QuotePlugin measure, and execute a PLAY bang using the QuotePLugin measure's value as the sound to play. If you want both, you will need two buttons, one for "stop" and one for "play".
User avatar
Cellinarac
Posts: 50
Joined: May 19th, 2017, 4:03 pm

Re: play and stop audio files

Post by Cellinarac »

well, I had it set as

Code: Select all

LeftMouseUpAction=[!PLAYSTOP][PLAY "#@#Sounds\Christmas.wav"]
but that didn't end the song when I clicked it a second time... did I do the command wrong or something?
Cellinarac