在 android 中将视频上传到 Firebase 时显示搜索栏

Show seekbar when video is uploaded to firebase in android

floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.setType("video/*");
                intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                startActivityForResult(Intent.createChooser(intent, "Complete action using"), RC_PHOTO_PICKER);

            }
        });

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
         if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) {
            Uri selectedImageUri = data.getData();

            // Get a reference to store file at chat_photos/<FILENAME>
            StorageReference photoRef = mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment());

            // Upload file to Firebase Storage
            photoRef.putFile(selectedImageUri)
                    .addOnSuccessListener(this, new OnSuccessListener<UploadTask.TaskSnapshot>() {
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            // When the image has successfully uploaded, we get its download URL
                            //  progressBar.setVisibility(View.VISIBLE);
                            Uri downloadUrl = taskSnapshot.getDownloadUrl();

                            // Set the download URL to the message box, so that the user can send it to the database
                            Video video = new Video(downloadUrl.toString());
                            mMessagesDatabaseReference.push().setValue(video);
                        }
                    });
        }
    }

我想在图片上传时在搜索栏上显示进度作为通知。我怎么做?我在 onCreate 中创建了一个 Seekbar 对象。如何获取我正在上传的视频的持续时间并在通知中显示搜索栏,并且用户在上传开始时不应该滑动通知?请帮忙。

您可以使用 addOnProgressListener

.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
            int progress = (int) ((100 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount());
            try {
                yourSeekBar.setProgress(progress);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    })