private void loadView(int id) {
    setContentView(id);
    getWindow().setBackgroundDrawable(null);
    mViewRoot = findViewById(R.id.video_root);
    mVideoView = (VideoView) findViewById(R.id.video);
    mVideoView.initialize(this, this, mIsHWCodec);
    mSubtitleContainer = findViewById(R.id.subtitle_container);
    mSubtitleText = (OutlineTextView) findViewById(R.id.subtitle_text);
    mSubtitleImage = (ImageView) findViewById(R.id.subtitle_image);
    mVideoLoadingText = (TextView) findViewById(R.id.video_loading_text);
    mVideoLoadingLayout = findViewById(R.id.video_loading);
    mLoadingProgressView = mVideoLoadingLayout.findViewById(R.id.video_loading_progress);
    player_back = (ImageButton) findViewById(R.id.player_back);
    player_back.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
          }
        });
    mLoadingAnimation = AnimationUtils.loadAnimation(VideoActivity.this, R.anim.loading_rotate);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case OPEN_FILE:
              synchronized (mOpenLock) {
                if (!mOpened.get() && vPlayer != null) {
                  mOpened.set(true);
                  vPlayer.setVPlayerListener(vPlayerListener);
                  if (vPlayer.isInitialized()) mUri = vPlayer.getUri();

                  if (mVideoView != null) vPlayer.setDisplay(mVideoView.getHolder());
                  if (mUri != null)
                    vPlayer.initialize(
                        mUri,
                        mDisplayName,
                        mSaveUri,
                        getStartPosition(),
                        vPlayerListener,
                        mParentId,
                        mIsHWCodec);
                }
              }
              break;
            case OPEN_START:
              mVideoLoadingText.setText(R.string.video_layout_loading);
              setVideoLoadingLayoutVisibility(View.VISIBLE);
              break;
            case OPEN_SUCCESS:
              loadVPlayerPrefs();
              setVideoLoadingLayoutVisibility(View.GONE);
              setVideoLayout();
              vPlayer.start();
              attachMediaController();
              break;
            case OPEN_FAILED:
              resultFinish(RESULT_FAILED);
              break;
            case BUFFER_START:
              setVideoLoadingLayoutVisibility(View.VISIBLE);
              vPlayerHandler.sendEmptyMessageDelayed(BUFFER_PROGRESS, 1000);
              break;
            case BUFFER_PROGRESS:
              if (vPlayer.getBufferProgress() >= 100) {
                setVideoLoadingLayoutVisibility(View.GONE);
              } else {
                mVideoLoadingText.setText(
                    getString(
                        R.string.video_layout_buffering_progress, vPlayer.getBufferProgress()));
                vPlayerHandler.sendEmptyMessageDelayed(BUFFER_PROGRESS, 1000);
                stopPlayer();
              }
              break;
            case BUFFER_COMPLETE:
              setVideoLoadingLayoutVisibility(View.GONE);
              vPlayerHandler.removeMessages(BUFFER_PROGRESS);
              break;
            case CLOSE_START:
              mVideoLoadingText.setText(R.string.closing_file);
              setVideoLoadingLayoutVisibility(View.VISIBLE);
              break;
            case CLOSE_COMPLETE:
              mCloseComplete = true;
              break;
            case HW_FAILED:
              if (mVideoView != null) {
                mVideoView.setVisibility(View.GONE);
                mVideoView.setVisibility(View.VISIBLE);
                mVideoView.initialize(VideoActivity.this, VideoActivity.this, false);
              }
              break;
            case LOAD_PREFS:
              loadVPlayerPrefs();
              break;
          }
        }