Introducing Compose Multiplatform Media Player: Your Go-To Solution for Seamless Media Playback
Tags: android, ios, compose, composemultiplatform
Published: 2024-05-20 12:02:41

In today’s digital age, media consumption is an integral part of our lives. Whether it’s watching videos or browsing through reels, users expect a seamless and immersive experience. However, building a media player that works seamlessly across different platforms can be a daunting task. That’s where Compose Multiplatform Media Player comes to the rescue!

**What is Compose Multiplatform Media Player?**
Compose Multiplatform Media Player is a powerful media player library designed specifically for Compose Multiplatform projects. It provides developers with the tools they need to effortlessly integrate video playback and reel viewing into their applications, all while maintaining a consistent experience across both iOS and Android platforms.

## Key Features

**Cross-Platform Compatibility**
With Compose Multiplatform Media Player, you can rest assured that your media player will work flawlessly on both iOS and Android platforms within Compose Multiplatform projects. Say goodbye to platform-specific headaches and hello to a seamless development experience.

**Video Playback**
Easily incorporate video playback functionality into your app with high performance and reliability.

**Reel Viewing**
Experience reel viewing like never before with support for both horizontal and vertical scrolling. Whether your users prefer to swipe through content or scroll vertically, our media player ensures a smooth and intuitive experience.

**Customizable Controls**
Take control of your media player’s behavior with extensive customization options. Enable or disable pause/resume functionality, toggle the visibility of the seek bar, and display playback time duration according to your app’s requirements.

## Getting Started

Getting started with Compose Multiplatform Media Player is easy! Simply add the library as a dependency in your project’s `build.gradle.kts` file, and you’re good to go:

```
commonMain.dependencies {
   implementation("network.chaintech:compose-multiplatform-media-player:1.0.5")
}
```

Once you’ve added the dependency, you can start using the library’s composable functions to integrate video playback and reel viewing into your app:

```
// Video Playback
VideoPlayerView(
 modifier = Modifier.fillMaxSize(),
 url = videoUrl
)

// Reel Viewing
ReelsPlayerView(
 modifier = Modifier.fillMaxSize(),
 urls = videoUrlArray
)
```

**Customization Options**
Our media player library offers a wide range of customization options to suit your app’s needs:

- `modifier`: Modify the layout and appearance of the media player.
- `url`: Provide the URL of the video to be played.
- `urls`: Pass an array of URLs for reel viewing.
- `playerConfig`: You can configure various aspects of the player appearance and behavior.

- `enablePauseResume`: Enable or disable pause/resume functionality.
- `showSeekBar`: Toggle the visibility of the seek bar.
- `showDuration`: Control the display of playback time duration.
- `thumbColor`: Customize color of the seek bar thumb.
- `activeTrackColor`: Customize the color of the seek bar’s active track, representing the portion of the media content that has already been played.
- `inactiveTrackColor`: Customize the color of the seek bar’s inactive track, representing the remaining portion of the media content yet to be played.
- `textColor`: Customization of the color of the duration text displayed alongside the seek bar.
- `seekBarBottomPadding`: Allows configuring the bottom padding for the seek bar control, ensuring proper alignment within the UI layout.
- `playIcon` & pauseIcon: Customize the play and pause button icons.
- `reelVerticalScrolling`: Manage vertical and horizontal scrolling in reel viewing.
- `autoHideControl` & controlHideInterval: Enable the automatic hiding of controls after a specified time interval, enhancing user experience by reducing clutter on the interface when controls are not in use.

![MediaPlayer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kysxy7jvvv07oxyzbbqt.png)
```
VideoPlayerView(modifier = Modifier.fillMaxSize(),
                url = videoUrl,
                playerConfig = PlayerConfig(
                    enablePauseResume = true,
                    showSeekBar = true,
                    showDuration = true,
                    thumbColor = Color.Red,
                    activeTrackColor = Color.Red,
                    inactiveTrackColor = Color.White,
                    textColor = Color.White,
                    seekBarBottomPadding = 10.dp,
                    playIcon = Res.drawable.icn_play,
                    pauseIcon = Res.drawable.icn_pause,
                    pauseResumeIconSize = 40.dp,
                    autoHideControl = true,
                    controlHideInterval = 5
                )
            )
```

```
VideoPlayerView(modifier = Modifier.fillMaxSize(),
                url = videoUrl,
                playerConfig = PlayerConfig(
                    enablePauseResume = false,
                    showSeekBar = false,
                    showDuration = false
                )
            )
```

![Reels](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y075hmmm8doqjxfes5wy.png)
```
ReelsPlayerView(modifier = Modifier.fillMaxSize(),
                url = videoUrlArray,
                playerConfig = PlayerConfig(
                    enablePauseResume = true,
                    showSeekBar = true,
                    reelVerticalScrolling = true
                )
            )
```

```
ReelsPlayerView(modifier = Modifier.fillMaxSize(),
                url = videoUrlArray,
                playerConfig = PlayerConfig(
                    enablePauseResume = false,
                    showSeekBar = false,
                    reelVerticalScrolling = false
                )
            )
```

## Conclusion
With Compose Multiplatform Media Player, building a seamless media playback experience for your app has never been easier. Whether you’re a seasoned developer or just getting started with Compose Multiplatform, our library empowers you to create engaging and immersive media experiences that delight your users.
So why wait? Give Compose Multiplatform Media Player a try today and take your app’s media playback to the next level!

> https://github.com/ChainTechNetwork/ComposeMultiplatformMediaPlayer.git

Happy coding ❤

Connect with us 👇

- [Linkedin](https://www.linkedin.com/showcase/mobile-innovation-network)

- [GitHub](https://github.com/ChainTechNetwork)