public boolean playFileForMute(String path, MediaEventsHandler parent) {
    if (null != mMediaPlayer && mMediaPlayer.isPlaying()) {
      return false;
    }
    this.mParent = parent;
    try {
      mMediaPlayer = new MediaPlayer();
      FileInputStream fin = new FileInputStream(path);
      mMediaPlayer.setDataSource(fin.getFD());
      mMediaPlayer.prepare();
      mMediaPlayer.setOnCompletionListener(this);
      mMediaPlayer.setOnErrorListener(this);
      mMediaPlayer.setOnInfoListener(this);
      mMediaPlayer.start();

    } catch (IOException e) {

      return false;
    } catch (Exception e) {
      System.out.println("########################EXCEPTION HANDLED#############################");
      e.printStackTrace();

      return false;
    }
    return true;
  }
Exemplo n.º 2
0
  @Override
  public void onCreate() {

    feedBackIntent = new Intent(BROADCAST_FEEDBACK);
    seekIntent = new Intent(BROADCAST_SEEK);

    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mediaPlayer.setOnCompletionListener(this);
    mediaPlayer.setOnErrorListener(this);
    mediaPlayer.setOnBufferingUpdateListener(this);
    mediaPlayer.setOnInfoListener(this);
    mediaPlayer.setOnSeekCompleteListener(this);
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.reset();

    DropboxConnect dropConnect = new DropboxConnect(getApplicationContext());
    dropboxApi = dropConnect.getDropboxAPI();

    nowplayingData = SongSQLite.getmInstance(getApplicationContext());
    playingSongList = nowplayingData.getAllSong(SongSQLite.TABLE_NOWPLAYING, null);
    intCurrentSong = 0;

    if (playingSongList == null) playingSongList = new ArrayList<>(); // If Database is Emply

    intTotalSong = playingSongList.size();
    updateCurrentSong();

    initNotification();
    Log.d(">>>> THAI <<<<", "onCreat() Service");
  }
  private void initMediaPlayer() {

    mediaPlayer = new MediaPlayer();

    mediaPlayer.setAudioStreamType(STREAM_TYPE);
    mediaPlayer.setVolume(1f, 1f);

    mediaPlayer.setOnErrorListener(
        new OnErrorListener() {
          @Override
          public boolean onError(MediaPlayer mp, int what, int extra) {
            Log.e(TAG, "MediaPlayer.onErrorListener (What: " + what + ", Extra: " + extra + ")");
            // mp.reset();
            if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
              mp.release();
              initMediaPlayer();
            }
            return true;
          }
        });

    mediaPlayer.setOnInfoListener(
        new OnInfoListener() {
          @Override
          public boolean onInfo(MediaPlayer mp, int what, int extra) {
            Log.e(TAG, "MediaPlayer.onInfoListener (What: " + what + ", Extra: " + extra + ")");
            return false;
          }
        });
  }
  public void openVideo(Uri uri) {
    if (uri == null || mSurfaceHolder == null || getContext() == null) {
      // not ready for playback just yet, will try again later
      if (mSurfaceHolder == null && uri != null) {
        mUri = uri;
      }
      return;
    }

    mUri = uri;
    mDuration = 0;

    // Idle 状态:当使用new()方法创建一个MediaPlayer对象或者调用了其reset()方法时,该MediaPlayer对象处于idle状态。
    // End 状态:通过release()方法可以进入End状态,只要MediaPlayer对象不再被使用,就应当尽快将其通过release()方法释放掉
    // Initialized 状态:这个状态比较简单,MediaPlayer调用setDataSource()方法就进入Initialized状态,表示此时要播放的文件已经设置好了。
    // Prepared
    // 状态:初始化完成之后还需要通过调用prepare()或prepareAsync()方法,这两个方法一个是同步的一个是异步的,只有进入Prepared状态,才表明MediaPlayer到目前为止都没有错误,可以进行文件播放。

    Exception exception = null;
    try {
      if (mMediaPlayer == null) {
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setOnPreparedListener(mPreparedListener);
        mMediaPlayer.setOnCompletionListener(mCompletionListener);
        mMediaPlayer.setOnErrorListener(mErrorListener);
        mMediaPlayer.setOnVideoSizeChangedListener(mVideoSizeChangedListener);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setOnSeekCompleteListener(mSeekCompleteListener);
        mMediaPlayer.setOnInfoListener(mInfoListener);
        //			mMediaPlayer.setScreenOnWhilePlaying(true);
        //				mMediaPlayer.setVolume(mSystemVolumn, mSystemVolumn);
        mMediaPlayer.setDisplay(mSurfaceHolder);
      } else {
        mMediaPlayer.reset();
      }
      mMediaPlayer.setDataSource(getContext(), uri);

      //			if (mLooping)
      //				mMediaPlayer.setLooping(true);//循环播放
      mMediaPlayer.prepareAsync();
      // we don't set the target state here either, but preserve the
      // target state that was there before.
      mCurrentState = STATE_PREPARING;
    } catch (IOException ex) {
      exception = ex;
    } catch (IllegalArgumentException ex) {
      exception = ex;
    } catch (Exception ex) {
      exception = ex;
    }
    if (exception != null) {
      Logger.e(exception);
      mCurrentState = STATE_ERROR;
      if (mErrorListener != null)
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
    }
  }
Exemplo n.º 5
0
 private void initPlayer() {
   mPlayer = new MediaPlayer();
   mPlayer.setAudioSessionId(mPlayer.getAudioSessionId());
   mPlayer.setOnErrorListener(this);
   mPlayer.setOnInfoListener(this);
   mPlayer.setOnPreparedListener(this);
   mPlayer.setOnBufferingUpdateListener(this);
   mPlayer.setOnSeekCompleteListener(this);
   mPlayer.setOnCompletionListener(this);
 }
Exemplo n.º 6
0
 private void initplayer() {
   if (player == null) {
     player = new MediaPlayer();
     player.setOnPreparedListener(MediaPlayerListener);
     player.setOnVideoSizeChangedListener(MediaPlayerListener);
     player.setOnSeekCompleteListener(MediaPlayerListener);
     player.setOnInfoListener(MediaPlayerListener);
     player.setOnCompletionListener(MediaPlayerListener);
     player.setOnErrorListener(MediaPlayerListener);
     player.setOnBufferingUpdateListener(MediaPlayerListener);
   }
 }
Exemplo n.º 7
0
  private void openVideo() {
    if (mUri == null || mSurfaceHolder == null) {
      // not ready for playback just yet, will try again later
      return;
    }
    // Tell the music playback service to pause
    // TODO: these constants need to be published somewhere in the framework.
    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    mContext.sendBroadcast(i);

    // we shouldn't clear the target state, because somebody might have
    // called start() previously
    release(false);
    try {
      mMediaPlayer = new MediaPlayer();
      if (mAudioSession != 0) {
        mMediaPlayer.setAudioSessionId(mAudioSession);
      } else {
        mAudioSession = mMediaPlayer.getAudioSessionId();
      }
      mMediaPlayer.setOnPreparedListener(mPreparedListener);
      mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
      mMediaPlayer.setOnCompletionListener(mCompletionListener);
      mMediaPlayer.setOnErrorListener(mErrorListener);
      mMediaPlayer.setOnInfoListener(mOnInfoListener);
      mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
      mCurrentBufferPercentage = 0;
      mMediaPlayer.setDataSource(mContext, mUri, mHeaders);
      mMediaPlayer.setDisplay(mSurfaceHolder);
      mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      mMediaPlayer.setScreenOnWhilePlaying(true);
      mMediaPlayer.prepareAsync();
      // we don't set the target state here either, but preserve the
      // target state that was there before.
      mCurrentState = STATE_PREPARING;
      attachMediaController();
    } catch (IOException ex) {
      Log.w(TAG, "Unable to open content: " + mUri, ex);
      mCurrentState = STATE_ERROR;
      mTargetState = STATE_ERROR;
      mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
      return;
    } catch (IllegalArgumentException ex) {
      Log.w(TAG, "Unable to open content: " + mUri, ex);
      mCurrentState = STATE_ERROR;
      mTargetState = STATE_ERROR;
      mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
      return;
    }
  }
Exemplo n.º 8
0
  protected void initialize() throws IOException {
    try {
      mp = new MediaPlayer();
      String url = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_URL));
      if (URLUtil.isAssetUrl(url)) {
        Context context = proxy.getTiContext().getTiApp();
        String path = url.substring(TiConvert.ASSET_URL.length());
        AssetFileDescriptor afd = null;
        try {
          afd = context.getAssets().openFd(path);
          // Why mp.setDataSource(afd) doesn't work is a problem for another day.
          // http://groups.google.com/group/android-developers/browse_thread/thread/225c4c150be92416
          mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
        } catch (IOException e) {
          Log.e(LCAT, "Error setting file descriptor: ", e);
        } finally {
          if (afd != null) {
            afd.close();
          }
        }
      } else {
        Uri uri = Uri.parse(url);
        if (uri.getScheme().equals(TiC.PROPERTY_FILE)) {
          mp.setDataSource(uri.getPath());
        } else {
          remote = true;
          mp.setDataSource(url);
        }
      }

      mp.setLooping(looping);
      mp.setOnCompletionListener(this);
      mp.setOnErrorListener(this);
      mp.setOnInfoListener(this);
      mp.setOnBufferingUpdateListener(this);

      mp.prepare(); // Probably need to allow for Async
      setState(STATE_INITIALIZED);

      setVolume(volume);
      if (proxy.hasProperty(TiC.PROPERTY_TIME)) {
        setTime(TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_TIME)));
      }
    } catch (Throwable t) {
      Log.w(LCAT, "Issue while initializing : ", t);
      release();
      setState(STATE_STOPPED);
    }
  }
Exemplo n.º 9
0
  @Override
  protected void onResume() {
    super.onResume();
    Log.d(TAG, "onResume");

    mIndex = 0; // 再開時ソートの頭から表示
    mItems = Item.getItems(getApplicationContext());

    if (mItems.size() != 0) {
      mMediaPlayer = new MediaPlayer();
      mMediaPlayer.setOnPreparedListener(this);
      mMediaPlayer.setOnInfoListener(this);
      mMediaPlayer.setOnCompletionListener(this);
      prepare();
    }
  }
Exemplo n.º 10
0
  public void release() {
    try {
      if (mp != null) {

        mp.setOnCompletionListener(null);
        mp.setOnErrorListener(null);
        mp.setOnBufferingUpdateListener(null);
        mp.setOnInfoListener(null);

        mp.release();
        mp = null;
        if (DBG) {
          Log.d(LCAT, "Native resources released.");
        }
        remote = false;
      }
    } catch (Throwable t) {
      Log.w(LCAT, "Issue while releasing : ", t);
    }
  }
  private void createPlayer(SurfaceHolder holder) {
    if (mMediaPlayer != null) {
      destroyPlayer(holder);
    }

    mMediaPlayer = new MediaPlayer();
    mHolder = holder;

    mVideoWidth = 0;
    mVideoHeight = 0;
    mVideoDurationSeconds = 0;

    try {
      mMediaPlayer.setDisplay(mHolder);
      mMediaPlayer.setDataSource(mUrl);

      mMediaPlayer.setScreenOnWhilePlaying(true);

      mMediaPlayer.setOnPreparedListener(this);
      mMediaPlayer.setOnVideoSizeChangedListener(this);
      mMediaPlayer.setOnCompletionListener(this);
      mMediaPlayer.setOnErrorListener(this);
      mMediaPlayer.setOnInfoListener(this);
      mMediaPlayer.setOnBufferingUpdateListener(this);
      mMediaPlayer.setOnSeekCompleteListener(this);

      mMediaPlayer.prepareAsync();
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SecurityException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalStateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemplo n.º 12
0
  private void initPlayer() {
    Logger.LOGD(TAG, "begint to new InitPlayer");
    if (mPlayer != null) {
      mPlayer.release();
      mSurfaceView.setVisibility(View.INVISIBLE);
    }

    mPlayer = new MediaPlayer();
    mSurfaceView.setVisibility(View.VISIBLE);
    //		if (mHolder != null)
    //			mPlayer.setDisplay(mHolder);
    mPlayer.setOnPreparedListener(mPrepareListener);
    mPlayer.setOnCompletionListener(mCompleteListener);
    mPlayer.setOnErrorListener(mErrorListener);
    mPlayer.setOnInfoListener(mInfoListener);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mPlayer.reset();

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  }
Exemplo n.º 13
0
 @Override
 public void onPrepared(MediaPlayer mediaPlayer) {
   mediaPlayer.setOnInfoListener(
       new MediaPlayer.OnInfoListener() {
         @Override
         public boolean onInfo(MediaPlayer mp, int what, int extra) {
           /*
            * add what == MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING
            * fix : return what == 700 in Lenovo low configuration Android System
            */
           if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START
               || what == MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING) {
             mProgressBarView.setVisibility(View.GONE);
             setCloseButton(true);
             initDLNAInfo();
             return true;
           }
           return false;
         }
       });
 }
  public boolean playFile(String path, MediaEventsHandler parent, boolean isUrl) {
    this.mParent = parent;
    if (null != mMediaPlayer && mMediaPlayer.isPlaying()) {
      parent.mediaEvent((byte) 123);
    }
    if (null != mMediaPlayer && mMediaPlayer.isPlaying()) {
      return false;
    }
    try {
      mMediaPlayer = new MediaPlayer();
      if (!isUrl) {
        FileInputStream fin = new FileInputStream(path);
        mMediaPlayer.setDataSource(fin.getFD());
      } else {
        mMediaPlayer.setDataSource(path);
      }
      mMediaPlayer.prepare();
      mMediaPlayer.setOnCompletionListener(this);
      mMediaPlayer.setOnErrorListener(this);
      mMediaPlayer.setOnInfoListener(this);
      // System.out.println("isplaying====================false"
      // +"mMediaPlayer.isPlaying==="+mMediaPlayer.isPlaying() +
      // "currentstate==="+BusinessProxy.sSelf.mUIActivityManager.getCurrentState());
      // RocketalkApplication.am.setMode(AudioManager.STREAM_MUSIC);
      // mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC) ;
      mMediaPlayer.start();
    } catch (IOException e) {
      e.printStackTrace();

      return false;
    } catch (Exception ex) {
      ex.printStackTrace();

      return false;
    }
    return true;
  }
Exemplo n.º 15
0
  // 创建播放器
  private void initPlayer() {
    reset();
    // 创建播放器
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

    mMediaPlayer.setOnPreparedListener(
        new OnPreparedListener() {

          @Override
          public void onPrepared(MediaPlayer mp) {
            // mp.start();
            try {
              if (onPreparedListener != null) {
                onPreparedListener.onPrepared(mp);
              }
            } catch (IllegalStateException e) {
              LogManager.printStackTrace(e);
            } catch (Exception e) {
              LogManager.printStackTrace(e);
            }
          }
        });

    mMediaPlayer.setOnCompletionListener(
        new OnCompletionListener() {

          @Override
          public void onCompletion(MediaPlayer mp) {
            try {
              if (onCompletionListener != null) {
                LogManager.i(TAG, "OnCompletionListener  ----play completion");
                onCompletionListener.onCompletion(mp);
              }
            } catch (IllegalArgumentException e) {
              LogManager.printStackTrace(e, "MediaPlayerService", "onCompletion");
            } catch (IllegalStateException e) {
              LogManager.printStackTrace(e, "MediaPlayerService", "onCompletion");
            } catch (Exception e) {
              LogManager.printStackTrace(e);
            }
          }
        });

    mMediaPlayer.setOnErrorListener(
        new OnErrorListener() {

          @Override
          public boolean onError(MediaPlayer mp, int what, int extra) {

            LogManager.e(TAG, " on Error " + what + "  " + extra);
            // 无法复用播放器
            hasReady = false;
            try {
              if (onErrorListener != null) {
                return onErrorListener.onError(mp, what, extra);
              }
            } catch (IllegalStateException e) {
              LogManager.printStackTrace(e);
            } catch (Exception e) {
              LogManager.printStackTrace(e);
            }
            return true;
          }
        });

    mMediaPlayer.setOnInfoListener(
        new OnInfoListener() {

          @Override
          public boolean onInfo(MediaPlayer mp, int what, int extra) {
            LogManager.d(TAG, "what:" + what + ",extra:" + extra);
            switch (what) {
              case 702: // buffer结束缓冲 -> 音乐恢复播放
                isBufferingCauseStop = false;
                break;
              case 703: // buffer不足造成 -> 音乐暂停播放
                isBufferingCauseStop = true;
                break;
              case 701: // buffer开始缓冲 -> buffer不足时发生
                break;
              default:
            }
            return false;
          }
        });

    mMediaPlayer.setOnBufferingUpdateListener(
        new OnBufferingUpdateListener() {

          @Override
          public void onBufferingUpdate(MediaPlayer mp, int newBufferPercentage) {

            if (mBaseContext.getPrefBoolean(KeyList.PKEY_CUREENT_MUSIC_IS_DLAN, false)) {
              return;
            }

            bufferPercentage = newBufferPercentage;
            /** 暂时未查到 -2147483648 是什么状态,但此状态下歌曲是在缓冲的 */
            LogManager.i(TAG, " buffer percent:" + newBufferPercentage + "%");

            if (bufferPercentage != -2147483648 && bufferPercentage < 0 || isBufferingCauseStop) {
              long now = System.currentTimeMillis();
              if (bufferingLowStart == 0) {
                bufferingLowStart = now;
                LogManager.d(TAG, "缓冲发生不足");
              } else {
                long s = now - bufferingLowStart;
                LogManager.d(TAG, "缓冲持续不足:" + s + "ms");
                if (s >= bufferingLowOverdue) { // 超过缓冲超时时间了
                  LogManager.d("缓冲不足超时");
                  bufferingLowStart = 0;
                  // 暂停
                  if (onBufferingOverdueListener != null) {
                    onBufferingOverdueListener.onBufferingUpdate(mp, s);
                  }
                }
              }

            } else {
              bufferingLowStart = 0;
              LogManager.d(TAG, "mediaPlayer buffer percent:" + newBufferPercentage + "%");
              // 当剩余时间不足时,开始预加载下一首歌曲,且仅预加载一次
            }
          }
        });
  }
Exemplo n.º 16
0
  private void openVideo() {
    if ((mFd == null && mUri == null) || mSurfaceHolder == null) {
      // not ready for playback just yet, will try again later
      return;
    }
    // Tell the music playback service to pause
    // TODO: these constants need to be published somewhere in the framework.
    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    mContext.sendBroadcast(i);

    // we shouldn't clear the target state, because somebody might have
    // called start() previously
    release(false);
    try {
      mMediaPlayer = new MediaPlayer();
      // TODO: create SubtitleController in MediaPlayer, but we need
      // a context for the subtitle renderers
      final Context context = getContext();
      // final SubtitleController controller = new SubtitleController(context,
      // mMediaPlayer.getMediaTimeProvider(), mMediaPlayer);
      // controller.registerRenderer(new WebVttRenderer(context));
      // mMediaPlayer.setSubtitleAnchor(controller, this);

      if (mAudioSession != 0) {
        mMediaPlayer.setAudioSessionId(mAudioSession);
      } else {
        mAudioSession = mMediaPlayer.getAudioSessionId();
      }
      mMediaPlayer.setOnPreparedListener(mPreparedListener);
      mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
      mMediaPlayer.setOnCompletionListener(mCompletionListener);
      mMediaPlayer.setOnErrorListener(mErrorListener);
      mMediaPlayer.setOnInfoListener(mInfoListener);
      mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
      mCurrentBufferPercentage = 0;

      if (mUri != null) {
        mMediaPlayer.setDataSource(mContext, mUri, mHeaders);
      } else {
        mMediaPlayer.setDataSource(mFd);
      }

      mMediaPlayer.setDisplay(mSurfaceHolder);
      mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      mMediaPlayer.setScreenOnWhilePlaying(true);
      mMediaPlayer.prepareAsync();

      /*   for (Pair<InputStream, MediaFormat> pending: mPendingSubtitleTracks) {
          try {
              mMediaPlayer.addSubtitleSource(pending.first, pending.second);
          } catch (IllegalStateException e) {
              mInfoListener.onInfo(
                      mMediaPlayer, MediaPlayer.MEDIA_INFO_UNSUPPORTED_SUBTITLE, 0);
          }
      }*/

      // we don't set the target state here either, but preserve the
      // target state that was there before.
      mCurrentState = STATE_PREPARING;
      attachMediaController();
    } catch (IOException ex) {
      Log.w(TAG, "Unable to open content: ", ex);
      mCurrentState = STATE_ERROR;
      mTargetState = STATE_ERROR;
      mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
      return;
    } catch (IllegalArgumentException ex) {
      Log.w(TAG, "Unable to open content: ", ex);
      mCurrentState = STATE_ERROR;
      mTargetState = STATE_ERROR;
      mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
      return;
    } finally {
      mPendingSubtitleTracks.clear();
    }
  }
Exemplo n.º 17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    // Remove notification bar
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // set content view AFTER ABOVE sequence (to avoid crash)
    setContentView(R.layout.player);

    decorView = getWindow().getDecorView();
    uiOption = getWindow().getDecorView().getSystemUiVisibility();

    surfaceView = (SurfaceView) this.findViewById(R.id.SurfaceView);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);

    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnCompletionListener(this);
    mediaPlayer.setOnErrorListener(this);
    mediaPlayer.setOnInfoListener(this);
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setOnSeekCompleteListener(this);
    mediaPlayer.setOnVideoSizeChangedListener(this);

    mMenuBar = (RelativeLayout) findViewById(R.id.menuBar);
    mMenuButton = (ImageView) findViewById(R.id.menuButton);
    mVideoList = (LinearLayout) findViewById(R.id.videoList);
    mTitle = (TextView) findViewById(R.id.MovieTitle);
    mMenuButton.setOnClickListener(this);
    mVideoList.setOnClickListener(this);

    /*
     * String filePath = Environment.getExternalStorageDirectory().getPath()
     * + "/Movies/Spanglish_H264_AAC_800x432.mp4";
     */

    // POINT: sdcard 의 동영상 파일 목록을 구하기
    String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    File sdRoot = new File(sdPath);
    FileList(sdRoot);

    for (int i = 0; i < mFileList.size(); i++) {
      if ((mFileList.get(i).endsWith(".mp4")) || (mFileList.get(i).endsWith(".mkv"))) {
        Log.e("TAT", mFileList.get(i));
        mVideoFileList.add(mFileList.get(i));
      }
    }

    if (mVideoFileList.isEmpty()) {
      Toast.makeText(this, "재생할 파일이 없습니다.", 1).show();
    }

    for (int i = 0; i < mVideoFileList.size(); i++) {
      final String path = mVideoFileList.get(i);
      final String filename = path.substring(path.lastIndexOf("/") + 1);
      final TextView text = new TextView(this);
      text.setContentDescription(i + "");
      text.setSingleLine();
      text.setPadding(
          text.getPaddingLeft() + 10,
          text.getPaddingTop() + 10,
          text.getPaddingRight(),
          text.getPaddingBottom());
      text.setHeight(80);
      text.setText(filename);
      text.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              try {
                if (mediaPlayer.isPlaying()) mediaPlayer.stop();
                mediaPlayer.reset();
                mediaPlayer.setDataSource(path);
                mediaPlayer.prepare();
                idx = Integer.parseInt(text.getContentDescription().toString());
                mTitle.setText("[ " + filename + " ]");
              } catch (IllegalArgumentException e) {
                Log.v(LOGTAG, e.getMessage());
                finish();
              } catch (IllegalStateException e) {
                Log.v(LOGTAG, e.getMessage());
                finish();
              } catch (SecurityException e) {
                e.printStackTrace();
              } catch (IOException e) {
                e.printStackTrace();
              }
            }
          });
      mVideoList.addView(text);
    }

    /* TODO : intend를 통해 클릭한 동영상 path 넘겨주기 */
    // Intent intent = getIntent();
    // mmList = intent.getStringArrayListExtra("vList");

    String filePath = mVideoFileList.get(0);

    try {
      mediaPlayer.setDataSource(filePath);
      String filename = filePath.substring(filePath.lastIndexOf("/") + 1);
      mTitle.setText("[ " + filename + " ]");
    } catch (IllegalArgumentException e) {
      Log.v(LOGTAG, e.getMessage());
      finish();
    } catch (IllegalStateException e) {
      Log.v(LOGTAG, e.getMessage());
      finish();
    } catch (IOException e) {
      Log.v(LOGTAG, e.getMessage());
      finish();
    }

    controller =
        new MediaController(this) {
          @Override
          public void show() {
            super.show(0);
            mMenuBar.setVisibility(View.VISIBLE);
          }

          @Override
          public void hide() {
            super.hide();
            mMenuBar.setVisibility(View.INVISIBLE);
            ((ScrollView) mVideoList.getParent()).setVisibility(View.INVISIBLE);
          }
        };
    currentDisplay = getWindowManager().getDefaultDisplay();

    //
    // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    // uiOption |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
  }