当前位置: 首页>>代码示例>>Java>>正文


Java MediaButtonReceiver.handleIntent方法代码示例

本文整理汇总了Java中android.support.v4.media.session.MediaButtonReceiver.handleIntent方法的典型用法代码示例。如果您正苦于以下问题:Java MediaButtonReceiver.handleIntent方法的具体用法?Java MediaButtonReceiver.handleIntent怎么用?Java MediaButtonReceiver.handleIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.media.session.MediaButtonReceiver的用法示例。


在下文中一共展示了MediaButtonReceiver.handleIntent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    if (startIntent != null) {
        String action = startIntent.getAction();
        String command = startIntent.getStringExtra(CMD_NAME);
        if (ACTION_CMD.equals(action)) {
            if (CMD_PAUSE.equals(command)) {
                mMediaController.getTransportControls().pause();
            }
        } else {
            // Try to handle the intent as a media button event wrapped by MediaButtonReceiver
            MediaButtonReceiver.handleIntent(mMediaSession, startIntent);
        }
    }

    return START_STICKY;
}
 
开发者ID:AllThatSeries,项目名称:react-native-streaming-audio-player,代码行数:18,代码来源:AudioPlayerService.java

示例2: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    if (startIntent != null) {
        String action = startIntent.getAction();
        String command = startIntent.getStringExtra(CMD_NAME);
        if (ACTION_CMD.equals(action)) {
            if (CMD_PAUSE.equals(command)) {
                mPlaybackManager.handlePauseRequest();
            } else if (CMD_STOP_CASTING.equals(command)) {
                VideoCastManager.getInstance().disconnect();
            }
        } else {
            // Try to handle the intent as a media button event wrapped by MediaButtonReceiver
            MediaButtonReceiver.handleIntent(mSession, startIntent);
        }
    }
    // Reset the delay handler to enqueue a message to stop the service if
    // nothing is playing.
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY);
    return START_STICKY;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:23,代码来源:MediaService.java

示例3: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
/**
 * (non-Javadoc)
 * @see android.app.Service#onStartCommand(android.content.Intent, int, int)
 */
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    if (startIntent != null) {
        String action = startIntent.getAction();
        String command = startIntent.getStringExtra(CMD_NAME);
        if (ACTION_CMD.equals(action)) {
            if (CMD_PAUSE.equals(command)) {
                mPlaybackManager.handlePauseRequest();
            } else if (CMD_STOP_CASTING.equals(command)) {
                CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true);
            }
        } else {
            // Try to handle the intent as a media button event wrapped by MediaButtonReceiver
            MediaButtonReceiver.handleIntent(mSession, startIntent);
        }
    }
    // Reset the delay handler to enqueue a message to stop the service if
    // nothing is playing.
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY);
    return START_STICKY;
}
 
开发者ID:googlesamples,项目名称:android-UniversalMusicPlayer,代码行数:27,代码来源:MusicService.java

示例4: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Timber.i("onStartCommand called");
    super.onStartCommand(intent, flags, startId);

    if (intent != null && MediaStoreUtil.hasPermission(this)) {
        mBeQuiet = intent.getBooleanExtra(EXTRA_START_SILENT, false);

        if (intent.hasExtra(Intent.EXTRA_KEY_EVENT)) {
            MediaButtonReceiver.handleIntent(musicPlayer.getMediaSession(), intent);
            Timber.i(intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT).toString());
        } else if (ACTION_STOP.equals(intent.getAction())) {
            stop();
        }
    }
    return START_STICKY;
}
 
开发者ID:marverenic,项目名称:Jockey,代码行数:18,代码来源:PlayerService.java

示例5: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if(L) Log.i(LOG_TAG, "Starting service");
    if (intent != null && intent.getAction() != null) {

        switch (intent.getAction()) {
            case ACTION_PLAY:
                if(L) Log.i(LOG_TAG, "Calling play");
                mediaController.getTransportControls().play();
                break;
            case ACTION_STOP:
                if(L) Log.i(LOG_TAG, "Calling stop");
                mediaController.getTransportControls().stop();
                break;
        }
    }

    // receives and handles all media button key events and forwards
    // to the media session which deals with them in its callback methods
    MediaButtonReceiver.handleIntent(mediaSession, intent);

    return super.onStartCommand(intent, flags, startId);
}
 
开发者ID:theBoyMo,项目名称:RadioPlayer,代码行数:24,代码来源:PlaybackService.java

示例6: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        String action = intent.getAction();
        if (action != null) {
            switch (action) {
                case ACTION_STOP:
                    stop();
                    break;
                case ACTION_PAUSE:
                    pause();
                    break;
                case ACTION_RESUME:
                    resume();
                    break;
            }
        }

        MediaButtonReceiver.handleIntent(mediaSession, intent);
    }

    return super.onStartCommand(intent, flags, startId);
}
 
开发者ID:segler-alex,项目名称:RadioDroid,代码行数:24,代码来源:PlayerService.java

示例7: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand");

    castSession = castSessionManager.getCurrentCastSession();

    if (sessionManagerListener == null) {
        sessionManagerListener = new SessionManagerListenerImpl();
        castSessionManager.addSessionManagerListener(sessionManagerListener);
    }

    String requestType = intent.getStringExtra(MediaRecorderService.REQUEST_TYPE);
    Log.d(TAG, "onStartCommand received request: " + requestType);

    if (requestType != null && requestType.equals(MediaRecorderService.REQUEST_TYPE_START)) {
        Log.i(TAG, "Started service");
        // After binding with activity, will hear setActivity() to start recording
    }
    else if (requestType != null && requestType.equals(MediaRecorderService.REQUEST_TYPE_STOP)) {
        stop();
    }
    else {
        MediaButtonReceiver.handleIntent(mediaSession, intent);
    }

    return START_STICKY;
}
 
开发者ID:aschober,项目名称:vinyl-cast,代码行数:28,代码来源:MediaRecorderService.java

示例8: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    if (startIntent != null) {
        String action = startIntent.getAction();
        if(action!=null) {
            if (action.equals(MediaTasks.ACTION_STOP)) {
                stopSelf();
            }else {
                MediaTasks.executeTask(playbackManager, action);
            }
        }
        MediaButtonReceiver.handleIntent(mediaSession, startIntent);
    }
    return START_NOT_STICKY;
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:16,代码来源:MusicPlaybackService.java

示例9: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
//@AddTrace(name = "onStartCommand", enabled = true/*Optional*/)
public int onStartCommand(Intent intent, int flags, int startId) {

    // checking for empty intent
    if (intent == null) {
        LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
        stopForeground(true); // Remove notification
        stopSelf();
    }

    // ACTION PLAY
    else if (intent.getAction().equals(TransistorKeys.ACTION_PLAY)) {
        LogHelper.v(LOG_TAG, "Service received command: PLAY");

        // get URL of station from intent
        if (intent.hasExtra(TransistorKeys.EXTRA_STATION)) {
            mStation = intent.getParcelableExtra(TransistorKeys.EXTRA_STATION);
            mStationID_Position = intent.getIntExtra(TransistorKeys.EXTRA_STATION_Position_ID, 0);
            mStreamUri = mStation.getStreamUri().toString();


        }
        // update controller - start playback
        mController.getTransportControls().play();
    }

    // ACTION STOP
    else if (intent.getAction().equals(TransistorKeys.ACTION_STOP)) {
        LogHelper.v(LOG_TAG, "Service received command: STOP");

        // update controller - pause playback
        mController.getTransportControls().pause();

    }

    // ACTION DISMISS
    else if (intent.getAction().equals(TransistorKeys.ACTION_DISMISS)) {
        LogHelper.v(LOG_TAG, "Service received command: DISMISS");

        // update controller - stop playback
        mController.getTransportControls().stop();


    }

    // listen for media button
    MediaButtonReceiver.handleIntent(mSession, intent);

    // default return value for media playback
    return START_STICKY;
}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:53,代码来源:PlayerService.java

示例10: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "Got an intent");
    if (intent != null && intent.getAction() != null) {
        Log.v(TAG, "Received intent:" + intent.getAction());

        switch (intent.getAction()) {
            case ACTION_STOP:
                notifyDismissed();
                closeConnection();
                break;
            case ACTION_SEARCH_FORWARDS:
                handleSearchForwards();
                break;
            case ACTION_NEXT:
                handleNextChannelRequest();
                break;
            case ACTION_PAUSE:
                handlePauseRequest();
                break;
            case ACTION_PREVIOUS:
                handlePreviousChannelRequest();
                break;
            case ACTION_SEARCH_BACKWARDS:
                handleSearchBackwards();
                break;
            case ACTION_PLAY:
                handlePlayRequest();
                break;
            default:
                MediaButtonReceiver.handleIntent(mediaSession, intent);
        }
    }
    return START_NOT_STICKY;
}
 
开发者ID:freshollie,项目名称:monkeyboard-radio-android,代码行数:36,代码来源:RadioPlayerService.java

示例11: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    MediaButtonReceiver.handleIntent(mediaSession, intent);
    return super.onStartCommand(intent, flags, startId);
}
 
开发者ID:SergeyVinyar,项目名称:AndroidAudioExample,代码行数:6,代码来源:PlayerService.java

示例12: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    MediaButtonReceiver.handleIntent(mSession, intent);
    return super.onStartCommand(intent, flags, startId);
}
 
开发者ID:Jaysaw,项目名称:NovaMusicPlayer,代码行数:6,代码来源:MusicService.java

示例13: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    // checking for empty intent
    if (intent == null) {
        LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
        stopForeground(true); // Remove notification
        stopSelf();
    }

    // ACTION PLAY
    else if (intent.getAction().equals(ACTION_PLAY)) {
        LogHelper.v(LOG_TAG, "Service received command: PLAY");

        // get URL of station from intent
        if (intent.hasExtra(EXTRA_STATION)) {
            mStation = intent.getParcelableExtra(EXTRA_STATION);
            mStationID = intent.getIntExtra(EXTRA_STATION_ID, 0);
            mStreamUri = mStation.getStreamUri().toString();
        }

        // update controller - start playback
        mController.getTransportControls().play();
    }

    // ACTION STOP
    else if (intent.getAction().equals(ACTION_STOP)) {
        LogHelper.v(LOG_TAG, "Service received command: STOP");

        // update controller - pause playback
        mController.getTransportControls().pause();
    }

    // ACTION DISMISS
    else if (intent.getAction().equals(ACTION_DISMISS)) {
        LogHelper.v(LOG_TAG, "Service received command: DISMISS");

        // update controller - stop playback
        if (mPlayback) {
            mController.getTransportControls().stop();
        }

        // dismiss notification
        NotificationHelper.stop();
        // set media session in-active
        mSession.setActive(false);
    }

    // ACTION NEXT
    else if (intent.getAction().equals(ACTION_NEXT)) {
        LogHelper.e(LOG_TAG, "Service received command:NEXT");

        }


    // ACTION PREVIOUS
    else if (intent.getAction().equals(ACTION_PREVIOUS)) {
        LogHelper.e(LOG_TAG, "Service received command: PREVIOUS");


        }



    // listen for media button
    MediaButtonReceiver.handleIntent(mSession, intent);

    // default return value for media playback
    return START_STICKY;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:71,代码来源:PlayerService.java

示例14: onStartCommand

import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    // checking for empty intent
    if (intent == null) {
        LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
        stopForeground(true); // Remove notification
        stopSelf();
    }

    // ACTION PLAY
    else if (intent.getAction().equals(ACTION_PLAY)) {
        LogHelper.v(LOG_TAG, "Service received command: PLAY");

        // reset current station if necessary
        if (mStation != null && mStation.getPlaybackState() != PLAYBACK_STATE_STOPPED) {
            mStation.resetState();
            // send local broadcast: stopped
            Intent intentStateBuffering = new Intent();
            intentStateBuffering.setAction(ACTION_PLAYBACK_STATE_CHANGED);
            intentStateBuffering.putExtra(EXTRA_STATION, mStation);
            LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentStateBuffering);
            LogHelper.v(LOG_TAG, "LocalBroadcast: ACTION_PLAYBACK_STATE_CHANGED -> PLAYBACK_STATE_STOPPED");
        }

        // get URL of station from intent
        if (intent.hasExtra(EXTRA_STATION)) {
            mStation = intent.getParcelableExtra(EXTRA_STATION);
        }

        // update controller - start playback
        mController.getTransportControls().play();
    }

    // ACTION STOP
    else if (intent.getAction().equals(ACTION_STOP)) {
        LogHelper.v(LOG_TAG, "Service received command: STOP");

        // update controller - pause playback
        mController.getTransportControls().pause();
    }

    // ACTION DISMISS
    else if (intent.getAction().equals(ACTION_DISMISS)) {
        LogHelper.v(LOG_TAG, "Service received command: DISMISS");

        // update controller - stop playback
        if (mStation != null && mStation.getPlaybackState() != PLAYBACK_STATE_STOPPED) {
            mController.getTransportControls().stop();
        }
    }

    // listen for media button
    MediaButtonReceiver.handleIntent(mSession, intent);

    // default return value for media playback
    return START_STICKY;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:59,代码来源:PlayerService.java


注:本文中的android.support.v4.media.session.MediaButtonReceiver.handleIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。