Search code examples
androiddropboxdropbox-apiexoplayerexoplayer2.x

why I can't stream an audio or video stored in dropbox?


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 ?


Solution

  • 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.