2011-08-31 40 views
0

有没有什么办法可以播放存储在原始文件中的视频,而无需使用uri。如果不是我如何正确设置uri。比方说,我有文件命名电影,我想用videoviewer播放它。我将如何做到这一点?我也必须将数据写入SD卡。或者我可以只从原始播放它。使用视频查看器的最佳方式。并播放视频

为什么不能我只是做

uri uri.parse("android.resources://"+this.getApplicationContext().getPackageName()+movie); 

这就是我把它当作现在如果你能你能指出这些错误给我,让我知道,我不会有这个问题的任何更多

  VideoView videoview = (VideoView) findViewById(R.id.videoView1); 
      videoview.setKeepScreenOn(true); 
      videoview.setVideoPath("android.raw://com.example.movievp8"); 
      MediaController controller = new MediaController(videoview.getContext()); 
      videoview.setMediaController(controller);   
      videoview.start(); 
      videoview.requestFocus();  

回答

0

这里的东西,对我的作品:

videoResource = R.raw.some_video; 
    String uri = String.format("android.resource://%s/%d", context.getPackageName(), videoResource); 
    animationCanvas = (VideoView) ui.findViewById(R.id.animation_canvas); 
    animationCanvas.setVisibility(View.VISIBLE); 
    animationCanvas.setVideoURI(Uri.parse(uri)); 
    animationCanvas.setOnCompletionListener(this); 
    animationCanvas.setOnPreparedListener(new OnPreparedListener() { 
     public void onPrepared(MediaPlayer mp) { 
      animationCanvas.start(); 

     } 
    }); 
+0

感谢@Ravi ...出于某种原因格式化被拒绝工作 –

相关问题