コード例 #1
0
  public MjpegView setView(MjpegView view) {
    // releasing old view first
    MjpegView oldView = mView;

    if (oldView != null) {
      Log.i(TAG, "Unassign old view: " + oldView);
      // oldView.pausePlayback();	// TODO: print info when stop playback (change in MjpegView)
      mView = null;
      // pause data receiving (destroy all incoming pkts)
      try {
        mReceiver.setReceive(false);
      } catch (IOException e) {
        Log.e(TAG, e.getMessage());
      }
    }

    // assign new view
    mView = view;
    // start playback if the assigned view is not null
    if (mView != null) {
      Log.i(TAG, "Get view: " + mView);
      released = false;
      // create MJPEG input stream
      MjpegDataInput mjpegDataInput = new MjpegDataInput(mReceiver);

      // set source
      mView.setSource(mjpegDataInput);
      mView.setOnErrorListener(this);
      // resume data receiving (baPkt->Socket stream->MjpegInputStream->MJpegView)

      // settings
      view.showFps(true);
      view.setDisplayMode(MjpegView.SIZE_FULLSCREEN);

      // start playback
      view.startPlayback();
      try {
        mReceiver.setReceive(true);
      } catch (IOException e) {
        Log.e(TAG, e.getMessage());
      }
      Log.i(TAG, "startPlayback()");
    }

    return oldView;
  }
コード例 #2
0
 @Override
 public void onError() {
   mStreamFinishedListener.streamFinished(mReceiver.getRid());
   Log.i(TAG, "VideoPlayer released!");
 }
コード例 #3
0
 public void release() {
   if (!released) {
     released = true;
     mReceiver.release();
   }
 }