From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

MP3 Playlist (m3u) Generator

Code and Documents

Attachment

Introduction

A few months ago I was setting up my HTPC (Home Theatre PC) and loading all my MP3s onto it.

I wanted to be able to create playlists so I could play different styles of music depending on the occasion.

My wife also wanted to be able to create a playlist of music she wanted playin when in the birthing suite at hospital. (So I had a deadline that couldn’t be missed!)

The other problem I had was that the base folder for the MP3 files on the HTPC was different to the base folder on my normal computer where I was creating the m3u playlists.

So instead of C:\Documents and Settings\MeAtHome\My Documents\My Music

The path needed to be C:\Documents and Settings\HTPC\My Documents\My Music

Unfortunately relative paths and system variables didn’t work in the m3u playlists.

There are dozens of apps out there that can do something similar but after hours of searching I couldn't find one that suited me.

So as any DIY LabVIEW type person would, I wrote my own. I thought it would be the perfect opportunity to get the hang of tree controls


Steps to Complete

My MP3s are grouped by artist then album. That's how I decide what I want in my playlist rather than meta data.

So I started with a tree control on the left that displays a recursive list of files that match the filter you specify.


I had to write my own ‘multi file filter’ vi so you could have different types of music files in the list. Windows explorer lets you do this by separating the file filters with a semi-colon but the LabVIEW function doesn’t.


The next feature I wanted was the ability to resolve windows environment variables like %USERPROFILE% in the base path (not absolutely necessary but eh, I wanted it). So I wrote a vi to do that too.


Now the main functionality. Drag and drop individual items and/or parent items to the playlist on the right.


Then a randomize function, load existing file for editing/path change, export to file and it’s done.



Additional Notes

Instructions:

Select the base filepath to your collection of MP3s
[optional] Change "pattern(s)" to suit your files
Click the "Load/Refresh" button to populate the left tree with your MP3 files
Drag the files and or folders from the left tree to the right
[optional] Click "Randomise" to randomise the playlist
[optional] Check the "Use new base path" checkbox and enter the new base path you would like to use.
Click "Save" to save your newly created MP3 playlist (.m3u file)

Sorry no pics or videos to attach. Supply your own music files. Give it a go yourself!

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Deirdre
NI Employee (retired)
on

This is AWSEOME.

Troy, I just featured your application on Developer Zone and the Community

Thanks for sharing.

Deirdre Walsh -- NI Community Manager & Social Media Geek
pallen
Active Participant
Active Participant
on

Very cool!

---------------------
Patrick Allen: FunctionalityUnlimited.ca
Contributors