I wrote a media player for playing video, but it encounter an error of
PV SW DECODER IS USED FOR MPEG4 when I try to play back a 3gp format
video, anyone knows what is it? How to solve this problem? I paste my
code below:

package com.test;


import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MediaVideoTest extends Activity implements
MediaPlayer.OnPreparedListener,MediaPlayer.OnCompletionListener,SurfaceHolder.Callback
{

        private static final String TAG = "MediaVideoTest";
        private MediaPlayer player;
        private SurfaceHolder holder;
        private SurfaceView surfaceView;
        private int mWidth,mHeight;


        @Override
        protected void onCreate(Bundle savedInstanceState) {

                super.onCreate(savedInstanceState);
                setContentView(R.layout.video_view);
                surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
                holder = surfaceView.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        }

        private void playVideo() {

                try {
                        AssetFileDescriptor asd = 
getResources().openRawResourceFd
(R.raw.chainsaw);

                        //create media player
                        player = new MediaPlayer();
                        
player.setDataSource(asd.getFileDescriptor(),asd.getStartOffset
(),asd.getLength());
                        player.setDisplay(holder);
                        player.prepare();
                        player.setOnPreparedListener(this);
                        player.setOnCompletionListener(this);
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);

                } catch (Exception e) {
            Log.e(TAG, "error: " + e.getMessage(), e);
                }
        }

        @Override
        public void onPrepared(MediaPlayer mp) {
        Log.d(TAG, "onPrepared called");
                mWidth = player.getVideoWidth();
                mHeight = player.getVideoHeight();
                Log.d(TAG, "width : " + mWidth + " height : " + mHeight);

                if(mWidth != 0 && mHeight != 0){
                        holder.setFixedSize(mWidth, mHeight);
                        player.start();
                }
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int
width,int height) {
        Log.d(TAG, "surfaceChanged width : " + width + " height : " +
height);
        }

        @Override
        public void surfaceCreated(SurfaceHolder holder) {
        Log.d(TAG, "surfaceCreated() is called");
                playVideo();
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
        Log.d(TAG, "surfaceDestroy() is called");
        }

        @Override
        protected void onDestroy() {
                super.onDestroy();
                if(player != null){
                        player.release();
                        player = null;
                }
        }

        @Override
        public void onCompletion(MediaPlayer mp) {

                if(player != null){
                        player.release();
                        player = null;
                }

                //close this activity;
                finish();

                //go back to the main menu
                Intent intent = new Intent(this,MediaTest.class);
                startActivity(intent);

        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to