适用于Android的简单视频播放器“无法播放此视频”

时间:2014-10-20 10:47:58

标签: android video android-videoview

所以,我试图为Android创建一个非常简单的视频播放器并在Samsung Galaxy S3上运行它,但它一直给我留言#34;我们很抱歉,这个视频文件无法播放"。问题是我尝试了不同的视频,包括用同一部手机录制的视频,问题不在于视频。代码很简单,我只是对问题所在的想法没有用处,所以我要求帮助。这可能是愚蠢的事。

代码:

public class MainActivity extends ActionBarActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.activity_main);
            final VideoView videoView = (VideoView) findViewById(R.id.videoView1);
            videoView.requestFocus();
            String videoToPlay = Environment.getExternalStorageDirectory() + "/DCIM/Camera/20140524_183346.mp4";
            Uri videoUri = Uri.parse(videoToPlay);
            videoView.setVideoURI(videoUri);
            videoView.start();  
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }

如果您还有其他需要,请告诉我并感谢您的帮助。

编辑错误添加: 10-20 12:51:56.735:E / MediaPlayer(20398):错误(1,-2147483648) 10-20 12:51:56.735:D / VideoView(20398):错误:1,-2147483648

0 个答案:

没有答案