Comments (3)
Hey @nihk Thanks, i followed the steps and managed to fetch the videos, working on exoplayer caching (Preloading?/PreCaching?) .
Thanks for your help
from videopager.
Hey @heromiyo, great question. In this project, all MainViewModel
cares about is the VideoDataRepository
interface - it doesn't know anything about how it ultimately gets the List<VideoData>
. That means you can pass in any custom implementation of VideoDataRepository
to the ViewModel. For example, you could create a FirebaseVideoDataRepository
implementation which uses Firebase to acquire the list of videos. VideoDataRepository
has the one function which returns a Flow<List<VideoData>>
; that represents a stream of data that could be anything on any thread.
In your case with Firebase you'll want to get a Flow of your relevant Firebase objects then map them to a List<VideoData>
. I'm not familiar with the Firebase APIs, but here's the basic idea with some contrived classes:
class FirebaseVideoDataRepository(private val firebase: Firebase) : VideoDataRepository {
override fun videoData(): Flow<List<VideoData>> {
return firebase.getAllVideos()
.map { videos -> videos.toVideoData() }
}
private fun List<FirebaseVideo>.toVideoData(): List<VideoData> {
return map { firebaseVideo -> VideoData(mediaUri = firebaseVideo.url) }
}
}
interface Firebase {
fun getAllVideos(): Flow<List<FirebaseVideo>>
}
data class FirebaseVideo(val url: String)
You could change the return type of VideoDataRepository's function to have some wrapper representing state, too. E.g. fun videoData(): Flow<MyState<List<VideoData>>>
. That will facilitate the Success/Error states in your example.
Note that the current state of the app in this repository won't show image previews of remote videos (only local videos). This can be achieved by simply adding a new field to the VideoData
object representing the image URL of a frame preview, then using it in the RecyclerView.ViewHolder. I'll check in a commit later to make that more clear.
from videopager.
hi, Have you solved it
Can I post part of the code of the response
from videopager.
Related Issues (8)
- create progress bar for every video HOT 1
- youtube kuds ui player HOT 1
- It is suggested that each line of code should be annotated for your convenience HOT 3
- It is better to group classes HOT 1
- video with Images HOT 2
- Open source license HOT 1
- this is a great project. can you demo with livestream like tiktok app, thanks a lot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from videopager.