The Climax, atlast

This is where I bring to your table, the Company Secrets of Crashz. The Quest for a multimedia DB ends right here and a tailored Media Player is in for a Grand Launch.

Hariharan M
6 min readAug 4, 2017

Lets rewind the past and take a look at how the home page steered the app to command.

The Song Page

A list of tabs featuring a song. Every song is a complete package Song Name, Composer, Bool Like, Comment Box, Comment List and Date added. Not to forget that each song can play on a sandboxed Custom Media Player designed and hosted by your friendly neighbourhood ‘hari’.

Reader Note: This may feel like yet another update story, coz, I’ve kept some .mp3 and .jpg file handling techniques shrouded for sometime in this series so far.

Beneath the Cover

The song tab is a CardView stacked into a RecyclerView. The CardView template is designed with a Constraint layout tooling.

Cipher Unlocked!

The Challenge with Media Files

We are offered with a Relational DB and even JSON blobs don’t hit the roads with a .mp3 file. I’m left with the local setup for a filestore DB, but I’d problems with the filestore port forwarding. A better proposition to make would be that the SSH tunneling simply can’t go on forever with my laptop working 24/7, which I recall from the DP story.

shark made it clear that the PC has to be running and Wi-fi connected for the VM to be exposed.

Reminding you of the premises I’d made in the DP update story, concerning specifics, the response rate and interactivity, when it comes to a mobile app. I can’t trade-off that with my laptop spinning live all-the-time.

How could I ever keep my laptop running non-stop ?

Where can save a Song?

In a file hosting server, in the Cloud.

GDrive is a popular Cloud File Storage Provider
Microsoft’s OneDrive was meant to integrate work files across devices.

Why can’t you integrate with GDrive to add files on the go within your app, with built-in intents?

There’s a reason, I’d to work within the scope of the project.

I can’t go about research and there are no Google APIs that serve system-intents with a sharable link of the song file.

This is how the drive APIs integrate android with drive.

Reader Note: I sincerely researched for weeks parallely with GDrive for some way of API integration to save and fetch files, but in vain. Its easy to add files, but extracting a public link is out for user discretion and system permissions are nowhere revelant.

Dropbox!

This Cloud Storage Provider saved my day. Now that I can save my files to my Dropbox Personal Cloud, I can easily get a sharable public link that could stream songs for me.

Dropbox offers cloud storage, file synchronization, personal cloud, and client software.

Why not GDrive? Why Dropbox out of nowhere?

I tried GDrive, but when I play the file more than 5 times in a day, I got this Snap Message.

When too many people access the same file in a day, the Drive Server refutes any more requests.

The DP Story Revisited

When I said that I’d secrets to reveal with the ‘*’ in the update post, I was referring to this.

URL response corresponding to the request below.
A typical query for a DP link.
Here’s how the UI looks. Its a custom-alertbox. Pretty easy to handle over creating an activity :), coz, your activity pages are limited to 3. I’ve talked in depth on how permissions and camera intents steal the show, in the last update. Here’s its follow-up.

The Plan

Let me come again. The Pre-Requisite to Crashz is a Dropbox account. I don’t endorse raw .mp3 file links from any-other Cloud File Service. Next, you’ve got to upload your file to Dropbox, enabling sharing via HTTPS, and give me the link. The link is stored into my tables. When you play a Song tab, I stream the song for you from the URL.

Does the URL streaming lag my UI thread?

You needn’t worry on that. I’ve got the most optimized Media Player playing the song, so your Internet Data Use is trivial and the app works seamlessly.

Now, lets gear up and make the insert calls.

Insert a Song

The song table beyond any shadow of doubt is alive. So, lets insert something and kindle some fire.

This is a simple song insert.
This is how the insert UI looks. Again, a custom-layout alert, designed by yours truly.

The Song Tab Explained

There goes a list of song tabs, each with a name, composer, date_created, num_of_likes and comments synced into a single entity, loaded from a view in one shot. Hover over the Thumbs up to like the song. The little arrow to the right is the mix & pix!
Tap on the banner to see the comments added. Its an auto-scroll viewpager, so displays new pages on its free will.

Beneath the Cover

  1. The Media Player holds a lock on the Device’s Power Manager. Obviously, that keeps it playing even when you lock your screen or the system goes into stand-by.
  2. It also holds Wi-fi lock, if you are connected to a hotspot, so that there are no spurts when playing a song.
  3. I’ve designed the Media Player to work only within the scope of the app. If you navigate out of the app, on a back-press, the song won’t be playing in the background anymore. Why? Its Coming up.
  4. The auto-scroll comments view-pager was imported from a .jar package into the gradle. Its not worth bragging about.
  5. The Like Thumbs up switching to a Heart is the work of no selectors. A simple setImageResource() to the button upon ‘select’ is all there to it.
  6. ‘Your Songs’ Page is easy to compute. I pass your hasura_id instead of user_id to fetch your songs :)
The Crashz Media Player in action

Why is the Media Player not run as a System Service?

A system service runs in the background even while navigating out of apps. A typical example would be a Task Manager. Its possible to lock the device’s speakers to run music, between app sessions. But, whats the app’s intention?

The Intended Audience

This app targets long-time commuters, people who spend hours in travel, typically, us, Day-Scholars. There is no way a commuter could stand hours of journey without some recreation. If you were to listen your own songs, it gets horrible after a few days. Boring, I would say. If it were your friends’ songs, there are some intriguing moments when you click on the song’s handle, awaiting for a thriller :)

End of Design

With this we come to the end of Crashz Design Architecture. Its taken me a lot of time and effort to design and code the app’s pages.

But self-conscience and passion kept me going to what the app’s turned out.

There are a lot to thank for this. But, lets save it all for the next story. And, please look into my git repo to exactly know how things are done.

So Long then :)

--

--