Skip to content

Commit

Permalink
replace deprecated function used in TikTokPlayer.kt (Gurupreet#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiryadev authored Jul 3, 2021
1 parent b8e0990 commit 3fb6e80
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.viewinterop.AndroidView
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.source.ProgressiveMediaSource
Expand All @@ -20,11 +21,14 @@ fun TikTokPlayer(context: Context, url: String, selected: Boolean) {
SimpleExoPlayer.Builder(context)
.build()
.apply {
val mediaSource = ProgressiveMediaSource.Factory(
DefaultDataSourceFactory(context, "composeCookBook")
)
.createMediaSource(Uri.parse("asset:///${url}"))
this.prepare(mediaSource)
val mediaSource = ProgressiveMediaSource
.Factory(
DefaultDataSourceFactory(context, "composeCookBook")
)
.createMediaSource(MediaItem.fromUri(Uri.parse("asset:///${url}")))

this.setMediaSource(mediaSource, true)
this.prepare()
}
}
tiktokPlayer.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
Expand Down

0 comments on commit 3fb6e80

Please sign in to comment.