【问题标题】:Android can't play video issueAndroid无法播放视频问题
【发布时间】:2018-04-11 11:02:13
【问题描述】:

视频 URL 在默认 Android 媒体播放器中不起作用。例如:

http://clips.vorwaerts-gmbh.de/VfE_html5.mp4

以上网址在安卓的默认媒体播放器中不起作用。

【问题讨论】:

  • 使用exo播放器播放视频。
  • 如果您愿意,请提供代码。
  • 能发一下代码吗

标签: android video video-streaming video-processing android-videoview


【解决方案1】:

它正在使用 VideoView

    VideoView videoview;
    videoview = (VideoView) findViewById(R.id.VideoView);

    try {
                // Start the MediaController
                MediaController mediacontroller = new MediaController(
                        VideoPlayActivity.this);
                mediacontroller.setAnchorView(videoview);
                // Get the URL from String VideoURL
                Uri video = Uri.parse("http://clips.vorwaerts-gmbh.de/VfE_html5.mp4");
                videoview.setMediaController(mediacontroller);
                videoview.setVideoURI(video);

            } catch (Exception e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }

            videoview.requestFocus();
            videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                // Close the progress bar and play the video
                public void onPrepared(MediaPlayer mp) {
                    videoview.start();
                }
            });

【讨论】:

    猜你喜欢
    • 2019-05-25
    • 1970-01-01
    • 2018-11-14
    • 2014-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多