Jump to content

TextBin Online

TextBin is a website where you can store any text online for easy sharing.
Buy now
Info
  • News ticker sample
  • News ticker sample
SuperVegita1

Mp3 Java Android Code

Recommended Posts

package com.example.audiomediaplayer1;  

  

import android.media.MediaPlayer;  

import android.net.Uri;  

import android.os.Bundle;  

import android.app.Activity;  

import android.view.Menu;  

import android.widget.MediaController;  

import android.widget.VideoView;  

  

public class MainActivity extends Activity {  

  

    @Override  

    protected void onCreate(Bundle savedInstanceState) {  

        super.onCreate(savedInstanceState);  

        setContentView(R.layout.activity_main);  

          

        MediaPlayer mp=new MediaPlayer();  

        try{  

            mp.setDataSource("/sdcard/Music/maine.mp3");//Write your location here  

            mp.prepare();  

            mp.start();  

              

        }catch(Exception e){e.printStackTrace();}  

          

    }  

  

    @Override  

    public boolean onCreateOptionsMenu(Menu menu) {  

        // Inflate the menu; this adds items to the action bar if it is present.  

        getMenuInflater().inflate(R.menu.activity_main, menu);  

        return true;  

    }  

  

}  

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




General Chat

General Chat

Please enter your display name

×
×
  • Create New...