0

so in my Android app, I can use an exoplayer like this

lateinit var player : SimpleExoPlayer!

val mediaItem = MediaItem.fromUri("https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3")
player = SimpleExoPlayer.Builder(mContext).build()
player.setMediaItem(mediaItem)
playerView.player = player

I can stream the audio without any use if I use the code above.

but if I want to use an audio file that have in dropbox, the sound will never play, the code and link is like this

val mediaItem = MediaItem.fromUri("https://www.dropbox.com/s/lbe1kod9t6yuh5j/sample1.m4a")

how to solve this ?

2

2 Answers 2

4

replace www by dl from your link and add ?dl=1 to end

for example

https://dl.dropbox.com/s/lbe1kod9t6yuh5j/sample1.m4a?dl=1

try this. it's work for me.

1
1

Adding ?raw=1 to the end of the URL, worked for me. Example:

https://www.dropbox.com/s/lbe1kod9t6yuh5j/sample1.m4a?raw=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.