Random choise mp3 playlist

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Random choise mp3 playlist

#1 Post by Dick60 » 01 May 2021, 08:01

I use the PFplayer mini on my ESP8266 device with the latest rom.It works great but is there a a rule to start playing the playlist like a Lucky shot, so not sequently but randomly?

TD-er
Core team member
Posts: 4932
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Random choise mp3 playlist

#2 Post by TD-er » 01 May 2021, 09:38

We don't have a random function (which is a great feature by the way), but you could create one in the rules.

What you could do, is use the RSSI as random generator and multiply it by the uptime.

Let's assume you have the current track nr stored in variable #1 and number of tracks in variable #2
In this example I will store the random number in variable #3.

Code: Select all

let,3,abs(%rssi%) * %uptime%
let,1,([int#3]*[int#1])%[int#2]
With this code your next track nr is in variable #1 (to be used in rules with [int#1])

(untested code)

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Random choise mp3 playlist

#3 Post by Ath » 01 May 2021, 09:57

Looking at the commands for the DFR-0299, there is a command available to get random playback, it just isn't available to be set.
And the same goes for 'repeat', AFAICS, which would probably be useful here as well.

Wouldn't be too hard to add, except I don't have such unit available, so actual testing would have to be done by you or someone else. What type and flash configuration (.bin file name is helpful) do you use?
/Ton

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Random choise mp3 playlist

#4 Post by Ath » 01 May 2021, 11:34

Dick60 wrote: 01 May 2021, 08:01 I use the PFplayer mini on my ESP8266 device with the latest rom.It works great but is there a a rule to start playing the playlist like a Lucky shot, so not sequently but randomly?
I've opened a pull request (PR #3615) adding a mode and a repeat command.

This plugin is only available in the 'test' .bin files, but as they are currently too big, they won't be available in the PR builds. (There's a separate PR #3600 to try and solve that).

I can provide you with an (adapted) 'test' build if you provide the type you need, and a list of other plugins that must be available too (if any), as I have to leave some out to create a working build.

Based on your highly appreciated feedback we can opt to actually include it in ESPEasy.
/Ton

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#5 Post by Dick60 » 01 May 2021, 12:19

thanks for the explanation. At the moment I use the test.bin because that was the only bin where the MP3 player was available. What i need in my project is the mp3 player and some normal switches. I appreciate the offer, to make an costum test.bin for me. After a succesfull implementation I can give you feedback of my findings.

I hope you have enough info to create the test.bin.

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Random choise mp3 playlist

#6 Post by Ath » 01 May 2021, 16:35

Dick60 wrote: 01 May 2021, 12:19 At the moment I use the test.bin because that was the only bin where the MP3 player was available. What i need in my project is the mp3 player and some normal switches. I appreciate the offer, to make an costum test.bin for me. After a succesfull implementation I can give you feedback of my findings.
Here's a test-build (attached below) with the new commands included.

From the (also updated) documentation:
Screenshot - 01_05_2021 , 16_33_37.png
Screenshot - 01_05_2021 , 16_33_37.png (35.05 KiB) Viewed 1653 times
Attachments
ESP_Easy_mega_20210501_test_ESP8266_4M1M.zip
(653.18 KiB) Downloaded 28 times
/Ton

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#7 Post by Dick60 » 02 May 2021, 10:03

I hope, there is no misunderstanding from my side, I have load the attached Bin on my NodeMcu without any problems, created the device DFPLAYER-MINI and tested the play mode (http://xxx.xxx.x.xx/control?cmd=play,3). Worked perfect. Tried the new option MODE at boot

Code: Select all

 On System#Boot do 
   vol,10
   mode,3
   delay,180 //play the song for 30 seconds (this is a generic command!)
   stop
 endon
Did not work. Tried http://xxx.xxx.x.xx/control?cmd=mode,3 in my IE, Did not work.
Any idea? What am I doing wrong?

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Random choise mp3 playlist

#8 Post by Ath » 02 May 2021, 13:40

Not sure if you are doing anything wrong, there are a lot of possible causes here

- You can enter the commands, as shown in the documentation above, on the Tools page, no prefix like control?cmd= etc needed there, and the quickest way to test a command
- Calling that type of commands from the System#Boot event might be a bit 'early', not sure if the plugin is already fully initialized at that point (though I'd expect it would be). Adding a delay like you did is a big no-no, so that's why I updated the example code, see below.
- I have no player module available, so I've been unable to do any testing at all, just extended the existing command structure
- Chinese clones are not necessarily 100% compatible with the original player, so they can have a chip that doesn't support these commands, don't know what exact type of module you are using

Updated Rules example (as available in the updated documentation):

Code: Select all

On System#Boot do
  vol,10
  play,255 // file number 255
  timerSet,1,30 //play the song for 30 seconds (this is a generic command!)
Endon

On Rules#Timer=1 do
  Stop
Endon
/Ton

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#9 Post by Dick60 » 02 May 2021, 14:50

I've tested the new command MODE as described in your previous answere. The PLAY option is working but the MODE,3 without the "control?cmd=" (http://xxx.xxx.x.xx/mode,3) is not working for now. Probably I have to wait for the final version of the plug-in.

TD-er
Core team member
Posts: 4932
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Random choise mp3 playlist

#10 Post by TD-er » 02 May 2021, 15:27

Dick60 wrote: 02 May 2021, 14:50 I've tested the new command MODE as described in your previous answere. The PLAY option is working but the MODE,3 without the "control?cmd=" (http://xxx.xxx.x.xx/mode,3) is not working for now. Probably I have to wait for the final version of the plug-in.
You always need to include a command prefix as you tried first.

Can you try sending the command in the "command" input field on the Tools page?
If you submit the command you will see some output, which may also state if it is an unknown command.
To be honest, I do find it a bit too generic, so maybe it conflicts with some other plugin?

You can also add the "task prefix" to the command to make sure you address it to the task you want to control.
See: https://espeasy.readthedocs.io/en/lates ... f-a-plugin

Also if you submitted the command there, the browser will reload with the command encoded in a new URL in the browser URL bar, so you can use that later on other devices.

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#11 Post by Dick60 » 02 May 2021, 16:05

this is all above my level of knowledge. Probably I use Variables for now to monitor the mp3's already played and that the new play not start Always with the same mp3. This is part of my alarm system (barking dog) and you do not want to start with the same mp3 but "randomly".

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Random choise mp3 playlist

#12 Post by Ath » 02 May 2021, 16:42

I will order a MP3-player module from my friends at Ali, but delivery will take a couple of weeks, so any testing by me will be postponed until then.
/Ton

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#13 Post by Dick60 » 02 May 2021, 16:47

thank you for the effort. I appreciate it.

Dick60
Normal user
Posts: 76
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Random choise mp3 playlist

#14 Post by Dick60 » 17 Jun 2021, 21:32

The MP3 is working perfectly using the "normal control options mentioned in the WIKI. A nice, missing function, would be the option to put the volume and the Play number in a rule. Bur for now I m happy with it and thiefs are welcome with the sound of barking agressieve dogs. :lol:

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests