Android SDK 2.2的windows 模拟器,运行《Hello Android》上的例子(代码如下),遇到如下错误。samplevideo.3gp保存在项目目录的data目录下。类似的mp3的例子就没问题屏幕打出Cannot play video,LogCat:
09-20 14:09:44.849: ERROR/MediaPlayer(278): error (1, -2147483648)
09-20 14:09:44.880: ERROR/MediaPlayer(278): Error (1,-2147483648)
09-20 14:09:44.880: DEBUG/VideoView(278): Error: 1,-2147483648----------------------------------
//Video.java
package org.example.video;import android.app.Activity;
import android.os.Bundle;import android.widget.VideoView;public class Video extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.main);
VideoView video = (VideoView) findViewById(R.id.video);
// Load and start the movie
video.setVideoPath("/data/samplevideo.3gp" );
video.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
........
video.setOnPreparedListener(videoViewPrepared);
........
}private OnPreparedListener videoViewPrepared = new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.v(TAG, "onPrepared");
video.start();
}
};这些需要做一下