예제 #1
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   switch (keyCode) {
     case KeyEvent.KEYCODE_VOLUME_DOWN:
     case KeyEvent.KEYCODE_VOLUME_UP:
     case KeyEvent.KEYCODE_VOLUME_MUTE:
     case KeyEvent.KEYCODE_DPAD_UP:
     case KeyEvent.KEYCODE_DPAD_DOWN:
     case KeyEvent.KEYCODE_DPAD_LEFT:
     case KeyEvent.KEYCODE_DPAD_RIGHT:
       /// M: Code analyze 010, fix bug ALPS00264030, no response for menu key @{
     case KeyEvent.KEYCODE_MENU:
       /// @}
       break;
     case KeyEvent.KEYCODE_BACK:
       if ((mSmilPlayer != null)
           && (mSmilPlayer.isPausedState()
               || mSmilPlayer.isPlayingState()
               || mSmilPlayer.isPlayedState())) {
         mSmilPlayer.stop();
       }
       break;
     default:
       if ((mSmilPlayer != null) && (mMediaController != null)) {
         mMediaController.show();
       }
   }
   return super.onKeyDown(keyCode, event);
 }
예제 #2
0
 @Override
 protected void onPause() {
   super.onPause();
   /// M: Code analyze 008, fix bug ALPS00236567, hide the mediaControl when activity paused
   /// so onTouchEvent excute show @{
   if (mMediaController != null) {
     /// M: Must do this so we don't leak a window.
     mMediaController.hide();
   }
   /// @}
   if (mSmilDoc != null) {
     ((EventTarget) mSmilDoc)
         .removeEventListener(SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, this, false);
   }
   /// M: Code analyze 002, fix bug ALPS00111374, whether need resume @{
   if ((null != mSmilPlayer)) {
     if (mSmilPlayer.isPlayingState()) {
       mSmilPlayer.pause();
       bNeedResume = true;
     } else if (mSmilPlayer.isPausedState()) {
       bNeedResume = false;
     }
   }
   /// @}
 }
예제 #3
0
 public int getCurrentPosition() {
   /// M: Code analyze 005, fix bug ALPS00071669, Handel delay problem
   /// when progress bar update @{
   if (mPlayer != null) {
     return mPlayer.getCurrentPosition();
   } else {
     return 0;
   }
   /// @}
 }
예제 #4
0
 @Override
 protected void onStop() {
   super.onStop();
   /// M: Code analyze 009, fix bug ALPS00335430, should close in lockscreen @{
   /**
    * M: when this activity is invisiable, it should exit. though it has nohistory property, lock
    * screen is an exception. so we must destory this activity in onStop.
    */
   finish();
   /// @}
   if ((null != mSmilPlayer)) {
     if (isFinishing()) {
       mSmilPlayer.stop();
       if (mSlideView != null) {
         mSlideView.clearImageView();
       }
     } else {
       mSmilPlayer.stopWhenReload();
     }
     if (mMediaController != null) {
       // Must set the seek bar change listener null, otherwise if we rotate it
       // while tapping progress bar continuously, window will leak.
       View seekBar =
           mMediaController.findViewById(com.android.internal.R.id.mediacontroller_progress);
       if (seekBar instanceof SeekBar) {
         ((SeekBar) seekBar).setOnSeekBarChangeListener(null);
       }
       // Must do this so we don't leak a window.
       mMediaController.hide();
     }
   }
   /// M: Code analyze 003, fix bug ALPS00119632, present slide return
   /// (mActivityRunning=false) when SlideshowActivity stop @{
   if (mPresenter != null) {
     mPresenter.onStop();
     mPresenter = null;
   }
   /// @}
 }
예제 #5
0
  @Override
  protected void onResume() {
    super.onResume();

    if (mMediaController != null) {
      // mMediaController.setMdragging(false);
      mMediaController.hide();
    }
    if (mSmilDoc != null) {
      ((EventTarget) mSmilDoc)
          .addEventListener(
              SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);
    }
    /// M: Code analyze 002, fix bug ALPS00111374, whether need resume @{
    if (!bNeedResume) {
      mRotate = false;
      return;
    }
    /// @}
    if (null == mSmilPlayer) {
      mSmilPlayer = SmilPlayer.getPlayer();
    }
    if (null != mSmilPlayer) {
      if (!isFinishing()) {
        if (mSmilPlayer.isPausedState()) {
          if (mRotate) {
            // if need resume the player, set the state playing.
            mSmilPlayer.setStateStart();
          } else {
            mSmilPlayer.start();
          }
        }
      }
    }
    mRotate = false;
  }
예제 #6
0
 public void start() {
   mPlayer.start();
   mCachedIsPlaying = true;
 }
예제 #7
0
 public void pause() {
   mPlayer.pause();
   mCachedIsPlaying = false;
 }
예제 #8
0
 public int getDuration() {
   return mPlayer.getDuration();
 }
예제 #9
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mHandler = new Handler();
    /// M: Code analyze 004, new feature, Slideshow Plugin(unknown) @{
    initPlugin(this);
    /// @}
    // Play slide-show in full-screen mode.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.slideshow);

    Intent intent = getIntent();
    Uri msg = intent.getData();
    final SlideshowModel model;

    try {
      model = SlideshowModel.createFromMessageUri(this, msg);
      mSlideCount = model.size();
      /** M: Confirm that we have at least 1 supported_slide to display @{ */
      if (mSlideCount == 0) {
        Toast.makeText(this, getString(R.string.unsupport_media_type), Toast.LENGTH_SHORT).show();
        throw new MmsException();
      }
      /** @} */
    } catch (MmsException e) {
      Log.e(TAG, "Cannot present the slide show.", e);
      finish();
      return;
    }
    mSlideView = (SlideView) findViewById(R.id.slide_view);

    /// M: Code analyze 003, fix bug ALPS00119632, present slide return
    /// (mActivityRunning=false) when SlideshowActivity stop @{
    mPresenter =
        (SlideshowPresenter)
            PresenterFactory.getPresenter("SlideshowPresenter", this, mSlideView, model);
    /// @}

    mRotate = true;

    /// M: Code analyze 005, fix bug ALPS00071669, Handel delay problem
    /// when progress bar update @{
    mSmilPlayer = SmilPlayer.getPlayer();
    initMediaController();
    mSlideView.setMediaController(mMediaController);
    mSlideView.setActivity(this);
    mSlideView.setMmsSlideShowPlugin(mMmsSlideShowPlugin);
    // Use SmilHelper.getDocument() to ensure rebuilding the
    /// M: entire SMIL document.
    mSmilDoc = SmilHelper.getDocument(model);
    /// @}
    mHandler.post(
        new Runnable() {
          private boolean isRotating() {
            return mSmilPlayer.isPausedState()
                || mSmilPlayer.isPlayingState()
                || mSmilPlayer.isPlayedState();
          }

          public void run() {
            if (isMMSConformance(mSmilDoc)) {
              int imageLeft = 0;
              int imageTop = 0;
              int textLeft = 0;
              int textTop = 0;
              /// M: Code analyze 006, fix bug ALPS00300308, Modified Text layout @{
              int textWidth = 0;
              int textHeight = 0;
              /// @}
              LayoutModel layout = model.getLayout();
              if (layout != null) {
                RegionModel imageRegion = layout.getImageRegion();
                if (imageRegion != null) {
                  imageLeft = imageRegion.getLeft();
                  imageTop = imageRegion.getTop();
                }
                RegionModel textRegion = layout.getTextRegion();
                if (textRegion != null) {
                  textLeft = textRegion.getLeft();
                  textTop = textRegion.getTop();
                }
              }
              /// M: Code analyze 006, fix bug ALPS00300308, Modified Text layout @{
              mSlideView.enableMMSConformanceMode(
                  textLeft, textTop, textWidth, textHeight, imageLeft, imageTop);
              /// @}
            } else {
              /// M: init page divider view
              mSlideView.initPageDivider();
            }
            if (DEBUG) {
              ByteArrayOutputStream ostream = new ByteArrayOutputStream();
              SmilXmlSerializer.serialize(mSmilDoc, ostream);
              if (LOCAL_LOGV) {
                Log.v(TAG, ostream.toString());
              }
            }

            // Add event listener.
            ((EventTarget) mSmilDoc)
                .addEventListener(
                    SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);

            mSmilPlayer.init(mSmilDoc);
            if (isRotating()) {
              mSmilPlayer.reload();
            } else {
              /// M: Code analyze 002, fix bug ALPS00111374, (CMCC feature) pause / not auto play
              /// but need prepareToPlay when enter the slideshow activity @{
              if (mMmsSlideShowPlugin.getInitialPlayState() == IMmsSlideShow.PLAY_AS_PAUSE) {
                mSmilPlayer.prepareToPlay();
                bNeedResume = true;
                mSmilPlayerController.pause();
              } else {
                mSmilPlayer.play();
                bNeedResume = true;
              }
              /// @}
            }
          }
        });
  }