Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Playlist Project

lesak
lesak
6,260 Points

Out of curiosity, what does adding songs to listen to the program involve?

Is that where backend programming /database work comes in?

Steven Parker
Steven Parker
217,443 Points

While unrelated to the question, I thought it was funny that one of the "students likely to have the answer you're looking for" shown on this page is "Random Whoisthis" with a lifetime total of 1646 points. :stuck_out_tongue_winking_eye:

3 Answers

Hi Lesak,

If you kept it simple then you should be able to do it entirely on the front end. If you were going to have a big site with user accounts and users could upload mp3's and create their own playlists, etc.. then you'd have to go backend and databases to store everything.

You would need an audio player to do the actual playing of the music similar to how you need a video player to play a video on your page. To start off with you could use the html5 audio element and rely on the native ui controls that each browser provides.

Treehouse has a course to get you familiar with that: https://teamtreehouse.com/library/html-video-and-audio

The other thing you need is the audio files. Here's a link to caniuse showing support for the various audio formats: http://caniuse.com/#search=audio%20format

It looks to me like mp3 covers everything the other 2 formats cover plus some extra. So with modern browsers you could probably get away with mp3 only. Usually a couple formats are needed for videos in order to have fuller coverage because not all browsers support the same formats.

I haven't implemented this before but I would imagine that you would want to modify your javascript so that when a song changes in the ui you would update the src attribute for the audio element to the current song.

lesak
lesak
6,260 Points

That's really interesting. Thanks for answering my question in such detail. I'll check out the html video and audio course. I must admit I postponed this course in the frontend track because I wanted to go on with learning javascript. I like javascript because I find the language challenging but this course is great. Thanks for your help!

lesak
lesak
6,260 Points

And yes Steven, nice to pick up on that one.