Closed Zaraki596 closed 1 year ago
@Zaraki596 Hello! Please, take a look at Amplituda library which is used sample app.
You can use code below to process audio from the URL and then pass it to the audio waveform library.
amplituda.processAudio("https://audio-url-example.com/amplituda.mp3", Cache.withParams(Cache.REUSE))
Otherwise, if you need to process more "advanced" URLs, you can try to use yt-dlp to download audio and then process with Amplituda or FFMPEG. Here is a brilliant android project Seal which uses yt-dlp
amplituda.processAudio("https://audio-url-example.com/amplituda.mp3", Cache.withParams(Cache.REUSE))
Will this function return the mediaItem ?
Sorry, I misunderstood you a bit. If you want to play (not process URL), then you can use ExoPlayer, Media3, or even MediaPlayer.
In the sample app, playback is implemented in AudioPlaybackManager
. You can try to add new setAudio()
function with URL. (Create a simple exoplayer to stream video from url)
fun setAudio(url: String, title: String) {
setAudio(getMediaItem(MediaItem.fromUri(url), title))
}
If we want to play the audio directly from URL, MediaItem.fromUri(url)
is not working properly.
This worked out.
val rmd = MediaItem.RequestMetadata.Builder()
.setMediaUri(Uri.parse(url))
.build()
MediaItem.Builder().setRequestMetadata(rmd).build()
if we don't add Uri.parse(url)
then this won't work...Maybe for this we need customDataFactory
, But I tried to add this in the PlaybackService class in the Exoplayer but that also didn't worked out.
Yes, maybe something went wrong in PlaybackService
. Please, check media items in onAddMediaItems() PlaybackService
callback
Currently, the sample app contains the example which uses the ContentResolver to play the local files. We need some help to directly play media from the Url. how do we set up the MediaItem to play from the URL? From the Example, we can see it is using MediController to play the local file is there any example where we can play using URL?