/// <summary> /// Callback for response to seek() device method. /// </summary> public override void onSeek(SmcAvPlayer device, long requestedPosition, int err) { if (err != Smc.SUCCESS) { // Error has occurred. return; } // Action successful, no further processing needed. }
/// <summary> /// Callback when AllShare device state changes /// </summary> public override void onDeviceChanged(SmcAvPlayer device, int state, int err) { Log.d("MusicPlayer", "onDeviceChanged: " + state); if (err != Smc.SUCCESS) { // Error has occurred, switch to local player. mController.setLocalPlayer(); return; } // We use simplified state set, so map from states used in service // to states used locally. switch (state) { case SmcAvPlayer.STATE_PAUSED: State = PlayerState.PAUSED; break; case SmcAvPlayer.STATE_PLAYING: State = PlayerState.PLAYING; if (mFirstPlay) { mPlayer.seek(mPosition); mFirstPlay = false; } mPosition = 0; break; case SmcAvPlayer.STATE_BUFFERING: State = PlayerState.BUFFERING; break; case SmcAvPlayer.STATE_STOPPED: if (mCurrentState == PlayerState.INITIALIZING) { playItem(); } else { State = PlayerState.STOPPED; } break; case SmcAvPlayer.STATE_CONTENT_CHANGED: //mController.setLocalPlayer(); //TODO break; default: State = PlayerState.STOPPED; break; } }
/// <summary> /// Callback for response to pause() device method. /// </summary> public override void onPause(SmcAvPlayer device, int err) { if (err != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of state change. State = PlayerState.PAUSED; }
/// <summary> /// Callback for response to play() device method. /// </summary> public override void onPlay(SmcAvPlayer device, SmcItem item, SmcAvPlayer.PlayInfo contentInfo, int error) { if (error != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of state change. State = PlayerState.PLAYING; }
/// <summary> /// Callback for response to resume() device method. /// </summary> public override void onResume(SmcAvPlayer device, int error) { if (error != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of state change State = PlayerState.PLAYING; }
/// <summary> /// Callback for response to hide() device method. /// </summary> public override void onStop(SmcAvPlayer device, int error) { if (error != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of state change mController.notifyCurrentPosition(0); State = PlayerState.STOPPED; mPosition = 0; }
/// <summary> /// Callback for response to requestPlayPosition() device method. /// </summary> public override void onRequestPlayPosition(SmcAvPlayer device, long position, int err) { if (err != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of current position. if (position != 0) { mController.notifyCurrentPosition((int)position); } if (Math.Abs(position - mPosition) < 2 && mCurrentState == PlayerState.BUFFERING) { State = PlayerState.PLAYING; } }
///////////////////////////////////////////////////////////////////////////////// // SmcDeviceFinder.StatusListener implementation ///////////////////////////////////////////////////////////////////////////////// public override void onStarted(SmcDeviceFinder deviceFinder, int error) { mDeviceFinder = deviceFinder; mPlayer = (SmcAvPlayer)mDeviceFinder.getDevice(mDeviceType, mDeviceId); if (mPlayer == null) { mController.setLocalPlayer(); return; } if (mController.CurrentState != PlayerState.STOPPED) { registerListeners(); } mPlayer.requestVolumeInfo(); mPlayer.requestStateInfo(); mPlayer.requestMuteInfo(); }
public override void onRequestVolumeInfo(SmcAvPlayer device, int i, int error) { mController.notifyCurrentVolume(i); }
/// <summary> /// Callback for response to requestPlayPosition() device method. /// </summary> public override void onRequestPlayPosition(SmcAvPlayer device, long position, int err) { if (err != Smc.SUCCESS) { // Error has occurred. return; } // Notify controller of current position. if (position != 0) { mController.notifyCurrentPosition((int) position); } if (Math.Abs(position - mPosition) < 2 && mCurrentState == PlayerState.BUFFERING) { State = PlayerState.PLAYING; } }
public override void onRequestMediaInfo(SmcAvPlayer device, SmcAvPlayer.MediaInfo mediaInfo, int err) { // Not used in this sample. }
public override void onRequestStateInfo(SmcAvPlayer device, int state, int err) { onDeviceChanged(device, state, err); }
public override void onSetMute(SmcAvPlayer device, bool onOff, int error) { }
/// <summary> /// Callback for AllShare device state changes. /// </summary> public override void onDeviceChanged(SmcAvPlayer device, int state, int error) { Log.d("VideoPlayer", "onDeviceChanged: " + state); if (error != Smc.SUCCESS) { // Error has occurred, switch to local player. mController.setLocalPlayer(); return; } // We use simplified state set, so map from states used in service // to states used locally. switch (state) { case SmcAvPlayer.STATE_PAUSED: State = PlayerState.PAUSED; break; case SmcAvPlayer.STATE_PLAYING: State = PlayerState.PLAYING; if (mFirstPlay) { mPlayer.seek(mPosition); mFirstPlay = false; } mPosition = 0; break; case SmcAvPlayer.STATE_BUFFERING: State = PlayerState.BUFFERING; break; case SmcAvPlayer.STATE_STOPPED: if (mCurrentState == PlayerState.INITIALIZING) { playItem(); } else { State = PlayerState.STOPPED; } break; case SmcAvPlayer.STATE_CONTENT_CHANGED: //mController.setLocalPlayer(); break; default: State = PlayerState.STOPPED; break; } }
public override void onSetVolume(SmcAvPlayer device, int level, int error) { }
public override void onRequestMuteInfo(SmcAvPlayer device, bool b, int error) { }
///////////////////////////////////////////////////////////////////////////////// // SmcDeviceFinder.StatusListener implementation ///////////////////////////////////////////////////////////////////////////////// public override void onStarted(SmcDeviceFinder deviceFinder, int error) { mDeviceFinder = deviceFinder; mPlayer = (SmcAvPlayer) mDeviceFinder.getDevice(mDeviceType, mDeviceId); if (mPlayer == null) { mController.setLocalPlayer(); return; } if (mController.CurrentState != PlayerState.STOPPED) { registerListeners(); } mPlayer.requestVolumeInfo(); mPlayer.requestStateInfo(); mPlayer.requestMuteInfo(); }