如何在SD卡中播放视频

时间:2013-03-26 10:43:36

标签: android

我试图播放我的SD卡中的视频,但是显示错误,视频无法播放..我的代码是

public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        mVideoView = (VideoView) findViewById(R.id.surface_view);

        mPath = (EditText) findViewById(R.id.path);

        mPath.setText("mnt/sdcard/music/jelly jamm.3gp");

任何人都可以帮助我..我尝试了堆栈溢出中的所有帖子但仍然得到相同的错误

3 个答案:

答案 0 :(得分:1)

             Intent intent = new Intent();
             intent.setAction(Intent.ACTION_VIEW);
             Uri imgUri = Uri.parse("file://mnt/sdcard/music/jelly jamm.3gp");
             intent.setDataAndType(imgUri, "video/mp4");
             startActivity(intent);

试试这样。希望这会给你一些解决方案。

答案 1 :(得分:0)

使用此代码播放sdcard中的视频

    VideoView vv = (VideoView)findViewById(R.id.videoView1);

    File root;
    root = Environment.getExternalStorageDirectory();
    Log.d("FILEPATH1", root.toString());

    String path =root.toString()+"/music/jelly jamm.3gp";

    MediaController mc= new MediaController(getApplicationContext());

    vv.setVideoPath(path);

    vv.setMediaController(mc);

    vv.requestFocus();

    vv.start();

答案 2 :(得分:0)

如果您发布错误,我们可以帮助您...

可能是您的视频与Android不兼容。尝试使用其他视频。像任何.mp4视频一样适用于Android。如果该视频有效,而您的视频无效,那么您的视频与Android不兼容。 并在设备上进行测试。模拟器上的视频播放需要太多电量。

相关问题