Play song on default music player - android -
my app show list of song sd card. want able play song on default player. i've got data song: id, title, album, artist, path...
is there way launch default player play song?
what i've tried:
using
intent.category_app_music
. can launch default player, can't set song.intent.makemainselectoractivity(intent.action_main, intent.category_app_music)
open default music app. howeverintent.setdata(uri.withappendedpath(mediastore.audio.media.external_content_uri, id))
throws exception intent not found.using deprecated
mediastore.intent_action_music_player
. activity not found.intent(mediastore.intent_action_music_player).setdataandtype(uri.fromfile(songfile), "audio/*")
- using
intent_action_media_play_from_search
. launch search, not song, says couldn't prepare mix on play music. however, works google now, may key.intent(mediastore.intent_action_media_play_from_search).putextra(searchmanager.query, name)
- using
action_view
. works launch compact version of player, , want full player.
note: want launch external player, not in app.
update: looks google hardcoded play music , youtube support.
if start default music player app on device, should try this:
intent intent = new intent(); intent.setaction(android.content.intent.action_view); file file = new file(your_song_uri); intent.setdataandtype(uri.fromfile(file), "audio/*"); startactivity(intent);
Comments
Post a Comment