Sitemap
Coding Code

Just another blog about development

Introducing PipedBeats

3 min readDec 9, 2015

--

A few days ago I was trying to find my perfect playlist for work, and I realised that there wasn’t only one. Some times you just want a continuous stream of songs, related to a genre or a search. That’s how PipedBeats idea came to my mind.

PipedBeats is a radio streaming web application that let you to define a genre or some keywords to create a random stream of tracks (generously provided by SoundCloud API) to help you concentrate (or not, it’s up to you!) during your work (or relax) hours.

It’s built on pure AngularJS, so the application doesn’t need a backend. And the best part, it’s free and you can access right now on https://pipedbeats.com

Main features

  • Listen to music for free: just choose a genre or a search keywords and start listening.
  • Responsive UI: it’s possible that it won’t fit 100% of screens, but I can assure that I have made our best effort to try. Really :)
  • Completely browser-based: your data is yours and your computer do all the work, so no data is exposed to our server.
  • SSL support: provided by CloudFlare, a shiny DNS provider. Whenever you access the application, it will be over secure connections.

Known limitations

The client hasn’t got limitations itself (except features not implemented yet), but at the moment SoundCloud limits each application to a maximum of 15,000 plays per day.

Also, I have some problems with the bandwidth usage on mobile devices. As SoundCloud doesn’t offer different qualities, the data usage can be a problem.

Personal experience and coding problems

As I have mentioned in precious posts, this is my first real project on AngularJS. As it has to be, I have found some problems during the development:

1. Sharing information between controllers

Get Óscar de Arriba’s stories in your inbox

Join Medium for free to get updates from this writer.

This can be done using three different approaches:

  • Storing the information in the $rootScope.
  • Creating a Service to share variables and functions.
  • Passing information through events.

Well, the first one is obvious: if the $rootScope is a shared variable between controllers, storing information on it is the first thought.

On the other hand, Services are instantiated once, so every controller making use of it will access the same variables. It’s a kind of $rootScope but specialised.

Finally, the events can be emitted in a scope. If you have access to a different controller’s scope, you can emit an event to it. Otherwise, you can emit a broadcast event to all the controllers using:

$rootScope.$broadcast(‘eventName’, args);

2. Update the User Interface when variables are changed

I encounter some problems when asynchronously changing variables that are used in the UI. The just doesn’t get updated.

To solve it, you only need to do your stuff inside an `$apply` call like this:

$scope.$apply(function(){
// Do your stuff here
});

An the variables will be updated on the UI as soon as changed.

3. Send current page to Google Tag Manager

Using virtual paths is perfect for a browser-only application, but Google Analytics doesn’t recognise it as it should.

To avoid this, I have created a Google Tag Manager configuration (thanks Nico!) and pushed a dataLayer object when the state of ui-router is changed:

$rootScope.$on(‘$stateChangeStart’, function(event, toState, toParams, fromState, fromParams){
dataLayer.push({
“event” : “pageView”,
“pageName” : event.currentScope.$state.href(toState, toParams)
});
});

Conclussions

This has been an amazing (and short) project that help me to discover small and valuable things about creating a real application using AngularJS.

I strongly recommend anyone who want to do a new step on the AngularJS world to create it’s own demo application to deal with real problems on your own.

--

--