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)
- [Play Store] Unable to publish apps on Play Store using Horologist HOT 1
- [Feature Request] Let rotaryWithScroll support nested scrolling HOT 4
- Media sample - address kapt warning HOT 3
- Stepper sample displays a long float number HOT 2
- Improve documentation of app helper functions for wear
- Improve result for app helper functions that require capability HOT 5
- Improve API and/or kdoc of installOnNode function HOT 1
- Talkback speaking device output text twice in VolumeScreen HOT 1
- Improve A11ySnapshotTransformer to match Talkback behaviour on PW HOT 1
- Report a RNG hardware bug with transparency
- Look into FakeImageLoader
- Observable TimePicker state without onTimeConfirm press HOT 2
- Switch all dependencies such as protoc to TOML file
- Add a ActivityResultContract for VoiceInput
- AI Sample Readme and config guide
- Revert minSdk from 26 back to 25 HOT 7
- Horologist 0.5.5 and newer breaks multi click buttons HOT 9
- Refactor the screensize tests
- rotaryWithScroll not working with ScalingLazyColumn HOT 1
- Dependabot doesn't create update PRs for version 0.5.20 HOT 2
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.