Android:如何从资源中播放内部MediaPlayer中的视频,任何人都可以帮忙吗?

时间:2011-01-09 12:41:38

标签: android media-player

我正在尝试从应用程序中的资源播放mp4视频,无论是res / raw还是资产,但我没有运气,也无法找到任何可在任何地方工作的教程或解决方案,希望有人听到可以提供答案。

下面的代码,我认为会起作用但不会,请告诉我怎么做?

由于 露

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video);    

    final Button button = (Button) findViewById(R.id.play);  
         button.setOnClickListener(new Button.OnClickListener() {  
             public void onClick(View v) {  
                 Uri uri = Uri.parse("android.resource://com.video.play.test/" + R.raw.test2);
                 Intent intent=new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/mp4");
                 startActivity(intent);  
             }
         });  
}

2 个答案:

答案 0 :(得分:0)

请查看关于该主题的答案:

https://groups.google.com/group/android-developers/browse_thread/thread/9a934f3aa2e4256/577d991b0f94aaf2?hl=hr&lnk=gst&q=play+video+resources#577d991b0f94aaf2

我所管理的是从我的应用程序中的资源(我的布局中的SufraceView)播放视频。另一种方法是(如链接中所建议的)将视频复制到SD卡,并使用内部(系统)MediaPlayer从那里轻松播放。

答案 1 :(得分:0)

This solution可能是相关的。