doublesymmetry / kotlinaudio Goto Github PK
View Code? Open in Web Editor NEWKotlinAudio is an Android audio player written in Kotlin, making it simpler to work with audio playback from streams and files.
License: Apache License 2.0
KotlinAudio is an Android audio player written in Kotlin, making it simpler to work with audio playback from streams and files.
License: Apache License 2.0
I wonder if anyone else would find this issue helpful, or if devs are interested in implementing this/pulling my changes?
I unfortunately uses Samsung as my main phone and OneUI's android 13 doesnt have the new mediaSession notification style. What we got is the old school squared album art on the left, and metadata on the right. While I do try to keep all my album arts to be as square as possible, occasionally there are landscape or portrait album arts mixed in. The squared album art does a "contain" instead of "cover" so annoying white spaces will show. My solution is to crop any loading album art to squares: c514071
Although is this a good idea to push a PR or better kept in my own repo?
Samsung's media notification looks like:
https://www.reddit.com/r/oneui/comments/x46hbm/concept_one_ui_5_what_couldve_been_notifications/
Running the following:
git clone [email protected]:doublesymmetry/KotlinAudio.git
cd KotlinAudio
./gradlew -x test build publishToMavenLocal
Results in a linter error:
Task :kotlin-audio:lintDebug FAILED
Wrote HTML report to file:///Users/gav/Repos/KotlinAudio/kotlin-audio/build/reports/lint-results-debug.html
Lint found 3 errors and 9 warnings. First failure:
/Users/gav/Repos/KotlinAudio/kotlin-audio/src/main/java/com/doublesymmetry/kotlinaudio/notification/NotificationManager.kt:159: Error: Call requires API level 24 (current min is 21): java.lang.Iterable#forEach [NewApi]
config.buttons.forEach { button ->
~~~~~~~
Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kotlin-audio:lintDebug'.
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintTask$AndroidLintLauncherWorkAction
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintWorkAction
> Lint found errors in the project; aborting build.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 11s
142 actionable tasks: 142 executed
gav@gavs-mbp KotlinAudio %
Continuing from this thread: doublesymmetry/react-native-track-player#1264 (comment)
If you pause the audio after receiving the updateOnAudioFocusChanged event, the follow up event to unpause the audio again is not sent.
Might this be happening because audio focus is abandoned when you pause the audio after receiving the first event?
In onIsPlayingChanged I see audio focus is abandoned whenever the audio ceases to play.
In the Android guide to managing audio focus, it is not required to release audio focus when the audio has been paused: https://developer.android.com/guide/topics/media-apps/audio-focus#:~:text=Abandoning%20audio%20focus%20is%20not%20required%20if%20the%20user%20pauses%20playback%20but%20may%20resume%20it%20later.
Looks like this project is missing a license, and since it's a dependency of react-native-track-player and I include licenses in my build, and fail the build when licenses are missing (or not manually added, but I can't find one here to add), my build is broken with the Android rewrite. Could you add a license to this library? Thank you!
Due to this compatibility issue, if I install RNTP 4.0, all fetches in the app will fail and the app will crash.
If I go back to the previous version, 1.4.0, the problem will not occur.
I faced this issue when using react-native-track-player, which is utilizing KotlinAudio library:
Version: v0.1.34
Fatal Exception: kotlin.UninitializedPropertyAccessException: lateinit property descriptionAdapter has not been initialized
at com.doublesymmetry.kotlinaudio.notification.NotificationManager$destroy$1.invokeSuspend(NotificationManager.kt:295)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:247)
at android.app.ActivityThread.main(ActivityThread.java:8676)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
This commit fixes a crash related to react-native fast reloads, but the latest commit breaks react-native-track-player if KotlinAudio is used on main, can the maintainers/owners please generate a tag 1.2.5 with the mentioned commit?
I've done some testing and this commit has broken remote seek:
Note sure why, I'll look into it but if anyone has any ideas that'd be great.
Currently seeing an issue where i cannot update the image for the lock screen
I can see that the passed info i.e we have a title, artis and artwork but nothing seems to update on the lockscreen.
I have tried setting player.automaticallyUpdateNotificationMetadata to both true and false
@MainThread
fun updateNotificationMetadata(title: String?, artist: String?, artwork: String?) {
player.notificationManager.notificationMetadata = NotificationMetadata(title, artist, artwork)
}
Please could you advise or help?
If we change this long to double we can improve seeking, without any downside?
Hi, thanks for this great library.
I am working in a project that uses a old exoplayer dependencie and I having these kind of errors:
Duplicate class com.google.android.exoplayer2.ui.WebViewSubtitleOutput$1 found in modules jetified-exoplayer-ui-2.14.2-runtime (com.google.android.exoplayer:exoplayer-ui:2.14.2) and jetified-exoplayer-ui-r2.16.4-runtime (com.github.DoubleSymmetry.ExoPlayer:exoplayer-ui:r2.16.4)
Duplicate class com.google.android.exoplayer2.video.spherical.CameraMotionListener found in modules jetified-exoplayer-core-2.14.2-runtime (com.google.android.exoplayer:exoplayer-core:2.14.2) and jetified-exoplayer-core-r2.16.4-runtime (com.github.DoubleSymmetry.ExoPlayer:exoplayer-core:r2.16.4)
It is because Kotlin audio is using the same "com.google.android.exoplayer2" package name, maybe could be it changed for future versions?
Hi,
We are facing a cache issue with react-native-trackplayer it's seem the cache not being released before init a new player.
Have you any advice too avoid this?
I have an arrayBuffer which I want to playback as a stream. Is this possible?
Hello, our builds started failing today because KotlinAudio v1.1.0 is not available in jitpack anymore. Is there a mitigation for this issue?
> Failed to transform KotlinAudio-v1.1.0.aar (com.github.DoubleSymmetry:KotlinAudio:v1.1.0) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find KotlinAudio-v1.1.0.jar (com.github.DoubleSymmetry:KotlinAudio:v1.1.0).
Searched in the following locations:
https://www.jitpack.io/com/github/DoubleSymmetry/KotlinAudio/v1.1.0/KotlinAudio-v1.1.0.aar
https://www.jitpack.io/com/github/DoubleSymmetry/KotlinAudio/v1.1.0/KotlinAudio-v1.1.0.jar
When I checked the website, I see an error as well https://www.jitpack.io/com/github/DoubleSymmetry/KotlinAudio/v1.1.0/
but for example 1.2.4 is available there https://www.jitpack.io/com/github/DoubleSymmetry/KotlinAudio/v1.2.4/
I've opened an issue on doublesymmetry/react-native-track-player#2187
I'm using React Native Track Player on a TV Box running android 7.1.2
And I'm getting a crash when trying to remove a song from the queue.
Here is the error:
FATAL EXCEPTION: main
Process: com.mytvapp, PID: 6889
java.lang.UnsupportedOperationException
at java.util.AbstractList.set(AbstractList.java:132)
at java.util.AbstractList$ListItr.set(AbstractList.java:426)
at java.util.Collections.sort(Collections.java:247)
at com.doublesymmetry.kotlinaudio.players.QueuedAudioPlayer.remove(QueuedAudioPlayer.kt:154)
at com.doublesymmetry.trackplayer.service.MusicService.remove(MusicService.kt:318)
at com.doublesymmetry.trackplayer.module.MusicModule$remove$1.invokeSuspend(MusicModule.kt:328)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@299f479, Dispatchers.Main]
Points to this code
fun remove(indexes: List<Int>) {
val sorted = indexes.toList()
// Sort the indexes in descending order so we can safely remove them one by one
// without having the next index possibly newly pointing to another item than intended:
Collections.sort(sorted, Collections.reverseOrder());
sorted.forEach {
remove(it)
}
}
Now based on some research I suspect either the function is unsupported in android 7 or another one is its trying to remove from a non-modifiable list.
Any ideas?
KotlinAudio v0.1.29 could not be found when building for android, see the error message bellow:
The https links return a 404 page
Could not resolve all files for configuration ':app:[REDACTED]RuntimeClasspath'.
Could not find com.github.DoubleSymmetry:KotlinAudio:v0.1.29.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/github/DoubleSymmetry/KotlinAudio/v0.1.29/KotlinAudio-v0.1.29.pom
- file:/Users/vagrant/.m2/repository/com/github/DoubleSymmetry/KotlinAudio/v0.1.29/KotlinAudio-v0.1.29.pom
- file:/Users/vagrant/git/node_modules/react-native/android/com/github/DoubleSymmetry/KotlinAudio/v0.1.29/KotlinAudio-v0.1.29.pom
- https://dl.google.com/dl/android/maven2/com/github/DoubleSymmetry/KotlinAudio/v0.1.29/KotlinAudio-v0.1.29.pom
- https://www.jitpack.io/com/github/DoubleSymmetry/KotlinAudio/v0.1.29/KotlinAudio-v0.1.29.pom
Required by:
project :app > project :react-native-track-player
I got a crash when upgrade to v1.1.0
I need this version because my project also needs react-native-video
. I'm using react-native-track-player
version 3.0.0
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (49, 44): Unresolved reference: ratingType
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (51, 40): Unresolved reference: ratingType
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (116, 59): Cannot find a parameter with this name: isCompact
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (316, 36): Unresolved reference: clearNotification
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (373, 19): Unresolved reference: onNotificationButtonTapped
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (374, 17): 'when' expression must be exhaustive, add necessary 'else' branch
e: /Users/vu.nguyen8/WebstormProjects/trainery-app/node_modules/react-native-track-player/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt: (374, 23): Unresolved reference: it
Hi,
Im currently trying to avoid buffering when I seek backwards by 10s. However when I seek back, the item buffers resulting in a position of 0 and the seek bar jumping from current position to 0 back to seeked position.
This is how im setting the buffer atm
`fun setupPlayer(playerOptions: Bundle?) {
val bufferConfig = BufferConfig(
playerOptions?.getDouble(MIN_BUFFER_KEY)?.toMilliseconds()?.toInt(),
playerOptions?.getDouble(MAX_BUFFER_KEY)?.toMilliseconds()?.toInt(),
playerOptions?.getDouble(PLAY_BUFFER_KEY)?.toMilliseconds()?.toInt(),
playerOptions?.getDouble(BACK_BUFFER_KEY)?.toMilliseconds()?.toInt(),
)
val cacheConfig = CacheConfig(playerOptions?.getDouble(MAX_CACHE_SIZE_KEY)?.toLong())
val playerConfig = PlayerConfig(
interceptPlayerActionsTriggeredExternally = true,
handleAudioBecomingNoisy = true,
handleAudioFocus = true,
audioContentType = AudioContentType.SPEECH // Setting this will result in pausing the audio rather then ducking
}
)
val automaticallyUpdateNotificationMetadata = false
player = QueuedAudioPlayer(this@MusicService, playerConfig, bufferConfig, cacheConfig)
player.automaticallyUpdateNotificationMetadata = automaticallyUpdateNotificationMetadata
if (playerInitialized == false) {
observeEvents()
}
playerInitialized = true
}`
the values im passing in
minBuffer : 1000 * 30 // 30s
maxBuffer: 1000 * 60 * 10 // 10min
backBuffer: 1000 * 60 * 5 // 5min
playBuffer: 1000 * 30 // 30s
We received this bug report recently, where Podverse audio is able to be mixed in with other apps, while video apps play in the background.
If I follow these steps I can reproduce the issue:
But I cannot reproduce the issue if I follow these steps:
With the help of newdarkworld in the Discord support channel, they pointed me to this documentation.
One thing stands out to me:
Call requestAudioFocus() immediately before starting to play and verify that the call returns AUDIOFOCUS_REQUEST_GRANTED. If you design your app as we describe in this guide, the call to requestAudioFocus() should be made in the onPlay() callback of your media session.
However when I look into KotlinAudio, it appears that requestAudioFocus
is called on READY
instead of PLAYING
. The bug behavior I am seeing seems to fit that? If focus is only called on READY, then our app won't regain audio focus until another track is loaded and the READY state is called?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.