V
V
Vladimir Mironov2014-08-21 11:42:43
PHP
Vladimir Mironov, 2014-08-21 11:42:43

How to play background music on an android tablet?

Greetings!
Flash is not an option.
JavaScript doesn't want to play, and neither does HTML5 set to autoplay.
Is there an alternative?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1Michael1, 2014-08-21
@1Michael1

public class Serve extends Service{

    MediaPlayer mp;
    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }
    public void onCreate()
    {   
        mp = MediaPlayer.create(this, R.raw.b);
        mp.setLooping(false);
    }
    public void onDestroy()
    {       
        mp.stop();
    }
    public void onStart(Intent intent,int startid){

        Log.d(tag, "On start");
        mp.start();
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question