Skip to content

Commit

Permalink
restructure code
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Oct 15, 2024
1 parent a7bb30d commit bef09f7
Show file tree
Hide file tree
Showing 51 changed files with 171 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModel

private const val TAG = "ActivityBrainSlug"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import android.graphics.Bitmap
import androidx.media3.common.MediaMetadata
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.datasource.HttpDataSource
import net.newpipe.newplayer.utils.Chapter
import net.newpipe.newplayer.utils.Stream
import net.newpipe.newplayer.utils.Subtitle
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.Subtitle

data class RepoMetaInfo(
val canHandleTimestampedLinks: Boolean,
Expand Down
8 changes: 4 additions & 4 deletions new-player/src/main/java/net/newpipe/newplayer/NewPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import androidx.media3.common.Player
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import net.newpipe.newplayer.utils.Chapter
import net.newpipe.newplayer.utils.LanguageIdentifier
import net.newpipe.newplayer.utils.Stream
import net.newpipe.newplayer.utils.StreamTrack
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.LanguageIdentifier
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.StreamTrack
import kotlin.Exception

enum class PlayMode {
Expand Down
24 changes: 12 additions & 12 deletions new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import net.newpipe.newplayer.service.NewPlayerService
import net.newpipe.newplayer.utils.ActionResponse
import net.newpipe.newplayer.utils.Chapter
import net.newpipe.newplayer.utils.LanguageIdentifier
import net.newpipe.newplayer.utils.MediaSourceBuilder
import net.newpipe.newplayer.utils.NewPlayerException
import net.newpipe.newplayer.utils.NoResponse
import net.newpipe.newplayer.utils.Stream
import net.newpipe.newplayer.utils.StreamExceptionResponse
import net.newpipe.newplayer.utils.StreamSelection
import net.newpipe.newplayer.utils.StreamSelectionResponse
import net.newpipe.newplayer.utils.StreamTrack
import net.newpipe.newplayer.utils.StreamSelector
import net.newpipe.newplayer.logic.ActionResponse
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.LanguageIdentifier
import net.newpipe.newplayer.logic.MediaSourceBuilder
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.logic.NoResponse
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.logic.StreamExceptionResponse
import net.newpipe.newplayer.data.StreamSelection
import net.newpipe.newplayer.logic.StreamSelectionResponse
import net.newpipe.newplayer.data.StreamTrack
import net.newpipe.newplayer.logic.StreamSelector
import kotlin.random.Random

private const val TAG = "NewPlayerImpl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import android.widget.FrameLayout
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import dagger.hilt.android.AndroidEntryPoint
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModel
import net.newpipe.newplayer.ui.NewPlayerUI
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.utils.NewPlayerException
import net.newpipe.newplayer.data.NewPlayerException

@AndroidEntryPoint
class NewPlayerView : FrameLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

import android.net.Uri

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

import android.content.res.Resources
import net.newpipe.newplayer.R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

class NewPlayerException : Exception {
constructor(message: String) : super(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

import android.net.Uri

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils

import net.newpipe.newplayer.utils.Stream
package net.newpipe.newplayer.data

interface StreamSelection {
val item: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

interface StreamTrack : Comparable<StreamTrack> {
val fileFormat: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

import android.net.Uri

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/


package net.newpipe.newplayer.utils
package net.newpipe.newplayer.data

internal data class VideoSize(
val width: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.logic

import androidx.annotation.OptIn
import androidx.media3.common.MediaItem
Expand All @@ -30,6 +30,11 @@ import androidx.media3.exoplayer.source.MergingMediaSource
import androidx.media3.exoplayer.source.ProgressiveMediaSource
import kotlinx.coroutines.flow.MutableSharedFlow
import net.newpipe.newplayer.MediaRepository
import net.newpipe.newplayer.data.MultiSelection
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.data.SingleSelection
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.StreamSelection

@OptIn(UnstableApi::class)
internal class MediaSourceBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils;
package net.newpipe.newplayer.logic;

import net.newpipe.newplayer.NewPlayer
import net.newpipe.newplayer.data.StreamSelection

interface StreamExceptionResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils

import net.newpipe.newplayer.utils.TrackUtils.getDynamicStreams
import net.newpipe.newplayer.utils.TrackUtils.hasVideoStreams
import net.newpipe.newplayer.utils.TrackUtils.tryAndGetMedianAudioOnlyStream
import net.newpipe.newplayer.utils.TrackUtils.tryAndGetMedianCombinedVideoAndAudioStream
import net.newpipe.newplayer.utils.TrackUtils.tryAndGetMedianVideoOnlyStream
package net.newpipe.newplayer.logic

import net.newpipe.newplayer.data.LanguageIdentifier
import net.newpipe.newplayer.data.MultiSelection
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.data.SingleSelection
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.StreamSelection
import net.newpipe.newplayer.logic.TrackUtils.getDynamicStreams
import net.newpipe.newplayer.logic.TrackUtils.hasVideoStreams
import net.newpipe.newplayer.logic.TrackUtils.tryAndGetMedianAudioOnlyStream
import net.newpipe.newplayer.logic.TrackUtils.tryAndGetMedianCombinedVideoAndAudioStream
import net.newpipe.newplayer.logic.TrackUtils.tryAndGetMedianVideoOnlyStream

internal class StreamSelector(
val preferredLanguages: List<LanguageIdentifier>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/

package net.newpipe.newplayer.utils
package net.newpipe.newplayer.logic

import net.newpipe.newplayer.data.AudioStreamTrack
import net.newpipe.newplayer.data.LanguageIdentifier
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.StreamTrack

object TrackUtils {

Expand Down
10 changes: 5 additions & 5 deletions new-player/src/main/java/net/newpipe/newplayer/ui/NewPlayerUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat

import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.utils.NewPlayerException
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.uiModel.UIModeState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModelDummy
import net.newpipe.newplayer.ui.audioplayer.AudioPlayerUI
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.videoplayer.VideoPlayerUi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModelDummy
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme

@androidx.annotation.OptIn(UnstableApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.EmbeddedUiConfig
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.uiModel.EmbeddedUiConfig
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModelDummy
import net.newpipe.newplayer.uiModel.UIModeState
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.videoplayer.CONTROLLER_UI_BACKGROUND_COLOR
import net.newpipe.newplayer.ui.videoplayer.PreviewBackgroundSurface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModelDummy
import net.newpipe.newplayer.uiModel.UIModeState
import net.newpipe.newplayer.ui.common.NewPlayerSeeker
import net.newpipe.newplayer.ui.common.ThumbPreview
import net.newpipe.newplayer.ui.selection_ui.ChapterSelectUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.EmbeddedUiConfig
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.uiModel.EmbeddedUiConfig
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerViewModelDummy
import net.newpipe.newplayer.uiModel.UIModeState
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.videoplayer.pip.supportsPip
import net.newpipe.newplayer.ui.common.getEmbeddedUiConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.utils.Chapter
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel
import net.newpipe.newplayer.ui.seeker.ChapterSegment
import net.newpipe.newplayer.ui.seeker.DefaultSeekerColor
import net.newpipe.newplayer.ui.seeker.Seeker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import androidx.compose.ui.res.stringResource
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.RepeatMode
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.InternalNewPlayerViewModel
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.uiModel.InternalNewPlayerViewModel

@OptIn(UnstableApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Slider
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -59,16 +57,14 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.core.content.res.ResourcesCompat
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.uiModel.NewPlayerUIState
import net.newpipe.newplayer.ui.seeker.SeekerDefaults
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ import androidx.core.view.WindowCompat
import androidx.media3.common.MediaItem
import androidx.media3.common.util.UnstableApi
import coil.compose.AsyncImage
import net.newpipe.newplayer.utils.NewPlayerException
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.EmbeddedUiConfig
import net.newpipe.newplayer.uiModel.EmbeddedUiConfig
import java.util.Locale

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import net.newpipe.newplayer.utils.Chapter
import net.newpipe.newplayer.utils.NewPlayerException
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.NewPlayerException
import net.newpipe.newplayer.R
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.common.Thumbnail
Expand Down
Loading

0 comments on commit bef09f7

Please sign in to comment.