Skip to content

Commit

Permalink
do some misc class documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Oct 22, 2024
1 parent 725c6c7 commit 3bff426
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerUIState

private const val TAG = "ActivityBrainSlug"

/**
* TODO: Remove this.
* This class should help for transitioning from and to fullscreen mode.
* However A user could also just subscribe to the [NewPlayerUIState]
* to check weather the UI is in fullscreen mode or not.
*/
class ActivityBrainSlug {

private val viewModel: InternalNewPlayerViewModel
Expand Down
19 changes: 16 additions & 3 deletions new-player/src/main/java/net/newpipe/newplayer/logic/TrackUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

package net.newpipe.newplayer.logic

import android.provider.MediaStore.Video
import android.util.Log
import android.util.Log
import androidx.annotation.OptIn
import androidx.media3.common.C
import androidx.media3.common.Tracks
Expand All @@ -33,6 +32,9 @@ import net.newpipe.newplayer.data.VideoStreamTrack

private const val TAG = "TrackUtils"

/**
* This provides several tools to handle [StreamTrack]s.
*/
object TrackUtils {

internal fun getAllAvailableTracksNonDuplicated(streams: List<Stream>): List<StreamTrack> {
Expand Down Expand Up @@ -136,6 +138,12 @@ object TrackUtils {
return false
}

/**
* You can filter for [StreamTrack]s by simply testing if a track equals the one
* you are looking for.
* However maybe you just want to filter tracks based on only some attributes.
* You can do this with this function.
*/
internal fun getStreamMatchingAudioTrack(
availableStreams: List<Stream>,
track: AudioStreamTrack,
Expand All @@ -147,7 +155,12 @@ object TrackUtils {
.filter{!matchBitrate || it.bitrate == track.bitrate}
.filter{!matchFileFormat || it.fileFormat == track.fileFormat}


/**
* You can filter for [StreamTrack]s by simply testing if a track equals the one
* you are looking for.
* However maybe you just want to filter tracks based on only some attributes.
* You can do this with this function.
*/
internal fun getStreamsMatchingVideoTrack(
availableStreams: List<Stream>,
track: VideoStreamTrack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.os.Bundle
import androidx.media3.session.CommandButton
import androidx.media3.session.SessionCommand
import net.newpipe.newplayer.R
import net.newpipe.newplayer.NewPlayerImpl

internal data class CustomCommand(
val action: String,
Expand All @@ -36,6 +37,12 @@ internal data class CustomCommand(
}
}

/**
* There could be more custom commands, other then just "Close".
* In order to match NewPipe's current implementation there could also be a mechanism for
* the [NewPlayerImpl] object that allows you to define which commands should be visible.
* This way the user can decide which additional commands should be shown.
*/
internal fun buildCustomCommandList(context: Context) = listOf(
CustomCommand(
CustomCommand.NEW_PLAYER_NOTIFICATION_COMMAND_CLOSE_PLAYBACK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ package net.newpipe.newplayer.uiModel
import android.content.pm.ActivityInfo
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import net.newpipe.newplayer.ui.NewPlayerUI

/**
* Restores the embedded mode UI config when returning from fullscreen
* This helps to restore properties of the UI/SystemUI when returning from fullscreen mode.
* [NewPlayerViewModelImpl] uses this to store the properties when switching to a fullscreen mode.
* When returning from a fullscreen mode [NewPlayerViewModelImpl] will store the current
* EmbeddedUiConfig in the [NewPlayerUIState]. When returning from fullscreen mode
* [NewPlayerUI] will then restore that configuration.
*
* TODO: At least in theory. Brightnes and the systembar theme don't work (correctly) right now.
*
*/
@Parcelize
data class EmbeddedUiConfig(
Expand Down

0 comments on commit 3bff426

Please sign in to comment.