Back to project page MusicPlayer.
The source code is released under:
MIT License
If you think the Android project MusicPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dsvoronin.musicplayer; /*from w w w . j a v a2 s.c o m*/ import android.os.Handler; import android.util.Log; /** * Short pause * ----------- * Created by dsvoronin on 26/02/14. */ class PausedState extends PlayerState { private static final int STOP_DELAY = 30000; private Handler handler = new Handler(); private Runnable serviceKiller = new Runnable() { @Override public void run() { service.stopSelf(); } }; protected PausedState(MusicPlayerService service) { super(service); } /** * after 30 sec of pause service will be dropped, if no actions called */ @Override void onActivated() { handler.postDelayed(serviceKiller, STOP_DELAY); } @Override void onDeactivated() { try { handler.removeCallbacks(serviceKiller); } catch (Exception e) { Log.w(MusicPlayerService.TAG, "Can't remove callbacks from serviceKiller", e); } } @Override void play(int id) { service.play(id); } @Override void pause() { } }