Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 视频播放Countino firebase_Java_Android_Firebase_Firebase Realtime Database - Fatal编程技术网

Java 视频播放Countino firebase

Java 视频播放Countino firebase,java,android,firebase,firebase-realtime-database,Java,Android,Firebase,Firebase Realtime Database,我用Fire base数据库存储了视频链接,总共有3个链接。如果您能演示如何连续播放歌曲,则无需触摸代码即可连续播放视频。代码很抱歉,可能也有错误 private FirebaseDatabase firebaseDatabase; private DatabaseReference song1; private DatabaseReference song2; private DatabaseReference song3; private VideoView videoView; pr

我用Fire base数据库存储了视频链接,总共有3个链接。如果您能演示如何连续播放歌曲,则无需触摸代码即可连续播放视频。代码很抱歉,可能也有错误

private FirebaseDatabase firebaseDatabase;
private DatabaseReference song1;
private DatabaseReference song2;
private DatabaseReference song3;
private VideoView videoView;



protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  firebaseDatabase = FirebaseDatabase.getInstance();
  song1 = firebaseDatabase.getReference().child("Song").child("1");
  song2 = firebaseDatabase.getReference().child("Song").child("2");
  song3 = firebaseDatabase.getReference().child("Song").child("3");
  videoView = findViewById(R.id.videoView);
  total = firebaseDatabase.getReference().child("Song");
------------------------------------------------------------------------

  total.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            List<Uri> list = new ArrayList<>();
            for (DataSnapshot child : dataSnapshot.getChildren()) {
                list.add(child.getValue(Uri.class));
                Uri uri=Uri.parse(dataSnapshot.getValue().toString());
               videoView.setVideoURI(uri);
               videoView.requestFocus();
               videoView.start();
            }



}

私有FirebaseDatabase FirebaseDatabase;
私有数据库参考1;
私有数据库参考2;
私有数据库参考3;
私人视频视图;
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
firebaseDatabase=firebaseDatabase.getInstance();
song1=firebaseDatabase.getReference().child(“歌曲”).child(“1”);
song2=firebaseDatabase.getReference().child(“歌曲”).child(“2”);
song3=firebaseDatabase.getReference().child(“歌曲”).child(“3”);
videoView=findviewbyd(R.id.videoView);
total=firebaseDatabase.getReference().child(“歌曲”);
------------------------------------------------------------------------
total.addValueEventListener(新的ValueEventListener(){
@凌驾
public void onDataChange(@NonNull DataSnapshot DataSnapshot){
列表=新的ArrayList();
对于(DataSnapshot子项:DataSnapshot.getChildren()){
add(child.getValue(Uri.class));
Uri=Uri.parse(dataSnapshot.getValue().toString());
setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}
}
您可以创建一个方法并向其传递不同的url

playVideo(String uri) {

    videoView.setVideoURI(uri);
    videoView.requestFocus();
    videoView.start();
}
调用playVideo方法时,检查以下条件-

if (videoView.isPlaying()) {

}
else {
     playVideo(uri);
}
您可以创建一个方法并向其传递不同的url

playVideo(String uri) {

    videoView.setVideoURI(uri);
    videoView.requestFocus();
    videoView.start();
}
调用playVideo方法时,检查以下条件-

if (videoView.isPlaying()) {

}
else {
     playVideo(uri);
}

你想先播放歌曲1,然后播放歌曲2,然后播放歌曲3吗?是的,我的计划是使用循环,但如果有更好的方法,尝试它很好。你想先播放歌曲1,然后播放歌曲2,然后播放歌曲3吗?是的,我的计划是使用循环,但如果有更好的方法,尝试为3首不同的歌曲工作很好。如果你能给我更多的解释如何存储3首不同的歌曲1数据引用中的数据引用=song1,song2,song3,它对3首不同歌曲的工作?如果你能给我更多解释如何在1数据引用中存储3个不同的数据引用=song1,song2,song3,