Search in sources :

Example 1 with MediaPlayerProxy

use of com.wm.remusic.proxy.utils.MediaPlayerProxy in project remusic by aa112901.

the class MediaService method onCreate.

@Override
public void onCreate() {
    if (D)
        Log.d(TAG, "Creating service");
    super.onCreate();
    mGetUrlThread.start();
    mLrcThread.start();
    mProxy = new MediaPlayerProxy(this);
    mProxy.init();
    mProxy.start();
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // gets a pointer to the playback state store
    mPlaybackStateStore = MusicPlaybackState.getInstance(this);
    mSongPlayCount = SongPlayCount.getInstance(this);
    mRecentStore = RecentStore.getInstance(this);
    mHandlerThread = new HandlerThread("MusicPlayerHandler", android.os.Process.THREAD_PRIORITY_BACKGROUND);
    mHandlerThread.start();
    mPlayerHandler = new MusicPlayerHandler(this, mHandlerThread.getLooper());
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mMediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName());
    mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setUpMediaSession();
    }
    mPreferences = getSharedPreferences("Service", 0);
    mCardId = getCardId();
    registerExternalStorageListener();
    mPlayer = new MultiPlayer(this);
    mPlayer.setHandler(mPlayerHandler);
    // Initialize the intent filter and each action
    final IntentFilter filter = new IntentFilter();
    filter.addAction(SERVICECMD);
    filter.addAction(TOGGLEPAUSE_ACTION);
    filter.addAction(PAUSE_ACTION);
    filter.addAction(STOP_ACTION);
    filter.addAction(NEXT_ACTION);
    filter.addAction(PREVIOUS_ACTION);
    filter.addAction(PREVIOUS_FORCE_ACTION);
    filter.addAction(REPEAT_ACTION);
    filter.addAction(SHUFFLE_ACTION);
    filter.addAction(TRY_GET_TRACKINFO);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(LOCK_SCREEN);
    filter.addAction(SEND_PROGRESS);
    filter.addAction(SETQUEUE);
    // Attach the broadcast listener
    registerReceiver(mIntentReceiver, filter);
    mMediaStoreObserver = new MediaStoreObserver(mPlayerHandler);
    getContentResolver().registerContentObserver(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, true, mMediaStoreObserver);
    getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMediaStoreObserver);
    // Initialize the wake lock
    final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
    mWakeLock.setReferenceCounted(false);
    final Intent shutdownIntent = new Intent(this, MediaService.class);
    shutdownIntent.setAction(SHUTDOWN);
    mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    mShutdownIntent = PendingIntent.getService(this, 0, shutdownIntent, 0);
    scheduleDelayedShutdown();
    reloadQueueAfterPermissionCheck();
    notifyChange(QUEUE_CHANGED);
    notifyChange(META_CHANGED);
}
Also used : PowerManager(android.os.PowerManager) IntentFilter(android.content.IntentFilter) MediaPlayerProxy(com.wm.remusic.proxy.utils.MediaPlayerProxy) HandlerThread(android.os.HandlerThread) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 2 with MediaPlayerProxy

use of com.wm.remusic.proxy.utils.MediaPlayerProxy in project remusic by aa112901.

the class MediaService method startProxy.

private void startProxy() {
    if (mProxy == null) {
        mProxy = new MediaPlayerProxy(this);
        mProxy.init();
        mProxy.start();
    }
}
Also used : MediaPlayerProxy(com.wm.remusic.proxy.utils.MediaPlayerProxy)

Aggregations

MediaPlayerProxy (com.wm.remusic.proxy.utils.MediaPlayerProxy)2 PendingIntent (android.app.PendingIntent)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 HandlerThread (android.os.HandlerThread)1 PowerManager (android.os.PowerManager)1