KhubaibKhan4 / MediaPlayer-KMP

MediaPlayer-KMP is a Kotlin Multiplatform (KMP) library that allows you to display and play YouTube videos across Android, iOS, Web, and Desktop platforms using JetBrains Compose Multiplatform. It provides a unified API for video playback that seamlessly integrates into Kotlin's multiplatform ecosystem.
GNU General Public License v2.0
116 stars 8 forks source link
android-application compose-multiplatform-library kmp-library kotlin-multiplatform kotlin-multiplatform-library kotlin-multiplatform-mobile media-player media-player-kmp

MediaPlayer-KMP

Maven Central GitHub License GitHub Issues GitHub Pull Requests GitHub Last Commit GitHub Stars

Supported Platforms Supported Platforms Supported Platforms Supported Platforms Supported Platforms

Untitledvideo-MadewithClipchamp57-ezgif com-video-to-gif-converter

Overview

MediaPlayer-KMP is a Kotlin Multiplatform (KMP) library that allows you to display and play YouTube videos across Android, iOS, Web, and Desktop platforms using JetBrains Compose Multiplatform. It provides a unified API for video playback that seamlessly integrates into Kotlin's multiplatform ecosystem.

Features

Future Plans

Installation

You can include MediaPlayer-KMP in your project by adding the following dependency:

Version Catelog

[versions]
mediaPlayerKMP = "2.0.4"

[libraries]
alert-kmp = { module = "io.github.khubaibkhan4:mediaplayer-kmp", version.ref = "mediaPlayerKMP" }
implementation("io.github.khubaibkhan4:mediaplayer-kmp:2.0.4")

Usage

YouTube Video Player

For the YouTube Player, you just need to provide the youtube video link. It will automatically detect it & will launch the YouTube Player.

import io.github.khubaibkhan4.mediaplayer.VideoPlayer

fun main() {
   VideoPlayer(modifier = Modifier.fillMaxWidth().height(340.dp),
               url ="https://www.youtube.com/watch?v=AD2nEllUMJw", // Automatically Detect the URL, Wether to Play YouTube Video or .mp4 e.g
     )
}

Video Player

For the YouTube Player, you just need to provide the youtube video link. It will automatically detect it & will launch the YouTube Player. It almost supports all the video extensions.

import io.github.khubaibkhan4.mediaplayer.VideoPlayer

fun main() {
   VideoPlayer(modifier = Modifier.fillMaxWidth().height(340.dp),
               url ="https://freetestdata.com/wp-content/uploads/2022/02/Free_Test_Data_1MB_MP4.mp4", // Automatically Detect the URL, Wether to Play YouTube Video or .mp4 e.g
     )
}

Audio Player Support

Audio Player Support is Implemented. It supports mp3 wav aac ogg m4a. It Supports Play Back, Volume Up, Down and Stability as well.

import io.github.khubaibkhan4.mediaplayer.VideoPlayer

fun main() {
    MediaPlayer(
        modifier = Modifier.fillMaxWidth(),
        url = "https://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3",
        startTime = Color.Black,
        endTime = Color.Black,
        volumeIconColor = Color.Black,
        playIconColor = Color.Blue,
        sliderTrackColor = Color.LightGray,
        sliderIndicatorColor = Color.Blue
    )
}

Future Plans

🤝 Connect with Me

Let's chat about potential projects, job opportunities, or any other collaboration! Feel free to connect with me through the following channels:

LinkedIn Twitter Email

💰 You can help me by Donating

BuyMeACoffee PayPal Patreon Ko-Fi

Screenshots

Screenshot 1 Screenshot 2 Screenshot 3
Screenshot 2 Screenshot_20240710_153958
Screenshot 1
Screenshot 2
Screenshot 2024-07-10 153852
Screenshot 2024-07-10 153944

Demo

https://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/657ad29d-5129-4f78-af56-ad354ba0935d

Desktop Demo

https://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/efd68685-2f41-4445-ad76-c183869ab93a

Star History

Star History Chart

Stargazers

Stargazers repo roster for @KhubaibKhan4/MediaPlayer-KMP

Forkers

Forkers repo roster for @KhubaibKhan4/MediaPlayer-KMP

Contribution Guidelines

We welcome contributions to the MediaPlayer-KMP Library Project! To contribute, please follow these guidelines:

Code of Conduct

We expect all contributors and users of the Alert-KMP Library Project to adhere to our code of conduct. Please review the Code of Conduct for details on expected behavior and reporting procedures.