I am an Android developer. I've developed a media player that can play both local and streaming videos. But there is a problem. When I click a local media in the gallery how can I configure it to be played with my player? At least, there should be a list of media players including mine one and I should be able to choose it from this list. After succeeding this, I want to open rtsp protocoled files with my player as default. How can I do this? Waiting for your help.
What you are looking for is called an Intent Filter. Specifically, you want to set up an intent filter on the type of media you are playing, a data type intent filter. There is more information on this in the Android SDK.
Related
I want to develop an Android app that plays music from Last.FM API.
But I can’t find methods that response with mp3 file. Also in Last.FM API documentation I couldn’t find the answer! I can retrieve only track/artist/charts and etc. But I need track media file…to play selected track.
I need to play music without user authentication is it possible?
Does someone know how I can retrieve Last.FM song to play (which method will allow to to it and give me the media file? Or maybe there is some other solution, maybe documentation/example?)
lastfm does not provide media file that contain .mp3 file
I've made an app in Android Studio which is essentially a parametric EQ with some additional features.
The app takes signal from the microphone source (whether the built-in mic or external mic). The signal is then passed through biquad filters and out to the speakers/earphones. I used LibPb to handle the signal processing.
Now, I want all the audio that would be coming out the speakers to be routed through the app.
In other words, any music playing or calls, I want the audio to also be passed through the filters in my app.
I have tried to find articles/resources on this topic but haven't found much.
I'm guessing that it can be done via Audio Focus or Media Router or something along those lines, but I cant figure it out!!
Firstly, is this possible?
Secondly, any code or hints as to how to go about it?
Any help is much appreciated!!
I am developing a musical piano app for android, in this app i want to record sound which user play by clicking piano buttons. I am using soundpool to play piano sounds. now for recording android gave us two api's MediaRecorder and AudioRecorder. but for both we have to set MediaRecorder.AudioSource. i didn't want to record sounds from mic because user sound can be included and more important sound quality decrease in recording. then i try to read bytes of that resource file which is played on clicking piano app. and when user click again and again then bytes will be together in global byte array. but when i play global byte array then this play only one resource file and one time only.
More important thing is i am new to android development. kindly guide me.
Although i did not find answer of my question, but now i am using technique for recording aspects which i want to share with all of you. Above function which i try to use is totally wrong option when you are trying to save music created by your app at run time. now for my first version i just saving the clicks of piano buttons along with system time in an array. now when i play that clicks it will play same sound as user try to record. i save these notes in database for further reuse by users.although this is not solution because these notes will be played in our app only, but this is good feature which we can add in our app. when i solve the correct solution, i will share with you guys
I need to execute Intent, but I also need to set application directly. I know that I can do it using Intent.setPackage(), and I need to set Android Media Player by default. Please, tell me, how can I do it? Thank you.
but I also need to set application directly
This is almost never a good idea.
I need to set Android Media Player by default
There is no "Android Media Player". Different devices will have different built-in "media player" apps.
I'm looking for a way to control the default Android media player from my own service. I'm NOT interested in playing media from my service or activity; I want to control the existing application, which consists of an activity (MediaPlaybackActivity.java) and more importantly a service (MediaPlaybackService.java) located in packages/apps/Music/src/com/android/music/. Ideally, I would like a solution that is independent of the version of Android.
I have figured out how to do pause/play/stop/next/previous operations using Intents. I can intercept track change events using a broadcast receiver. I can also get a list of playlists and the contents of each playlist. What I would like to be able to do is instruct the MediaPlaybackService to play a specific file/song. Again, I don't want to play this song in my application; I want the Android default media player to play it.
I have tried two approaches so far:
I imported the IMediaPlaybackService.aidl file from packages/apps/Music/src/com/android/music into my own application, and used this to bind to the MediaPlaybackService. On Froyo, this works great; I can pass a path to the openFile method, and the service will play the file. However, on Gingerbread, I get an error: Permission Denial: Accessing service ComponentInfo{com.google.android.music/com.android.music.MediaPlaybackService} from
pid=17721, uid=10058 requires null. Finding a workaround to this error would be a good temporary solution, but it's not future-proof. This service may well change again in future versions of Android.
Starting the media player via an ACTION_VIEW Intent. This also works; however, as expected, the media player UI is brought to the front, which is not ideal.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(someUri, "audio/mp3");
startActivity(intent);
Is there any other way to accomplish this? Is there an Intent I missed that would instruct the media player to play a specific song? Or alternatively, is there away to start an activity in the background, or to start an activity and immediately switch back to the previous one?
Sorry, there is no supported way to do this. All of the stuff you are describing is using private implementation details, and as you have seen is not robust. If you want to play music, you should do it in your own app.
I'm looking for a way to control the default Android media player from my own service.
There is no "default Android media player". The application you are referring to may exist on some devices and will not exist on others. AFAICT, few devices will have what you think is the "default Android media player" going forward -- those not already running proprietary media players from device manufacturers may have the new proprietary Google Music app.