Mycroft Community Forum

USB Music Skill - testing and feedback

usbmusic USB Music
Play Music from a USB device with Mycroft.ai

About

Play local music by inserting a USB drive into your Mycroft device. Upon Inserting a USB Device Mycroft
will scan the device for MP3 music and add it to a temporary library that you can play.

AutoPlay

If autoplay is enabled in the websettings then the usb music will begin playing imediatly when inserted.
Unplugging the usb will automatically stop and unmount the device.

Command Examples

  • “play the artist elvis Presley”
  • “play all shook up”
  • “play the song blue suede shoes”
  • “play the album appeal to reason”

Credits

Category

Media

Tags

#music, #usb, #mycroft.ai, #python, #skills, #mp3, #CPS

Require

Tested on platform_picroft (others untested)

Other Requirements

Installation Notes

Todo

  • Add “next/previous” commands
  • Add “random” selection
  • Add thumbnails for display
  • …?

Feedback

  • I have only tested this on picroft so feedback on other devices is very much welcome.
  • provide feedback in this Topic
  • provide feedback in github
    https://github.com/pcwii/usb-music
1 Like

Nice skill, wondering if it would be possible to make it run from an smb share instead of the usb drive (with a settings to select the path). Mixed with CMDSkill to mount the path it could auto play. I havent looked at the code yet but I am pretty sure this could be done

1 Like

So I got this working as a test… Sort of… be warned it took a bit of time to load the library in my test case, I don’t know how many songs you have but I am going to need to optimize things and clean up the code a bit. If you are adventurous, update to the latest build “msm update” then update your websettings with your smb share and then issue the command “load network music” and be prepared to wait if you have a large library (maybe try a smaller share first)
image

Great I will give it a try tomorrow. Thumbs up !

Cool skill, I have some questions:

That means it will copy locally the items or it creates an m3u pointing to the right place? (USB, SMB/whatever future path)

What about other formats like flac, ogg, etc?

What about, if you are willing to create a similar skill for videos, to create a meta-skill “USB-load” which scans the USB (or network path, but we’re speaking of USB) and determine how many audio files and video files are present on the device and playing it accordingly? My ideal skill would be one which scans the media and you can tell something like “play 12 monkeys movie on living TV’s Kodi” or “play the artist elvis presley (locally)”

I do not copy the files to a temporary area. Currently my approach for the “library” is to create a mount point then scan the mount point for mp3 data. I then create a dict of the data that I index when a request is made. The dict list consists of the following data for each found item.

info = {
                        "location": song_path,
                        "label": self.song_label,
                        "artist": self.song_artist,
                        "album": self.song_album
                    }

it does take some time to index all the items. and I am not sure at this point if this is a blocking event. I will need to do some testing to be sure. I will look into the flac, ogg, as far as the movies I am just about ready to release my revamped kodi skill and it should cover off some of those items.

For those interested, I have updated this skill with the following new features.

About

Play local music sources (USB, SMB, Local)

  1. Inserting a USB drive into your Mycroft device. Upon Inserting a USB Device Mycroft
    will scan the device for playable music and add it to a temporary library that you can play upon request.
  2. Adding an SMB source will let you play music from that source.
  3. Adding a local path source will let you play music from that source.
  4. Supports the following music formats ‘mp3’, ‘m4a’, ‘flac’, ‘wav’, ‘wma’,‘aac’

AutoPlay

If AutoPlay is enabled in the websettings then the USB music will begin playing immediately when inserted.
Unplugging the usb will automatically stop and unmount the USB device.
AutoPlay only functions with USB sources, not SMB or Local Path.

1 Like

I have made another small update to this skill.
This change lets you add a command that will automatically be pushed to the messagebus (invoking another skill) when the USB has been inserted.

Automatic Insert Command Request

If enabled the skill will automatically send a command to the messagebus
when the USB is inserted.
Why?
Why not?
This will let you do all sorts of things with this skill by invoking other skills when the USB is inserted.
Example:

  • You have a running playlist that is stored on a USB stick.
  • You insert the USB before you jump on the treadmill.
  • The insertion automatically issues the following command to the messagebus
  • “set a timer for 20 minutes”
  • Now you have workout music and a timer to notify you when your workout is complete.

As always feedback / bug reports can be added to this thread.
Enjoy!