Giter Site home page Giter Site logo

dsa28s / compose-video Goto Github PK

View Code? Open in Web Editor NEW
163.0 163.0 20.0 37.3 MB

Video UI Component for Jetpack Compose (Powered by androidx.media3)

Home Page: https://dsa28s.github.io/compose-video/

License: Apache License 2.0

Kotlin 100.00%
compose exoplayer jetpack player video

compose-video's Introduction

Hello!

πŸ€— I'm Dora Lee (@dsa28s), a 25 year old developer who wants to be as versatile as Doraemon!

πŸ‘¨β€πŸ’» I'm currently working at ModHaus as an

😘 There are so many things I want to do, so after work I usually work on my

  • side projects after work!
  • I enjoy drinking 🍻 beer, reading books, and catching up on YouTube.
  • I love to eat so much that I often go on restaurant hunts!

πŸ“š Currently, I'm studying

  • I'm learning Kotlin Native.
  • I'm trying to create my own interpreter language with rust.

πŸ‘‹ We talk together, we project together!

I love meeting new people, chatting with them, and working on projects together!

ν•œκ΅­μ–΄ 버전

Here is README_ko.md

compose-video's People

Contributors

dsa28s avatar itsallan avatar kangyee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

compose-video's Issues

Enter full screen reset player and track state

When screen rotates all jetpack compose components lose the remembers states.
Player is reset and in consequence video track is set on start by default.
Trying use:

  • android:configChanges="orientation|screenSize|layoutDirection" on manifest did not work
  • rememberSaveable only works with serializable objects

Dialog displays an error after attachBaseContext()

After override the context configuration to prevent font scaling and density scaling, the full screen dialog displays an error.

    override fun attachBaseContext(newBase: Context) {
        val resources = newBase.resources
        val overrideConfiguration = Configuration(resources.configuration)
            .apply {
                fontScale = 1.0f
                densityDpi = resources.displayMetrics.xdpi.toInt()
            }

        super.attachBaseContext(
            newBase.createConfigurationContext(overrideConfiguration)
        )
    }

Screenshot_20240304_185817

After set defaultPlayerView background to GRAY.

    DisposableEffect(
        AndroidView(
            modifier = modifier,
            factory = {
                defaultPlayerView.apply {
                    useController = usePlayerController
                    resizeMode = surfaceResizeMode.toPlayerViewResizeMode()
                    setBackgroundColor(Color.GRAY)
                }
            },
        ),
    ) {

Screenshot_20240304_190028

Play Multi Exoplayer

I want to know how to play multi-exoplayer like this picture
[explain]

  • one exoplayer is working well but the other one is stop
  • how to play at the same time each of them

hello

fun MultiPlayerScreen(){
  Column(){
    VideoScreen() // 1
    videoScreen() //2
  } 
}
-----------------------------------------------------------------------------------------------------------------------------------
const val MIME_TYPE_DASH = MimeTypes.APPLICATION_MPD
const val MIME_TYPE_HLS = MimeTypes.APPLICATION_M3U8
const val MIME_TYPE_VIDEO_MP4 = MimeTypes.VIDEO_MP4
@Composable
fun VideoScreen(
    onChangeView : () -> Unit,
    durationTime : Long = 8000L,
){
    val currentChangeView by rememberUpdatedState(newValue = onChangeView)
    var repeatMode by remember { mutableStateOf(RepeatMode.ALL) }

    val context = LocalContext.current

    LaunchedEffect(Unit){
        delay(durationTime)
        if(durationTime != 0L) currentChangeView()
    }
     VideoPlayer(
        mediaItems = listOf(
            VideoPlayerMediaItem.NetworkMediaItem(
                url = "https://html5demos.com/assets/dizzy.mp4",
                mediaMetadata = MediaMetadata.Builder().setTitle("Clear MP4: Dizzy").build(),
                mimeType = MIME_TYPE_VIDEO_MP4,
            )

        ),
        handleLifecycle = true,
        autoPlay = true,
        usePlayerController = true,
        enablePip = true,
        handleAudioFocus = true,
        controllerConfig = VideoPlayerControllerConfig.Default.copy(
            showSpeedAndPitchOverlay = false,
            showSubtitleButton = false,
            showCurrentTimeAndTotalTime = true,
            showBufferingProgress = false,
            showForwardIncrementButton = true,
            showBackwardIncrementButton = true,
            showBackTrackButton = true,
            showNextTrackButton = true,
            showRepeatModeButton = true,
            controllerShowTimeMilliSeconds = 5_000,
            controllerAutoShow = true,
            showFullScreenButton = false
        ),
        volume = 0.5f,  // volume 0.0f to 1.0f
        repeatMode = repeatMode,       // or RepeatMode.ALL, RepeatMode.ONE
        onCurrentTimeChanged = { // long type, current player time (millisec)
            Log.e("CurrentTime", it.toString())
        },
        playerInstance = { // ExoPlayer instance (Experimental)
            addAnalyticsListener(object : AnalyticsListener {
                @SuppressLint("UnsafeOptInUsageError")
                override fun onRepeatModeChanged(
                    eventTime: AnalyticsListener.EventTime,
                    rMode: Int,
                ) {
                    repeatMode = rMode.toRepeatMode()
                    Toast.makeText(
                        context,
                        "RepeatMode changed = ${rMode.toRepeatMode()}",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }

                @SuppressLint("UnsafeOptInUsageError")
                override fun onPlayWhenReadyChanged(
                    eventTime: AnalyticsListener.EventTime,
                    playWhenReady: Boolean,
                    reason: Int,
                ) {
                    Toast.makeText(
                        context,
                        "isPlaying = $playWhenReady",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }

                @SuppressLint("UnsafeOptInUsageError")
                override fun onVolumeChanged(
                    eventTime: AnalyticsListener.EventTime,
                    volume: Float,
                ) {
                    Toast.makeText(
                        context,
                        "Player volume changed = $volume",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }
                }
            )
        },
        modifier = Modifier
            .fillMaxSize()
//           .align(Alignment.Center),
    )
}

Having bottom paddings in fullScreenDilalog

When I open full screen it shows with bottom paddings:
(In my screen you can see some item and floating action button in full screen)

It's in default screen:

2024-02-09 11 12 38

And in full screen:

2024-02-09 11 12 35

black overlay

is there any way to hide video player back overlay before loading media item? (im using network media item)

OnMediaLoaded callback

I want to show loading spinner while the media is loading. For that I think I need a callback for media loaded.

Is it possible with the current api?

Samsung a series video overflow

Hello,

i have a problem,
actually i tried samsung j8, s23 or xiaomi devices and video normal on these devices but i tried galaxy a series (a73 and a34) and this problem occurred,
the problem is i select a video and video overflow, when once i tap the screen and the video size returns to normal?

What can i do?

kotlin multiplatform support

What if this library supports kotlin multiplatform?
I'am asking for your opinion on whether you are in favor of updating the library so that it can be used on Kotlin multiplatform.

Question regarding lifecycle

Hi! Nice extension.

I was experimenting with it and found that when using m3u8 network playback stream, the handleLifecycle=true paused playback properly when leaving the app, but never resumed it when coming back, resulting in back screen.

Not sure if it is a bug or a problem on my end. Perhaps it makes sense to be able to optionally create the exoplayer instance outside the library, for having more control over the instance? I'd assume then I would be able to use it to control playback with some custom logic.

Exit full screen UI offset

F7C32EFD26B7B5D1C6DE4CBC0BF430DA

When I exit from full screen state, the UI is offset and there is an empty space on the right side
ver: Android 9

Setting DataSource.Factory

Hi,

I really, really, like this library. Much much easier to use than the 400+ line ExoPlayer "getting started" demo.

I needed to use the OkHttp DataSource (to enable playing videos that a user has downloaded offline via an OkHttp interceptor I made).

The current function signatures don't allow setting the DataSource.Factory. I made a fork with an option for the HttpDataSource here:

https://github.com/UstadMobile/compose-video

Add argument:

httpDataSourceFactory: HttpDataSource.Factory = remember {
        DefaultHttpDataSource.Factory()
    },

Use it:

.apply {
                val cache = VideoPlayerCacheManager.getCache()
                if (cache != null) {
                    val cacheDataSourceFactory = CacheDataSource.Factory()
                        .setCache(cache)
                        .setUpstreamDataSourceFactory(DefaultDataSource.Factory(context, httpDataSourceFactory))
                    setMediaSourceFactory(DefaultMediaSourceFactory(cacheDataSourceFactory))
                } else {
                    setMediaSourceFactory(DefaultMediaSourceFactory(httpDataSourceFactory))
                }
            }

It's now working with OkHttpDataSource. I'm not sure if that is the most elegant API. Maybe accepting the DataSource.Factory itself would be an option?

I'm happy to tidy submit this into a pull request if that helps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.