Comments (6)
We made a deliberate decision to build the sample around the Google promoted options like Hilt. We previously avoided this in our samples, and we found that we ended up inventing a lot of DI concepts in the sample to fill gaps, overall was not simple either.
Some specifics:
prepare the player and release it (it seems this was removed from PlayerRepositoryImpl)
This has moved into Hilt, this lifecycle code is easy to get wrong, and once you are injecting it, it's hard to know what the tear down involves.
This is the code
Using a service to enable background playback (but not a browser service)
There are better examples that show the direct use of Media3 types, such as
Proper way to handle updating elapsed time
This has changed to a Compose first method, see here
So we read the position, status, and playback speed and predict the position for each frame.
Thanks for the feedback, I'll leave this open and discuss how we can better document this.
from horologist.
Now that I've finished the migration, the main sticking points for me were:
- Migrating from a custom PlayerRepositoryImpl to a standard one (I was able to just delete it, use the built-in one and migrate the prepare and release code to my view model)
- Updating the UI for the changes and handling time updates -- your comments helped me out a lot here.
mediaDisplay = { playerUiState ->
val timestampProvider = LocalTimestampProvider.current
var position by remember { mutableStateOf(null as Duration?) }
val summary = position?.let {
DateUtils.formatElapsedTime(it.inWholeSeconds)
} ?: ""
TextMediaDisplay(
title = "",
subtitle = summary
)
LaunchedEffect(playerUiState.trackPositionUiModel) {
when (val state = playerUiState.trackPositionUiModel) {
is TrackPositionUiModel.Actual -> position = state.position
TrackPositionUiModel.Hidden -> position = null
is TrackPositionUiModel.Loading -> {
// Ignore -- don't erase previous value.
}
is TrackPositionUiModel.Predictive -> {
while (isActive) {
val timestamp = timestampProvider.getTimestamp()
val duration = state.predictor.predictDuration(timestamp)
position = state.predictor.predictPosition(timestamp)
.coerceAtMost(duration)
delay(1000)
}
}
}
}
},
I didn't have to modify the rest of the integration, but I think it would still be beneficial to have a simpler example showing how to use the framework for playing a single file out of a playlist.
from horologist.
Going to close this, as I don't think we have plans for another media sample. And I think a real media player using remote content, DI, is more useful for this if we have to choose one. So it's a choice.
But please ask on slack if you are stuck.
from horologist.
Also we are active on kotlin lang slack, if you have other questions, feel free to connect there and I can help 1:1. Then work out how to update the docs based on those results.
from horologist.
Thanks, this is super appreciated. I'll check out the slack channels too.
from horologist.
cc @kul3r4 for feedback
from horologist.
Related Issues (20)
- AmbientAware composable unnecessarily recreates the whole tree HOT 2
- Horologist media router usage HOT 1
- Compose-Layout transitive dep on compose-navigation HOT 4
- Improve tracking Tile installation HOT 2
- Invalid doc links
- Review pipeline initializations HOT 1
- Use correct padding for all responsive SLC
- Use Responsive Dialog consistently HOT 1
- [Feature request] scalingLazyColumnDefaults does not support userScrollEnabled parameter HOT 10
- Stop a release off a release branch from generating docs HOT 1
- rotaryWithScroll in Dialogs HOT 4
- Uamp isn't restarting playback after pause and resume HOT 2
- Using rotaryWithScroll and onRotaryInputAccumulatedWithFocus simultaneously HOT 7
- AGP 8.3.0 upgrade is blocked
- Improve Tile tracking initialization HOT 1
- Some datalayer docs out of date HOT 1
- [FR] Expose beyondViewportPageCount to PagerScreen HOT 1
- Some screenshot tests not completing HOT 3
- horologist-datalayer-watch dependencies HOT 6
- Horologist
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 horologist.