Skip to main content

Android media support to your application - LookThisCode Program

This publication is part of the "LookThisCode". (is Spanish)

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);
    }
   }
[1] To call from a button handler.
[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?

Conclusion
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

Popular posts from this blog

Google Assistant, simpleness of interaction to call a webhook

The creation of an application using Google Assistant is very simple and represent a big impact to interact with users in diverse environments and particularly in home Hey Google ...Where is my dog? If we plan to connect a security camera system, the challenge of finding my pet in an automated way is more feasible, then I will give more details of how I intend to do it. Now we are going to prepare the functionality of the assistant’s requests. To create an agent and interact with Google Assistant , we will use DialogFlow . Let's see the main elements to create an agent, and using this agent call a webhook with some functionality. * Part of the objective will be to try to prepare the logic of interaction with a home security system * Arlo System From the DialogFlow console, we will create a new agent: We can customize different support languages, for this case I will use English to facilitate the testing of the agent. [You can include Spanish and also go in

Architectural reviews of software engineering, a simple approach

I wanted to share an analysis of a very interesting work where they develop concepts related to software architecture solutions. We know that the architecture of a software solution is very important to the success of a development. In my experience as a software architect in previous works dedicated to the software industry, very often expressed an effect of "do not have time to complete thearchitectural review. " What is the justification? if we can justify it. It is very expensive,time consuming, depending on the architectural documentation of the solution, a scenario that could never discuss "is a small project with a limited life cycle, with minimum documentation" So what options do we have when the project has these characteristics, and we'resure that we execute architectural reviews? “However, in spite of the demonstrated benefits of architecture reviews, many projects are unable or unwilling to use them. These projects tend to have the following cha

SMI Developer Day - Session 2 was pure developers adrenaline

A new session of SMI Developer Day program has been conducted at the Cultural Center Borges in Buenos Aires. The event was pure adrenaline to the ecosystem of technology development in Google. A great attendance and I could feel pure adrenaline at the conference on May 8 at the Cultural Center Borges in the context of SMI Developer Day event . In this opportunity we present an approach to development Web solutions , innovative technologies such as HTML5 and present an option for persistence in disconnected scenarios. A great conversation environments with a lot of questions, showed the state of motivation of the developer community in the region. A region full of talent. A region that every day becomes more involved in technology , mobility , computing in the cloud. Furthermore, this region strengthens a vision of entrepreneurship, and drive an amazing ecosystem. An excellent shared moment with the community