[go: up one dir, main page]

Skip to content

Commit

Permalink
Add preload manager to exoplayer. (1) Customize time frame to preload…
Browse files Browse the repository at this point in the history
… for videos.(2) Add preload manager as an optional to Timeline screen (4) Add 10 remote videos to chats by sending :prelaod: message to any chat (5) Replace Timeline surface view with Player view for better performance. (6) Use the preloaded source from PreloadManager (7) Add a flag to enable Preload Manager
  • Loading branch information
MayuriKhinvasara committed Aug 28, 2024
1 parent 64686e3 commit b7204a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package com.google.android.samples.socialite.data.utils
class ShortsVideoList {
companion object {
val mediaUris =
mutableListOf(
listOf(
"https://storage.googleapis.com/exoplayer-test-media-0/shorts_android_developers/shorts_1.mp4",
"https://storage.googleapis.com/exoplayer-test-media-0/shorts_android_developers/shorts_2.mp4",
"https://storage.googleapis.com/exoplayer-test-media-0/shorts_android_developers/shorts_3.mp4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fun TimelineVerticalPager(
.fillMaxSize()
.padding(8.dp)
.clip(RoundedCornerShape(16.dp))
.background(MaterialTheme.colorScheme.secondaryContainer)
// .background(MaterialTheme.colorScheme.secondaryContainer)
.graphicsLayer {
// Calculate the absolute offset for the current page from the
// scroll position. We use the absolute value which allows us to mirror
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter
import com.google.android.samples.socialite.ui.home.timeline.TimelineMediaItem

/**
* Created by Mayuri Khinvasara on 12/08/24.
* Wrapper class to manage all functionalities of preload manager of exoplayer especially for short form content
*/
@androidx.media3.common.util.UnstableApi
class PreloadManagerWrapper
private constructor(
private val defaultPreloadManager: DefaultPreloadManager,
) {
// Queue of media items to be preloaded. Can be ranked based on ranking data
private val preloadWindow: ArrayDeque<Pair<MediaItem, Int>> = ArrayDeque()

// Default window size for preload manager
private var preloadWindowMaxSize = 6
// Default window size for preload manager. This defines how many maximum items will be preloaded at a time. If more than maximum items are added to the preload window
private var preloadWindowMaxSize = 5

private var currentPlayingIndex = C.INDEX_UNSET

// List of all items in our current list of media items to be rendered on the UI
private var mediaItemsList = listOf<TimelineMediaItem>()

// Defines when to start preloading next items w.r.t current playing item
Expand Down

0 comments on commit b7204a9

Please sign in to comment.