[如何解决Android Studio中的错误“无法播放此视频”? (m3u8)文件

问题描述 投票:0回答:1

我正在使用ExoPlayer和m3u8文件。每当我运行我的应用程序时,它都会说

无法播放此视频

也许一切都应该正确,但我不知道为什么会这样说>

XML文件:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity">


<VideoView
    android:id="@+id/video_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity文件:

public class MainActivity extends AppCompatActivity {

VideoView videoView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    VideoView videoView = findViewById(R.id.video_view);

    final ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
    progressDialog.setMessage("Please Wait");
    progressDialog.setCancelable(false);
    progressDialog.show();

    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);



    videoView.setVideoURI(Uri.parse("http://mos.rusiptv.net:8080/live/@celalsonat/784512/94815.m3u8"));
    videoView.start();

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            progressDialog.dismiss();
        }
    });
 }
} 

提前感谢!

我正在使用ExoPlayer和m3u8文件。每当我运行我的应用程序时,它都会说“无法播放此视频”,也许一切都应该正确,但是我不知道为什么它像XML文件那样显示:&...

java android exoplayer m3u8
1个回答
0
投票

有很多原因。.

© www.soinside.com 2019 - 2024. All rights reserved.