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:

  1. 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.

  2. using deprecated mediastore.intent_action_music_player. activity not found. intent(mediastore.intent_action_music_player).setdataandtype(uri.fromfile(songfile), "audio/*")

  3. 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)
  4. using action_view. works launch compact version of player, , want full player.

compat view

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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -