This publication is part of the "LookThisCode". (is Spanish)
Concepts
Look Code
Important lines of code that deserve detailed explanation.
Conclusion
With this code segment can provide an elementary, middle to support our application Android.
References
Code
[1] To call from a button handler.
[2] Media handling for Android.
[3] For specification of the code.
public void IniciarMusica() { try { Uri archivo = Uri.parse("http://nicolasbortolotti.com.ar/mp3/Corelli%20-%20Preludio.mp3"); mp = MediaPlayer.create(this, archivo); mp.start(); } catch(Exception ex) { Log.e("Depurar", "falla en el archivo de audio",ex); } } |
[2] Media handling for Android.
[3] For specification of the code.
Concepts
MediaPlayer.create() | Create a new object MediaPlayer. |
MediaPlayer.start() | Starts playback. |
MediaPlayer.stop() | Stops playback. |
Uri.parser() | To analyze and format to "URI" character string. |
Look Code
Important lines of code that deserve detailed explanation.
Line 1: mp = MediaPlayer.create(this, archivo); | This line creates the playback mechanism, stating the context and passing the"URI" mp3 file. |
Line 2: mp.start(); | This line makes audio playback function. |
Did you find the value of source code?
With this code segment can provide an elementary, middle to support our application Android.
References
[1] Developers Android, Managing a handler for a button. | Ver |
[2] Developers Android, Media Management. | Ver |
[3] Android Wireless Application Development |
Comments
Post a Comment