Thursday, June 25, 2015

"Measure Twice and Cut Once" - An Open Request for Help Planning LibriFox Development

I'm making this post as an open invitation to anyone who sees it who either can offer advice themselves or who knows someone who could offer good advice to please send it our way!

As I described in a previous post, I have commissioned a former student to create a Firefox OS app for me that will download and play books from the LibriVox audio books website.

My motivation for funding this project is twofold:
  1. To get a usable app for playing LibriVox books on my Firefox OS phone.
  2. To explore free software development best practices that we can then use in future projects.
I'm acting as the on-site customer on the project, but I have to admit to being in a bit over my head.  Alex sent me this email today:
Hey Jeff,
Dominic [one of the Firefox OS Music player app developers] hasn't responded to me yet, but I've been thinking more about how the chapter files' metadata should be stored.  I'm actually thinking that maybe json stored in each chapter folder isn't the best solution.  I think sticking with localStorage is the better option, because it is reliable (we'll never have to worry about not having localStorage, whereas json files can be deleted) and only LibriFox can modify its own localStorage, whereas json files could be modified by other apps. 

The downside to using localStorage, of course, is that the metadata doesn't follow the data, but is instead tied to the device.  But how often are you really going to be swapping sdcards between devices? Worst case scenario, you might have to just redownload the chapters through the app on the new device rather than having them pop up automatically.
Depending on how much you care about the portability use case, I can also attempt to have it do what you were suggesting and pull data from the server based on the book id, assuming the files were originally downloaded through the app.  Otherwise, it could fall back on ID3 tags if they are present.  This gets pretty complicated, though.

Also, I know you were concerned about keeping the metadata in sync with the data, so I'm working on metadata validation.  The latest commits to the repo have an object that scans the metadata and verifies all the paths when the app is started.  It looks like there are filesystem events that I can hook into as well.
Let me know what your thoughts are!
I don't know how to respond to Alex.  I don't want to go down a path that is "expensive" both in time now and maintenance costs in the future, but I think that switching SD cards may happen more than Alex thinks, or at least it is not at all unlikely that an SD card will be removed, and when that happens, how should LibriFox behave?

Alex is a terrific young programmer.  He has great instincts and very high standards, which is why I was so happy about him taking on this "Summer of Code" project to begin with.  But he did just graduate high school, and he lacks the wealth of experience that a veteran programmer would bring to a project like this.

I want to make the best contribution to Firefox OS that I can.  As a teacher by trade, I also want this to be the best learning experience for Alex that it can be.  For both of those goals to be realized, however, input from programmers who do have the experience Alex lacks will be required.  I've been trying everything I know how to do reach out to the Mozilla and broader free software communities to ask for the help we need.

This blog post is part of that reaching out.  If you think you can provide meaningful feedback to the questions Alex raises in his email, please send it our way.  Thanks!

Monday, June 22, 2015

Providing Developer Debugging Feedback on Firefox OS

I reported a bug on Alex's LibriFox app which is preventing book files from playing.  Alex has been unable to reproduce the bug, since the downloaded book plays on his phone, but it won't play on mine.  He sent me an email this morning detailing the steps I need to take to provide him with useful information from my phone about the bug.

Since this process will be generally useful, I'll describe in detail what he told me to do and what happened (Alex's instructions are in green).

1. First, go into developer tools and make sure Console enabled is checked.  For whatever reason, it won't log errors to console without that checked (even though it seems to log console.log statements just fine).  We want errors to be logged, so enable that.

After clicking on the "Settings" icon on the home screen, and then the "Developer" link, I arrived at the screen above and confirmed that "Console enabled" was already checked.

2. Next, open the app via the IDE (with your flame connected and set as the USB device) and click the wrench to open developer tools.  Go to the console tab.

Don't do any app navigation until you have opened the console!
Once the console is opened, tap your downloaded book, then the downloaded chapter to take you to the (not working) player page.

It is so cool how well this works!  I connected my device via USB, then selected "Firefox OS (Flame)" from the "Select Runtime" in the Web IDE.  After giving permission on the phone to connect, I was able to select the installed LibriFox from App menu in the upper left of the Web IDE. I didn't even have to click on the wrench, it was already selected, and I saw what is in the screen shot above.

3. If there is an error being thrown somewhere, your console might look something like this.  I've added a throw statement in my code to try and simulate your issue.
Inline image 1

If the file can't be found, your console will look something like this:
Inline image 2

Both of these cases will result in a non-functional player and no chapter title in the header, so without seeing console I can't tell which is which.

Clicking my way through the app as instructed, I saw this:

Now I'll wait and see what Alex can do with this information.

What I keep liking about this OS is how friendly it is to developers.  That really isn't surprising, given Firefox's mission of "making the Web better and more accessible for everyone everywhere", but it is great to see this mission being carried out so well!

Sunday, June 21, 2015

Problems with Media Files in LibriFox and the Need to Find Good Support

As I mentioned in my last post, Alex Hirschberg is working on a Firefox OS app to play audio books from LibriVox. While his "Summer of Code" is just beginning, he has already made significant progress on the LibriFox app.  Because of this, we are now confronted with a problem we've encountered for the whole time we've been working with the platform -- it is very difficult to navigate mozilla's labyrinthine network of forums and irc channels to actually find someone in the know who can answer questions.

I'm hoping we are able to at least partially resolve this problem sooner rather than later, or I fear we may not be able to make the most of Alex's contribution this Summer.

LibriFox is designed to play audio books, which on the LibriVox website are stored as mp3 files. The problem is that music files are stored in the same format, and the Music app finds these files and automatically loads them into the menu:

AlĂ­ Primera and Johann Sebas[tian Bach] are music albums, Victor Hugo and Unknow artist are not. As Alex continues working on LibriFox, I would like it to support at least two ways to install books:

  1. Direct download from the LibriVox website using the app.
  2. Copying the audio files from a desktop computer to a USB connected phone.
To make this work well, we will need to resolve the problem of having the audio books appear in the Music app, and figure out a good place to put the files that get downloaded so that both methods of adding books can be supported.

I have a 32 Gigabyte SD card in my phone, and I plan to put a lot of books on it as LibriFox develops.  For a first go at this, I created a directory named AudioBooks and copied the audio files for Les Miserables into a subdirectory:

That's where Victor Hugo is coming from.

It would save us a lot of time and expense if we could get some guidance from someone at Mozilla on how best to approach this problem.  Our first experiment using a recommended irc channel did not work for us at all.  We posted the same question on each of two successive days, waited 6 hours for someone to answer, and did not get an answer on either day.

Since I'm hoping these blog posts I'm making will be of use to other folks interested in contributing apps to Firefox OS, I promise to post recommended help resources once I find some that work well.

Saturday, June 13, 2015

Firefox OS App Development "Summer of Code" Begins

I love my Firefox OS phone!

Despite being an IT teacher, I'm often not an early adopter of new technologies, for several reasons:
  • I'm not a gadget person, and I'm not interested in technology for technology's sake.
  • I'm repulsed by consumerism, and completely turned off by technologies that view me as a consumer rather than a human being.
  • My interest in technology has from the beginning been rooted in the role it can play in social justice, broadening access to information and communication and expanding the possibilities for participatory democracy. I thus won't adopt new technologies that are proprietary consumer items. I am perfectly willing to wait for versions that emerge in the land of freedom in which I wish to dwell.
I did get a mobile phone for a brief period several years back, but I didn't like it and the bill the first month was way too high, so I got rid of it and haven't had one since.

I have a phone now running Firefox OS, and it is just what I want in a phone:
  • It is simple and easy to operate.
  • It let's me do the things that are important to me: make phone calls, send text messages, look at my calendar, look up contacts, listen to music, listen to FM radio, take pictures, find my location and get directions, with a clean, attractive interface that is a pleasure to use.
  • It lets me access its file system from my Ubuntu desktop machine through a USB connection, making it easy for me to add and remove music and other data.
  • It treats me like a human being, not a consumer -- it offers me useful tools and resources without constantly try to sell me stuff!
I love my Firefox OS phone so much that I am commissioning one of my best and brightest former students, Alex Hirschberg, for a local "Summer of Code" type internship writing Firefox OS apps between now and August.

The first app he will be writing we are calling LibriFox.  It is an audio book player for Librivox audio books. Since I don't have a car and either take the bus, walk, or sometimes bike to work, I like to listen to audio books as I travel.  This app will provide me with hours and hours of pleasure, and point me in the direction of listening to some of the large collection of classic literature available on the LibriVox site.

I want to experiement during Alex's internship with the Extreme Programming processes to manage goals and maintain code quality. We'll specifically focus on user stories, iteration planning, unit tests, and refactoring.  Alex has already been schooled in the last two practices by his programming mentor.  This Summer will give him experience working with an on-site customer (me).

Alex will be posting his code to his github repo. As soon as he sets it up for me, I'll begin using the issues tracker for user stories.

Since we are planning a six week process with weekly iterations, I intend to make a new post after each iteration meeting to document how we do.