Playcount for Media Files? - android

I want to query meta data from the external storage. That's pretty straight forward with the ContentProvider. But I also want to get the play count of the mp3 file.
I looked into projects like scrobble droid and subsonic but I didn't find a way to retrieve the Play Count if it's there. (e.g. Winamp supports it.)
Is there a way to get the PC if it's there?

You could manually read in the ID3 tags and check for a playcount attribute, but keep in mind, if this is for your own media player application, you'll have to modify the file each time it is played (load it, modify the ID3 tag, save the changes) which I imagine would be inefficient and a battery drain at best. Also, very few other media players actually DO this (Winamp, from what I see, seems to be one of the few), so it's not going to be an accurate playcount if played with, say, the stock media player, or any other media player which does not modify the ID3 tag.
Most media players that track playcounts (iTunes, Zune, etc.) do so by maintaining a database with playcount as an attribute. Obviously this is not portable between media players, but for your own implementation, I would suggest a database as your solution.

I faced the same problem but found some solution. So, android does not provide the data but music players could store this info. What I did:
* decompiled music app
* grep manifest file looking for provider
* profit
The solution is not perfect but I think there is no other ways to get this information on not rooted device.

Related

Need QMediaPlayer to play mp3 data in memory

I guess small audio clips are necessary for many applications, thus I would expect QT have support playing mp3 in memory slices. Maybe decode mp3 data to wav data in memory may be one solution, but that needs time to decode all data first. For real time application, it is not a good idea. It also doesn't make sense to store mp3_data in a file and ask QMediaPlayer to play that, the performance is unacceptable.
This is my code after many searches by google, including stackoverflow:
m_buffer.setBuffer(&mp3_data_in_memory);
m_player.setMedia(QMediaContent(), &m_buffer);
m_player.play();
where m_buffer is a QBuffer instance, and mp3_data_in_memory is a QByteArray one; m_player is a QMediaPlayer instance.
I got some information that the code here doesn't work in MacOS and iOS, but I am running on Android now.
Does anyone have a solution for Android system? Thanks a lot.
Your code won't work because the media property requires a valid QMediaContent instance:
Setting this property to a null QMediaContent will cause the player to
discard all information relating to the current media source and to
cease all I/O operations related to that media.
There's also no way of telling the QMediaPlayer what format the data is in, you're just dumping raw data on it. In principle QMediaResource can hold this information, but it requires a url and is regarded as null without it.
As you may have guessed, QMediaPlayer and the related classes are high-level constructs not designed for this sort of thing. You need to use a QAudioDecoder to actually decode the raw data, and pipe the output to a QAudioOutput to hear it.

Android: Can I get the OS's last played audio/video or viewed image from inside my application?

Android developers,
I would like to know if it is possible to get, from inside my application, a reference to the last played media (audio or video) or viewed image.
I tried to get a list of MediaPlayer, but all I can get is the MediaPlayer from my own application context, not from the other applications. I could also get the current state for the MediaPlayer (if a file is playing or not), but thas all.
Is this possible?
thanks and regards
I don't think it is possible. For security reasons, an app cannot just view another app's data and there is no global 'recents' list (as in windows).

Android default media player

I want to know how a default media player works.Like how it scans all songs in sd card,how it displays them,so overall entire working on default media player.
I want this information so that I can compare it with my custom media player and check how fast my media player is working as compared to default one.I have tried searching internet but was not able to find some relevant information related to this.
Your question is very broad in perspective and hence, I will refer you to corresponding paths to get an understanding of the overall system.
First, the overall processing of media files starts from the Gallery application. Though not the entry point, ImageCacheRequest could be a good reference point to start the study, which shows how a cached image is read and rendered onto the screen.
Next, to understand how this thumbnail is generated, you will have to refer to ThumbnailManager.java which is invoked from camera, mms etc.
Thumbnail class internally employs MediaMetadataRetriever which is the main class for retrieving the thumbnail data.
MediaMetadataRetriever has a corresponding JNI implementation as shown here. The main function of interest is getFrameAtTime.
The most common implementation is StagefrightMetadataRetriever, which works on a simple principle. First, a MediaExtractor i.e. a parser is created which will sniff out the media-file type and create a corresponding parser entity as shown here. Next, the parser will then invoke a codec to decode the corresponding key frame at the requested time stamp and provide the image back as can be observed in extractVideoFramewithFlags.
Inside this function, a codec is created, frame is decoded, color converted and returned back to the caller which will transfer the same to the higher application.
In a nutshell, I feel your player will not come into picture and as long as the corresponding parsers and codecs are registered with the system, the thumbnails will be generated .
I want to know how a default media player works
There are dozens of "default media player" applications, as different Android devices ship with different "media player" applications, frequently written by their device manufacturers.
You are welcome to take a look at the implementation of the AOSP Music app, and there may be other open source media players that you can examine as well.

Tracking the number of times a video was played

Folks,
The project that I am working on requires that a certain video can be played on an android device for x number of times. After that, it must stop playing. When a client gets the video file, he or she also gets another file that contains the Android device ID and the number of times the video can be played. The original file and the metadata file are both encrypted.
My first thought is just to write a video decoder for the video file. Each time the file is played, the decoder first checks if Android device and the count are valid, decrements the count, starts decrypting the data and streaming it to the mpeg-4 decoder shipped with the OS.
I would appreciate your feedback on this idea. Please share your thoughts if you feel there is a better way to do it.
One problem I see is where to store the actual count. Storing it in the file itself won't work as the user can simply backup the original file and replace it after the count exceeds. It has to be stored in some other part of the system that cannot be tampered by the end-user.
Thank you in advance for your help.
Regards,
Peter
Useless to store it anywhere on the actual device, because anywhere an app can touch a user can as well. Best bet is to use a remote server for authorization, but then you get spoofing problems. But your real goal is to make it a nuisance, not worth going around, instead of making it impossible to crack, because you can't.
Okay, the simplest way would be similar to something you first suggested, and needs no further infrastructure: store the information in a file. This is defeated by reloading the file, as you suggested, but even that is a high enough barrier for some.
Defeat reloading the file via obsfucating where you're storing the information. Possibilities include text files (easy to spot), or perhaps image files (like images that are supposedly button images).
Remember, it only takes 1 guy 1 time to point the playback into a recorder, and you have a perfect, DRM-free copy running around in the wild. Remember that you're simply trying to make it easy enough to view legitimately and difficult enough to crack (take the difference of those) that people won't bother cracking it.

Android Online Radio Player

Is it possible to get track name while playing radio stream via MediaPlayer?
I would say pretty much with certainty - no, it isn't possible.
I can't see any MediaPlayer methods which suggest it's possible plus the way that metadata such as track name etc is presented in streaming media, will depend on the source, e.g, Shoutcast or otherwise.
If it can be done I'd be interested to know but I'd suspect you'd need to write something like a Shoutcast client (or other client depending on source). You'd still use MediaPlayer for streaming but would need extra code for accessing the metadata.

Categories

Resources