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.
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.
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.
Where can save a Song?
In a file hosting server, in the Cloud.
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.
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.
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.
The DP Story Revisited
When I said that I’d secrets to reveal with the ‘*’ in the update post, I was referring to this.
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.
The Song Tab Explained
Beneath the Cover
- 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.
- It also holds Wi-fi lock, if you are connected to a hotspot, so that there are no spurts when playing a song.
- 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.
- The auto-scroll comments view-pager was imported from a .jar package into the gradle. Its not worth bragging about.
- 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.
- ‘Your Songs’ Page is easy to compute. I pass your hasura_id instead of user_id to fetch your songs :)
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 :)