I am building an audio player where user can select a song which he wants to listen from a ListView. After he clicks on a song, audio player starts playing that song.
Audio files are not stored locally, they are fetched from some online audio library. After user opens a list of songs, he receives a lot of urls who look like this:
http://audiolibrary.com/user/1/77.mp3
http://audiolibrary.com/user/1/567.mp3
http://audiolibrary.com/user/1/34.mp3
Each song is identified with unique id as you can see. It's easy to temp download that song and play audio and that is working fine. The thing I want to accomplish is something like this:
User clicks on a song1 in list view and song1 starts playing
In the middle of the reproduction, user decides he had enough of song1 and switches to song2
He closes the app while song2 is still not finished
Next time when he opens an app, if he clicks on song1 or song2, reproduction starts from the place where he stopped listening for the song1 or song2
How to efficiently accomplish something like that on Android? Should I create an SQLite database for this situation, use SharedPreferences or something else? How do you usually handle similar situations?
Thank you :)
You need to store the time he pressed pause at in a permanent fashion. The options for this are database, shared preference, web service or file. Each has pros and cons.
Database pros: easily extensible with other information if needed, no difficult parsing code
Database cons: lots of setup code for what's a fairly simple amount of data, additional dependencies on 3rd party code
Shared preference pros: minimal code to setup and use
Shared preference cons: not really meant for dynamic string names, slow to parse and performance will degrade as the number of strings decrease, not easily capable of storing additional data.
webservice pros: would be available across devices/platforms
webservice cons: requires a server and the most code to do, requires an internet connection
custom file format pros: absolutely optimized for your needs, easily extensible if you design the format well
custom file format cons: all custom code and you'll have to write all of it.
Pick the one that weighs out the best for you.
Related
I'm writting simple music player. There is a fragment in the app, where user can search for tracks. I want to show last 5 (for example) user queries. SharedPreferences only allows to save unordered data. I'm not sure but using SQLite only for 5 strings sounds strange.
What is the best way to save user queries?
I'm currently working on audiobook player application I and I'm thinking about how to keep references to audiobook files.
So far I let user specify folder where books are kept and recognize subfolders / particular books.
Now I need to store those references. Audiobooks are always released in many parts, so lets say we have a 'Season of Storms' book and we have like 20 parts of that book: seasonofstorms-part1, seasonofstorms-part2 and so on.
I need to keep them linked to particular book and I need some more additional information stored, like what is name of the part that user finished listening to, and what is the time this part should start while opening book again.
So I though it could fit nicely in some JSON schema. I could make POJOs like:
Show with fields: name and List parts,
Part with fields: status [finished, notStarted, inProgress], time.
After resuming listening to a book application would search for part with 'inProgress' status and start playing at 'time'. I could parse these POJOs to JSON and keep them in SharedPreferences. What do you thing of this approach? Some better options? How could I make this work in any other way and what is the best approach in your opinion?
I'm currently working on my first serious app., and I would like to have some sort of contol on the data that users can enter.
Specifically, my app. allows users to write some text content (imagine something like a 'tweet'), and upload pictures.
I would like to prevent them from writing inappropriate text, and uploading offensive pictures for instance.
What I thought of doing, is to allow something like 'report abuse' button, where users who find some content offesive, can press - in which case relevent data will be saved, and later checked, to decide if indeed an inappropriate usage happened (maybe by some sort of server-side code).
As I said, I'm a beginner in android development, and I would really love to hear your suggestions and guiding. Perhaps it is something over my league for now? Maybe you know of such thing that already exists?
My app. uses Parse.com as its DB.
I would really appriciate your help.
Thank you.
I'm developing as well an app with parse and I also had to integrate in it a report button for the user.
The way I did it is simple:
In every Pf User object, I created a field of type counter named "reportCounter" while in the PFObject created by the user (it can be a string, a picture, etc.)I created a boolean field named "isReported". When a user find some inappropriate content he can report it through the dedicated button. The PFObject relative to that content gets its isReported field changed to YES and a parse background job checks every day for all the PFObjects, incrementing the reportCounter field of the owner-creator of the content and sending a report e-mail to the administrator. In this way you can keep also a record to see if a particular user is behaving badly. Just take a look at the Parse documentation about background-jobs. It's pretty good.
I hope this will help.
I'm in course of developing an application, which basically is a quiz. I store all the questions on an external server, and fetch them as JSON files. I'd like to implement some Facebook features, most importantly the possibility of challenging other players. However, in order to compare the results, I'd like that other user to use the same set of questions in a current game, as I do - situation similar as in SongPop, where two players guess the same songs. I'm not sure though if it's possible for a standard Android app, not Facebook app like SongPop. I'm looking for a way of somehow sending a 'data pack' to him, containing the questions I have for the current challenge.
Create a Question Set which is a collection of Questions.
e.g. QuestionSet1 will contain Question2, Question4, Question5.
You can just send QuestionSet1 to the user being challenged. e.g. mysite.com/game/?questionsetid=1
On your server, if the url contains the parameter 'questionsetid', that meets you'll get the questions from the Question Set.
Android application Sound Track is doing some following job.
Listen the song/sound track
Search the track from server
Provide full detail about the track like movie name, album name, singer etc
My question is Which type of mechanism they are using to track a sound/song?
Record a small excerpt of the song using the microphone.
Upload it to the server
Run a matching algorithm against your excerpt and the precompiled database that you've made containing thousands of songs.
Find the best match, and send the result back to the device.
Show the information to the user