I am running an application where I need to store an audio on a URL.
Before playing the URL, I want to convert the image of the play button to a pause.
I have to try in context.
The UI changes once the audio is played on the URL and it takes 5-10 seconds to run the server URL
Can someone tell me why this is happening And what is the potential solution.
Please take a look at my code: -
((button) v) .setBackgroundResource (R.drawable.pause); PlayPauseBtn.setId (1); Toast. Maketext (radio activity.This, "Loading ...", Toast. LNNHHLoad) Show (); MediaController.mediaPlayStart (R.raw.acoustic_loop_bgm, radioactivity.Thes.getApplicationContext ()); Public Static Zero Media PlayStart (Int. Resources, Final Reference m_Context) {try {mp = new MediaPlayer ()} Mp.setDataSource (m_Context, Uri.parse (Contants.audioURL)); Mp.prepare (); Mp.setAudioStreamType (AudioManager.STREAM_MUSIC); Mp.setLooping (true); Try {mp.start (); } Hold (exception e) {// TODO: exception exception}} (exception e) {/ TODO: Arrange exceptions system.out.println ("##### Exception in Media Player === "+ E.getMessage ()); }} My locks are here before running the sound.
06-21 17: 15: 17.661: W / Keybrearmark map (1005): No keyboards for ID 0 06-21 17: 15: 17.661: W / K Career Map (1005): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 06-21 17: 15: 21.910: I / System. Out (1005): 00000000000000 06-21 17: 15: 21.910: I / System. Out (1005): 2222222222 06-21 17: 15: 22.080: D / DelWiki (1005): GC_FOR_MALLOC 6592 06-21 17: 15: 26.140: 3592 objects / 199296 bytes in D / Media Player (1005) were released: The client side did not open the file, trying on the server side
This is because you < / P>
using mediaPlayer.prepare (); Use the better async method:
mediaPlayer.asyncPrepare (); This will not freeze your app and your icon will be changed instantly.
Edit:
mp.setDataSource (url); Mp.setOnPreparedListener (this); Mp.prepareAsync (); Posted on Public Zero (Media Player Player) {mp.start (); }
No comments:
Post a Comment