Upload video firebase android
Here I will show you how you can Upload a video in firebase storage with text. for this you need to create an android app and then connect it to firebase.
Learn how to upload video in firesbase storage with text based on current version of firebase.
for this we will create a method for choosing video and then it in a video view and then we will use onActivityResult method for showing it and then we will create a method for identifying the extension of file and then we will use addOnSuccessListener for uploading video in firebase storage and we will save text oin firebase realtime database with videoUrl.
Developers use the firebase SDK for cloud storage to upload and download files directly from clients ,if the network connection is poor then client is able to retry the operation right where is left off saving users time and bandwidth.
how does it work ?
The firebase realtime database lets you build rich collaborative applications by allowing secure access to the database directly from client side code . Data is persisted locally and even while offline,realtime events countinue to fire,giving the end user a responsive experience.when the device regains connection ,the realtime database synchronizes the local data changes with the remote updates that occurred while the client was offline merging any conflicts automatically.
The realtime database provides a flexible,expression based rules language,called
firebase realtime database security rules to define how your data should be structured and when data can be read from or written to.when integrated with firebase authentication
developers can define who has access to what data and how they can access it.
So guys first of all we will create a project and then we will connect it with firebase then after this we will implement its SDK for uploading and downloading data from its cloud storage so you will be able to upload video firebase android .In firebase we have two types of database realtime and firestore.In this tutorial we will use realtime database for saving data and firebase storage for uploading video .first of all we will activity_main.xml file for UI and where we will use widgets for uploading video.we will use video view for loading video and button for uploading and one progress bar for its progress while uploading .
So guys first of all we will declare a Integer variable for choosing video item then guys we will create a method inside it we will use Intent for choosing video and loading it in video view .Here we will also declare a Uri for video for this we will implement Uri and that Uri will be used while uploading and then we will use onActivityResult for choosing video and getting data in VideoUri.
Then after choosing video if VideoUri is not null then it will load it in video view and start playing so for controlling video we will use a media controller for controlling then we can play and pause video.
Then we will also use and Edittext for saving video name so when then user will choose the video and after this user will give name to it and then we will be able to upload that video because if video and edittext is empty then we can not upload video .so that is why videoUri and name edittext must have data so after giving name and choosing video user will click on button for uploading video then it will make progress bar visible and our progress bar is indeterminant so it will not show exact progress of upload. when the video will be uploaded successfully then we will take its upload session uri and save it it in realtime database.
Source code below
Join Our channel member ship for source code
Then check community tab
Things you need to check-
- You have changed firebase rules.
- You have given internet permission in manifest file.
- Given all the reference.
Hope my codes helped you so please subscribe my channel on youtube for more interesting videos like this :)
0 Comments