Domanda

Intent intent = new Intent();
ComponentName comp = new ComponentName("com.android.music","com.android.music.MediaPlaybackActivity");
intent.setComponent(comp);
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "audio/*");
startActivity(intent);

This is the code that i am using to open samsung player in other phones except galaxy S3. Regarding galaxy S3 this package is replaced with

ComponentName comp2 = new ComponentName("com.sec.android.app.music","com.sec.android.app.music.AudioPreview");

But in this case it is working only as audio preview but on pause it gets finished But i wanted play exactly like the one in the above as a music player . So for that i replaced ComponentName with this to open the musicplayer

 ComponentName comp2 = new ComponentName("com.sec.android.app.music",
                    "com.sec.android.app.music.MusicActionTabActivity");

But in the case the player won't plays the url that i have passed. It just open's the default music player in S3. I need to play file with the android default music player.

È stato utile?

Soluzione

Look Android is using AudioPlaybackPreview or someother named activity, to handle the song playback from fileManager or any other place .

Actually you want to use the default Playing activity ,which is used to show all the controls and all .Dear it's not possible to use that Activity , since it had been linked to someother service having data of all the songs and all paths. This playing Activity has control of next atnd previous and all , that is linked with one playback service.

Third thing is that , as far as i know that S3 is almost providing the same layout for playing the song from filemanager or for plaaying from any other activity. But the problem with that is that when u go back from there , it will stop the playing song.

Refer to android music player source code , u will understand why it's not possible to launch that activity.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top