Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
fix wrong merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilababayeva committed Mar 17, 2022
1 parent 0138cfd commit 5ffc2f6
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions app/src/main/java/ch/sdp/vibester/api/ItunesMusicApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,6 @@ class ItunesMusicApi private constructor(){
return retFuture
}

/**
* A function that given an audio stream url will play it
* @param audioUrl Url in String pointing towards the audio stream
* @return CompletableFuture<MediaPlayer> that contains the current playing mediaPlayer
*/
fun playAudio(audioUrl: String): CompletableFuture<MediaPlayer>{
val mediaFut = CompletableFuture<MediaPlayer>()
var mediaPlayer: MediaPlayer = MediaPlayer()
mediaPlayer.setAudioAttributes(
AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build()
)
try {
mediaPlayer.setDataSource(audioUrl)
mediaPlayer.prepare()
mediaPlayer.setOnPreparedListener {
mediaPlayer.start()
mediaFut.complete(mediaPlayer)
}
}catch (e: IOException){
Log.e("[PlayAudio]", "Error see stacktrace")
mediaFut.completeExceptionally(e)
}
return mediaFut
}

}


Expand Down

0 comments on commit 5ffc2f6

Please sign in to comment.