'mediaplayer'에 해당되는 글 1건

  1. 2009.05.12 Media(A/V) Playback 4
Android/App개발2009. 5. 12. 18:30
MediaPlayerDemo_Video.java 참조

           switch (Media) {
                case LOCAL_VIDEO:
                    /*
                     * TODO: Set the path variable to a local media file path.
                     */
                    //path = "sdcard/[PV] YUI - SUMMER SONG.avi"; // failed
                    //path = "sdcard/2008-01-11 02_01_00.3gp"; // ok
                    //path = "sdcard/FighterPilot_H264_720_480_30fps_4.1Mbps_AAC256Q100.mp4"; // fail
                    //path = "sdcard/leekunho_goal6.mp4"; // ok : frame skip
                    //path = "sdcard/Qpang.avi"; // fail
                    path = "sdcard/[M35_700]sample.avi"; // fail
                    if (path == "") {
                        // Tell the user to provide a media file URL.
                        Toast
                                .makeText(
                                        MediaPlayerDemo_Video.this,
                                        "Please edit MediaPlayerDemo_Video Activity, "
                                                + "and set the path variable to your media file path."
                                                + " Your media file must be stored on sdcard.",
                                        Toast.LENGTH_LONG).show();

                    }
                    break;
                case STREAM_VIDEO:

                    /*
                     * TODO: Set path variable to progressive streamable mp4 or
                     * 3gpp format URL. Http protocol should be used.
                     * Mediaplayer can only play "progressive streamable
                     * contents" which basically means: 1. the movie atom has to
                     * precede all the media data atoms. 2. The clip has to be
                     * reasonably interleaved.
                     *
                     */
                    path = "";
                    if (path == "") {
                        // Tell the user to provide a media file URL.
                        Toast
                                .makeText(
                                        MediaPlayerDemo_Video.this,
                                        "Please edit MediaPlayerDemo_Video Activity,"
                                                + " and set the path variable to your media file URL.",
                                        Toast.LENGTH_LONG).show();

                    }

                    break;


            }

            // Create a new media player and set the listeners
            mMediaPlayer = new MediaPlayer();
            mMediaPlayer.setDataSource(path);
            mMediaPlayer.setDisplay(holder);
            mMediaPlayer.prepare();
            mMediaPlayer.setOnBufferingUpdateListener(this);
            mMediaPlayer.setOnCompletionListener(this);
            mMediaPlayer.setOnPreparedListener(this);
            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

MediaPlayer
  -> setDataSource(path)  : URI로 content의 path가 전달 -> MediaPlayer service로부터 해당 path로 IMediaPlayer생성 -> 생성된 IMediaPlayer내부에 유지
  -> prepare()
      -> prepareAsync_I()
          -> setAudioStreamType() : 생성된 IMediaPlayer의 setAudioStreamType()임
                  in IMediaPlayer.cpp
 status_t setAudioStreamType(int type)
{
        Parcel data, reply;
        data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
        data.writeInt32(type);
        remote()->transact(SET_AUDIO_STREAM_TYPE, data, &reply);
        return reply.readInt32();
}
          -> prepareAsync() : 생성된 IMediaPlayer의 prepareAsync()임.
                  in IMediaPlayer.cpp
    status_t prepareAsync()
    {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
        remote()->transact(PREPARE_ASYNC, data, &reply);
        return reply.readInt32();
    }
     -> wait for prepare done
         if (mPrepareSync) {
            mSignal.wait(mLock);  // wait for prepare done
            mPrepareSync = false;
         }
  -> start()


Posted by 삼스