为什么exo media不从url播放视频?

iyfjxgzm  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(216)

我试图集成exo播放器播放视频从网址,但它只显示进度栏没有其他。我是android新手,请帮我找出问题并在我的移动应用程序上播放视频。下面是我的xml代码-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.devbrackets.android.exomedia.ui.widget.VideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:useDefaultControls="true" />

</RelativeLayout>

这是我的java代码-

package com.example.videodemo;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

import com.devbrackets.android.exomedia.listener.OnPreparedListener;
import com.devbrackets.android.exomedia.ui.widget.VideoView;

public class ExoMediaActivity extends AppCompatActivity implements OnPreparedListener {

private VideoView videoView;

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

    videoView = (VideoView) findViewById(R.id.video_view);
    videoView.setOnPreparedListener(ExoMediaActivity.this);

    //For now we just picked an arbitrary item to play
    videoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4"));
}

@Override
public void onPrepared() {
    videoView.start();
}
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题