├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── misc.xml └── vcs.xml ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample_app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── composeplayersample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── composeplayersample │ │ │ ├── MainActivity.kt │ │ │ └── ui │ │ │ └── theme │ │ │ ├── Color.kt │ │ │ ├── Shape.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ └── network_security_config.xml │ └── test │ └── java │ └── com │ └── example │ └── composeplayersample │ └── ExampleUnitTest.kt ├── settings.gradle └── videoplayer ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── imherrera │ └── videoplayer │ └── ExampleInstrumentedTest.kt ├── main ├── AndroidManifest.xml └── java │ └── com │ └── imherrera │ └── videoplayer │ ├── Utils.kt │ ├── VideoPlayer.kt │ ├── VideoPlayerControl.kt │ ├── VideoPlayerState.kt │ └── icons │ ├── Forward10.kt │ ├── Fullscreen.kt │ ├── FullscreenExit.kt │ ├── MoreVert.kt │ ├── Pause.kt │ ├── PlayArrow.kt │ ├── Replay10.kt │ ├── SkipNext.kt │ └── SkipPrevious.kt └── test └── java └── com └── imherrera └── videoplayer └── ExampleUnitTest.kt /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compose Video Player 2 | Video player for Android Compose powered by ExoPlayer. 3 | 4 | ## Adding Dependency 5 | 6 | * Add the JitPack repository to your build file in your root build.gradle at the end of repositories: 7 | ```groovy 8 | allprojects { 9 | repositories { 10 | ... 11 | maven { url 'https://jitpack.io' } 12 | } 13 | } 14 | ``` 15 | 16 | * Add the dependency 17 | ```groovy 18 | dependencies { 19 | implementation 'com.github.imherrera:compose-video-player:0.1.0-alpha' 20 | } 21 | ``` 22 | 23 | ## Basic Usage 24 | 25 | The basic usage is as follows: 26 | 27 | ```kotlin 28 | val playerState = rememberVideoPlayerState() 29 | 30 | VideoPlayer(playerState = playerState) { 31 | VideoPlayerControl( 32 | state = playerState, 33 | title = "Elephant Dream", 34 | ) 35 | } 36 | 37 | LaunchedEffect(Unit) { 38 | playerState.player.setMediaItem(MediaItem.fromUri("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4")) 39 | playerState.player.prepare() 40 | playerState.player.playWhenReady = true 41 | } 42 | ``` 43 | 44 | This will display the video in your Compose layout that shows the video provided. 45 | For fullscreen example you can take a look at [SampleActivity](sample_app/src/main/java/com/example/composeplayersample/MainActivity.kt) 46 | 47 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | compose_version = '1.2.0-alpha02' 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | maven { url 'https://jitpack.io' } 9 | } 10 | }// Top-level build file where you can add configuration options common to all sub-projects/modules. 11 | plugins { 12 | id 'com.android.application' version '7.1.0' apply false 13 | id 'com.android.library' version '7.1.0' apply false 14 | id 'org.jetbrains.kotlin.android' version '1.6.10' apply false 15 | } 16 | 17 | task clean(type: Delete) { 18 | delete rootProject.buildDir 19 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Feb 01 12:02:35 PYST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /sample_app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /sample_app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | applicationId "com.example.composeplayersample" 11 | minSdk 21 12 | targetSdk 31 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | vectorDrawables { 18 | useSupportLibrary true 19 | } 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | compileOptions { 29 | sourceCompatibility JavaVersion.VERSION_1_8 30 | targetCompatibility JavaVersion.VERSION_1_8 31 | } 32 | kotlinOptions { 33 | jvmTarget = '1.8' 34 | } 35 | buildFeatures { 36 | compose true 37 | } 38 | composeOptions { 39 | kotlinCompilerExtensionVersion compose_version 40 | } 41 | packagingOptions { 42 | resources { 43 | excludes += '/META-INF/{AL2.0,LGPL2.1}' 44 | } 45 | } 46 | } 47 | 48 | dependencies { 49 | debugImplementation('com.squareup.leakcanary:leakcanary-android:2.8.1') 50 | implementation 'androidx.core:core-ktx:1.7.0' 51 | implementation "androidx.compose.ui:ui:$compose_version" 52 | implementation "androidx.compose.material:material:$compose_version" 53 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" 54 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0' 55 | implementation 'androidx.activity:activity-compose:1.4.0' 56 | testImplementation 'junit:junit:4.13.2' 57 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 58 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 59 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" 60 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" 61 | implementation project(':videoplayer') 62 | } -------------------------------------------------------------------------------- /sample_app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /sample_app/src/androidTest/java/com/example/composeplayersample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.composeplayersample", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /sample_app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sample_app/src/main/java/com/example/composeplayersample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample 2 | 3 | import android.os.Bundle 4 | import android.view.View 5 | import androidx.activity.ComponentActivity 6 | import androidx.activity.compose.setContent 7 | import androidx.compose.foundation.background 8 | import androidx.compose.foundation.layout.fillMaxSize 9 | import androidx.compose.foundation.layout.fillMaxWidth 10 | import androidx.compose.foundation.layout.height 11 | import androidx.compose.runtime.LaunchedEffect 12 | import androidx.compose.ui.Modifier 13 | import androidx.compose.ui.graphics.Color 14 | import androidx.compose.ui.platform.LocalView 15 | import androidx.compose.ui.unit.dp 16 | import androidx.core.view.ViewCompat 17 | import androidx.core.view.WindowInsetsCompat 18 | import androidx.core.view.WindowInsetsControllerCompat 19 | import com.example.composeplayersample.ui.theme.ComposePlayerSampleTheme 20 | import com.google.android.exoplayer2.MediaItem 21 | import com.imherrera.videoplayer.VideoPlayer 22 | import com.imherrera.videoplayer.rememberVideoPlayerState 23 | import com.imherrera.videoplayer.VideoPlayerControl 24 | 25 | class MainActivity : ComponentActivity() { 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | setContent { 29 | ComposePlayerSampleTheme { 30 | val playerState = rememberVideoPlayerState() 31 | 32 | VideoPlayer( 33 | modifier = Modifier 34 | .background(Color.Black) 35 | .adaptiveSize(playerState.isFullscreen.value, LocalView.current), 36 | playerState = playerState, 37 | ) { 38 | /** 39 | * Use default control or implement your own 40 | * */ 41 | VideoPlayerControl( 42 | state = playerState, 43 | title = "Elephant Dream", 44 | subtitle = "By Blender Foundation", 45 | ) 46 | } 47 | 48 | LaunchedEffect(Unit) { 49 | playerState.player.setMediaItem(MediaItem.fromUri("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4")) 50 | playerState.player.prepare() 51 | playerState.player.playWhenReady = true 52 | } 53 | } 54 | } 55 | } 56 | } 57 | 58 | private fun Modifier.adaptiveSize(fullscreen: Boolean, view: View): Modifier { 59 | return if (fullscreen) { 60 | hideSystemBars(view) 61 | fillMaxSize() 62 | } else { 63 | showSystemBars(view) 64 | fillMaxWidth().height(250.dp) 65 | } 66 | } 67 | 68 | 69 | private fun hideSystemBars(view: View) { 70 | val windowInsetsController = ViewCompat.getWindowInsetsController(view) ?: return 71 | // Configure the behavior of the hidden system bars 72 | windowInsetsController.systemBarsBehavior = 73 | WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE 74 | // Hide both the status bar and the navigation bar 75 | windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) 76 | } 77 | 78 | private fun showSystemBars(view: View) { 79 | val windowInsetsController = ViewCompat.getWindowInsetsController(view) ?: return 80 | // Show both the status bar and the navigation bar 81 | windowInsetsController.show(WindowInsetsCompat.Type.systemBars()) 82 | } -------------------------------------------------------------------------------- /sample_app/src/main/java/com/example/composeplayersample/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple200 = Color(0xFFBB86FC) 6 | val Purple500 = Color(0xFF6200EE) 7 | val Purple700 = Color(0xFF3700B3) 8 | val Teal200 = Color(0xFF03DAC5) -------------------------------------------------------------------------------- /sample_app/src/main/java/com/example/composeplayersample/ui/theme/Shape.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample.ui.theme 2 | 3 | import androidx.compose.foundation.shape.RoundedCornerShape 4 | import androidx.compose.material.Shapes 5 | import androidx.compose.ui.unit.dp 6 | 7 | val Shapes = Shapes( 8 | small = RoundedCornerShape(4.dp), 9 | medium = RoundedCornerShape(4.dp), 10 | large = RoundedCornerShape(0.dp) 11 | ) -------------------------------------------------------------------------------- /sample_app/src/main/java/com/example/composeplayersample/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample.ui.theme 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.material.MaterialTheme 5 | import androidx.compose.material.darkColors 6 | import androidx.compose.material.lightColors 7 | import androidx.compose.runtime.Composable 8 | 9 | private val DarkColorPalette = darkColors( 10 | primary = Purple200, 11 | primaryVariant = Purple700, 12 | secondary = Teal200 13 | ) 14 | 15 | private val LightColorPalette = lightColors( 16 | primary = Purple500, 17 | primaryVariant = Purple700, 18 | secondary = Teal200 19 | 20 | /* Other default colors to override 21 | background = Color.White, 22 | surface = Color.White, 23 | onPrimary = Color.White, 24 | onSecondary = Color.Black, 25 | onBackground = Color.Black, 26 | onSurface = Color.Black, 27 | */ 28 | ) 29 | 30 | @Composable 31 | fun ComposePlayerSampleTheme( 32 | darkTheme: Boolean = isSystemInDarkTheme(), 33 | content: @Composable () -> Unit 34 | ) { 35 | val colors = if (darkTheme) { 36 | DarkColorPalette 37 | } else { 38 | LightColorPalette 39 | } 40 | 41 | MaterialTheme( 42 | colors = colors, 43 | typography = Typography, 44 | shapes = Shapes, 45 | content = content 46 | ) 47 | } -------------------------------------------------------------------------------- /sample_app/src/main/java/com/example/composeplayersample/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample.ui.theme 2 | 3 | import androidx.compose.material.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | body1 = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp 15 | ) 16 | /* Other default text styles to override 17 | button = TextStyle( 18 | fontFamily = FontFamily.Default, 19 | fontWeight = FontWeight.W500, 20 | fontSize = 14.sp 21 | ), 22 | caption = TextStyle( 23 | fontFamily = FontFamily.Default, 24 | fontWeight = FontWeight.Normal, 25 | fontSize = 12.sp 26 | ) 27 | */ 28 | ) -------------------------------------------------------------------------------- /sample_app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /sample_app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/sample_app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample_app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /sample_app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ComposePlayerSample 3 | -------------------------------------------------------------------------------- /sample_app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /sample_app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample_app/src/test/java/com/example/composeplayersample/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.composeplayersample 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "ComposePlayerSample" 16 | include ':sample_app' 17 | include ':videoplayer' 18 | -------------------------------------------------------------------------------- /videoplayer/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /videoplayer/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'org.jetbrains.kotlin.android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | minSdk 21 11 | targetSdk 31 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | kotlinOptions { 28 | jvmTarget = '1.8' 29 | } 30 | buildFeatures { 31 | compose true 32 | } 33 | composeOptions { 34 | kotlinCompilerExtensionVersion compose_version 35 | } 36 | } 37 | 38 | dependencies { 39 | def compose_version = "1.2.0-alpha02" 40 | implementation("androidx.compose.ui:ui:$compose_version") 41 | implementation("androidx.compose.material:material:$compose_version") 42 | implementation api("com.google.android.exoplayer:exoplayer-core:2.16.1") 43 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") 44 | } -------------------------------------------------------------------------------- /videoplayer/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imherrera/compose-video-player/1fddb586f2a0bfb25f6448d5cf3a8aae5342d604/videoplayer/consumer-rules.pro -------------------------------------------------------------------------------- /videoplayer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /videoplayer/src/androidTest/java/com/imherrera/videoplayer/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.imherrera.compose_video_player.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /videoplayer/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/Utils.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("NOTHING_TO_INLINE") 2 | 3 | package com.imherrera.videoplayer 4 | 5 | import android.widget.FrameLayout 6 | import androidx.compose.ui.unit.Constraints 7 | import com.google.android.exoplayer2.video.VideoSize 8 | import kotlin.time.Duration 9 | import kotlin.time.Duration.Companion.minutes 10 | 11 | internal inline fun VideoSize.aspectRatio(): Float = 12 | if (height == 0 || width == 0) 0f else (width * pixelWidthHeightRatio) / height 13 | 14 | /** 15 | * The [FrameLayout] will not resize itself if the fractional difference between its natural 16 | * aspect ratio and the requested aspect ratio falls below this threshold. 17 | * 18 | * 19 | * This tolerance allows the view to occupy the whole of the screen when the requested aspect 20 | * ratio is very close, but not exactly equal to, the aspect ratio of the screen. This may reduce 21 | * the number of view layers that need to be composited by the underlying system, which can help 22 | * to reduce power consumption. 23 | */ 24 | private const val MAX_ASPECT_RATIO_DIFFERENCE_FRACTION = 0.01f 25 | 26 | internal inline fun Constraints.resizeForVideo( 27 | mode: ResizeMode, 28 | aspectRatio: Float 29 | ): Constraints { 30 | if (aspectRatio <= 0f) return this 31 | 32 | var width = maxWidth 33 | var height = maxHeight 34 | val constraintAspectRatio: Float = (width / height).toFloat() 35 | val difference = aspectRatio / constraintAspectRatio - 1 36 | 37 | if (kotlin.math.abs(difference) <= MAX_ASPECT_RATIO_DIFFERENCE_FRACTION) { 38 | // TODO: ? 39 | return this 40 | } 41 | 42 | when (mode) { 43 | ResizeMode.Fit -> { 44 | if (difference > 0) { 45 | height = (width / aspectRatio).toInt() 46 | } else { 47 | width = (height * aspectRatio).toInt() 48 | } 49 | } 50 | ResizeMode.Zoom -> { 51 | if (difference > 0) { 52 | width = (height * aspectRatio).toInt() 53 | } else { 54 | height = (width / aspectRatio).toInt() 55 | } 56 | } 57 | ResizeMode.FixedWidth -> { 58 | height = (width / aspectRatio).toInt() 59 | } 60 | ResizeMode.FixedHeight -> { 61 | width = (height * aspectRatio).toInt() 62 | } 63 | ResizeMode.Fill -> Unit 64 | } 65 | 66 | return this.copy(maxWidth = width, maxHeight = height) 67 | } 68 | 69 | 70 | /** 71 | * Will return a timestamp denoting the current video [position] and the [duration] in the following 72 | * format "mm:ss / mm:ss" 73 | * **/ 74 | internal inline fun prettyVideoTimestamp( 75 | duration: Duration, 76 | position: Duration 77 | ): String = buildString { 78 | appendMinutesAndSeconds(duration) 79 | append(" / ") 80 | appendMinutesAndSeconds(position) 81 | } 82 | 83 | /** 84 | * Will split [duration] in minutes and seconds and append it to [this] in the following format "mm:ss" 85 | * */ 86 | private fun StringBuilder.appendMinutesAndSeconds(duration: Duration) { 87 | val minutes = duration.inWholeMinutes 88 | val seconds = (duration - minutes.minutes).inWholeSeconds 89 | appendDoubleDigit(minutes) 90 | append(':') 91 | appendDoubleDigit(seconds) 92 | } 93 | 94 | /** 95 | * Will append [value] as double digit to [this]. 96 | * If a single digit value is passed, ex: 4 then a 0 will be added as prefix resulting in 04 97 | * */ 98 | private fun StringBuilder.appendDoubleDigit(value: Long) { 99 | if (value < 10) { 100 | append(0) 101 | append(value) 102 | } else { 103 | append(value) 104 | } 105 | } -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/VideoPlayer.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer 2 | 3 | import android.os.Build 4 | import android.view.SurfaceView 5 | import android.view.ViewGroup 6 | import androidx.compose.animation.AnimatedVisibility 7 | import androidx.compose.animation.fadeIn 8 | import androidx.compose.animation.fadeOut 9 | import androidx.compose.foundation.gestures.detectTapGestures 10 | import androidx.compose.foundation.layout.Box 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.runtime.DisposableEffect 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.input.pointer.pointerInput 15 | import androidx.compose.ui.layout.layout 16 | import androidx.compose.ui.platform.LocalLifecycleOwner 17 | import androidx.compose.ui.viewinterop.AndroidView 18 | import androidx.lifecycle.Lifecycle 19 | import androidx.lifecycle.LifecycleEventObserver 20 | import androidx.lifecycle.LifecycleOwner 21 | 22 | @JvmInline 23 | value class ResizeMode private constructor(val value: Int) { 24 | companion object { 25 | val Fit = ResizeMode(0) 26 | val FixedWidth = ResizeMode(1) 27 | val FixedHeight = ResizeMode(2) 28 | val Fill = ResizeMode(3) 29 | val Zoom = ResizeMode(4) 30 | } 31 | } 32 | 33 | private fun Modifier.adaptiveLayout( 34 | aspectRatio: Float, 35 | resizeMode: ResizeMode = ResizeMode.Fit 36 | ) = layout { measurable, constraints -> 37 | val resizedConstraint = constraints.resizeForVideo(resizeMode, aspectRatio) 38 | val placeable = measurable.measure(resizedConstraint) 39 | layout(constraints.maxWidth, constraints.maxHeight) { 40 | // Center x and y axis relative to the layout 41 | placeable.placeRelative( 42 | x = (constraints.maxWidth - resizedConstraint.maxWidth) / 2, 43 | y = (constraints.maxHeight - resizedConstraint.maxHeight) / 2 44 | ) 45 | } 46 | } 47 | 48 | private fun Modifier.defaultPlayerTapGestures(playerState: VideoPlayerState) = pointerInput(Unit) { 49 | detectTapGestures( 50 | onDoubleTap = { 51 | if (playerState.videoResizeMode.value == ResizeMode.Zoom) { 52 | playerState.control.setVideoResize(ResizeMode.Fit) 53 | } else { 54 | playerState.control.setVideoResize(ResizeMode.Zoom) 55 | } 56 | }, 57 | onTap = { 58 | if (playerState.isControlUiVisible.value) { 59 | playerState.hideControlUi() 60 | } else { 61 | playerState.showControlUi() 62 | } 63 | } 64 | ) 65 | } 66 | 67 | @Composable 68 | private fun VideoPlayer( 69 | modifier: Modifier, 70 | playerState: VideoPlayerState, 71 | controller: @Composable () -> Unit 72 | ) { 73 | Box(modifier = modifier.defaultPlayerTapGestures(playerState)) { 74 | AndroidView( 75 | modifier = Modifier.adaptiveLayout( 76 | aspectRatio = playerState.videoSize.value.aspectRatio(), 77 | resizeMode = playerState.videoResizeMode.value 78 | ), 79 | factory = { context -> 80 | SurfaceView(context).apply { 81 | layoutParams = ViewGroup.LayoutParams( 82 | ViewGroup.LayoutParams.MATCH_PARENT, 83 | ViewGroup.LayoutParams.MATCH_PARENT 84 | ) 85 | }.also { 86 | playerState.player.setVideoSurfaceView(it) 87 | } 88 | } 89 | ) 90 | 91 | AnimatedVisibility( 92 | visible = playerState.isControlUiVisible.value, 93 | enter = fadeIn(), 94 | exit = fadeOut() 95 | ) { 96 | controller() 97 | } 98 | } 99 | } 100 | 101 | /** 102 | * @param playerState state to attach to this composable. 103 | * @param lifecycleOwner required to manage the ExoPlayer instance. 104 | * @param controller you can use [VideoPlayerControl] or alternatively implement your own 105 | * */ 106 | @Composable 107 | fun VideoPlayer( 108 | modifier: Modifier = Modifier, 109 | playerState: VideoPlayerState, 110 | lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, 111 | controller: @Composable () -> Unit, 112 | ) { 113 | VideoPlayer( 114 | modifier = modifier, 115 | playerState = playerState, 116 | controller = controller 117 | ) 118 | 119 | DisposableEffect(lifecycleOwner) { 120 | val observer = LifecycleEventObserver { _, event -> 121 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) { 122 | when (event) { 123 | Lifecycle.Event.ON_RESUME -> playerState.showControlUi() 124 | Lifecycle.Event.ON_STOP -> playerState.player.pause() 125 | else -> Unit 126 | } 127 | } else { 128 | when (event) { 129 | Lifecycle.Event.ON_START -> playerState.showControlUi() 130 | Lifecycle.Event.ON_STOP -> playerState.player.pause() 131 | else -> Unit 132 | } 133 | } 134 | } 135 | 136 | lifecycleOwner.lifecycle.addObserver(observer) 137 | 138 | onDispose { 139 | lifecycleOwner.lifecycle.removeObserver(observer) 140 | playerState.player.release() 141 | } 142 | } 143 | } -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/VideoPlayerControl.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer 2 | 3 | import androidx.compose.foundation.LocalIndication 4 | import androidx.compose.foundation.background 5 | import androidx.compose.foundation.clickable 6 | import androidx.compose.foundation.interaction.MutableInteractionSource 7 | import androidx.compose.foundation.layout.* 8 | import androidx.compose.foundation.shape.CircleShape 9 | import androidx.compose.material.* 10 | import androidx.compose.material.icons.Icons 11 | import androidx.compose.material.icons.rounded.PlayArrow 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.runtime.CompositionLocalProvider 14 | import androidx.compose.runtime.remember 15 | import androidx.compose.ui.Alignment 16 | import androidx.compose.ui.Modifier 17 | import androidx.compose.ui.draw.clip 18 | import androidx.compose.ui.graphics.Color 19 | import androidx.compose.ui.text.style.TextOverflow 20 | import androidx.compose.ui.unit.dp 21 | import com.imherrera.videoplayer.icons.* 22 | import kotlin.time.Duration.Companion.milliseconds 23 | 24 | @Composable 25 | fun VideoPlayerControl( 26 | state: VideoPlayerState, 27 | title: String, 28 | subtitle: String? = null, 29 | background: Color = Color.Black.copy(0.30f), 30 | contentColor: Color = Color.White, 31 | progressLineColor: Color = MaterialTheme.colors.primaryVariant, 32 | onOptionsClick: (() -> Unit)? = null, 33 | ) { 34 | CompositionLocalProvider(LocalContentColor provides contentColor) { 35 | Column( 36 | modifier = Modifier 37 | .fillMaxSize() 38 | .background(background) 39 | .padding(16.dp), 40 | horizontalAlignment = Alignment.CenterHorizontally, 41 | verticalArrangement = Arrangement.SpaceBetween 42 | ) { 43 | ControlHeader( 44 | modifier = Modifier.fillMaxWidth(), 45 | title = title, 46 | subtitle = subtitle, 47 | onOptionsClick = onOptionsClick 48 | ) 49 | PlaybackControl( 50 | isPlaying = state.isPlaying.value, 51 | control = state.control 52 | ) 53 | TimelineControl( 54 | modifier = Modifier.fillMaxWidth(), 55 | progressLineColor = progressLineColor, 56 | isFullScreen = state.isFullscreen.value, 57 | videoDurationMs = state.videoDurationMs.value, 58 | videoPositionMs = state.videoPositionMs.value 59 | ) { 60 | state.control.setFullscreen(!state.isFullscreen.value) 61 | } 62 | } 63 | } 64 | } 65 | 66 | @Composable 67 | private fun ControlHeader( 68 | modifier: Modifier = Modifier, 69 | title: String, 70 | subtitle: String?, 71 | onOptionsClick: (() -> Unit)?, 72 | ) { 73 | Row( 74 | modifier = modifier, 75 | horizontalArrangement = Arrangement.SpaceBetween, 76 | verticalAlignment = Alignment.CenterVertically 77 | ) { 78 | Column(verticalArrangement = Arrangement.SpaceBetween) { 79 | Text( 80 | text = title, 81 | color = LocalContentColor.current, 82 | style = MaterialTheme.typography.subtitle1, 83 | maxLines = 1, 84 | overflow = TextOverflow.Ellipsis 85 | ) 86 | if (subtitle != null) { 87 | Text( 88 | text = subtitle, 89 | color = LocalContentColor.current.copy(0.80f), 90 | style = MaterialTheme.typography.body1, 91 | maxLines = 1, 92 | overflow = TextOverflow.Ellipsis 93 | ) 94 | } 95 | } 96 | if (onOptionsClick != null) { 97 | AdaptiveIconButton( 98 | modifier = Modifier.size(SmallIconButtonSize), 99 | onClick = onOptionsClick 100 | ) { 101 | Icon( 102 | imageVector = Icons.Rounded.MoreVert, 103 | contentDescription = null 104 | ) 105 | } 106 | } 107 | } 108 | } 109 | 110 | @Composable 111 | private fun PlaybackControl( 112 | modifier: Modifier = Modifier, 113 | isPlaying: Boolean, 114 | control: VideoPlayerControl 115 | ) { 116 | Row( 117 | modifier = modifier, 118 | horizontalArrangement = Arrangement.spacedBy(16.dp) 119 | ) { 120 | IconButton( 121 | modifier = Modifier 122 | .size(BigIconButtonSize) 123 | .padding(10.dp), 124 | onClick = control::rewind 125 | ) { 126 | Icon( 127 | modifier = Modifier.fillMaxSize(), 128 | imageVector = Icons.Rounded.Replay10, 129 | contentDescription = null 130 | ) 131 | } 132 | IconButton( 133 | modifier = Modifier.size(BigIconButtonSize), 134 | onClick = { if (isPlaying) control.pause() else control.play() } 135 | ) { 136 | Icon( 137 | modifier = Modifier.fillMaxSize(), 138 | imageVector = if (isPlaying) Icons.Rounded.Pause else Icons.Rounded.PlayArrow, 139 | contentDescription = null 140 | ) 141 | } 142 | IconButton( 143 | modifier = Modifier 144 | .size(BigIconButtonSize) 145 | .padding(10.dp), 146 | onClick = control::forward 147 | ) { 148 | Icon( 149 | modifier = Modifier.fillMaxSize(), 150 | imageVector = Icons.Rounded.Forward10, 151 | contentDescription = null 152 | ) 153 | } 154 | } 155 | } 156 | 157 | @Composable 158 | private fun TimelineControl( 159 | modifier: Modifier, 160 | progressLineColor: Color, 161 | isFullScreen: Boolean, 162 | videoDurationMs: Long, 163 | videoPositionMs: Long, 164 | onFullScreenToggle: () -> Unit, 165 | ) { 166 | val timestamp = remember(videoDurationMs, videoPositionMs.milliseconds.inWholeSeconds) { 167 | prettyVideoTimestamp(videoDurationMs.milliseconds, videoPositionMs.milliseconds) 168 | } 169 | val progress = remember(videoPositionMs) { 170 | 1.0f - ((videoDurationMs - videoPositionMs) / videoDurationMs.toFloat()) 171 | } 172 | Column(modifier = modifier) { 173 | Row( 174 | modifier = Modifier.fillMaxWidth(), 175 | horizontalArrangement = Arrangement.spacedBy(16.dp), 176 | verticalAlignment = Alignment.CenterVertically 177 | ) { 178 | Text(text = timestamp) 179 | Spacer(modifier = Modifier.weight(1.0f)) 180 | AdaptiveIconButton( 181 | modifier = Modifier.size(SmallIconButtonSize), 182 | onClick = onFullScreenToggle 183 | ) { 184 | Icon( 185 | imageVector = if (isFullScreen) Icons.Rounded.FullscreenExit else Icons.Rounded.Fullscreen, 186 | contentDescription = null 187 | ) 188 | } 189 | } 190 | Spacer(modifier = Modifier.height(8.dp)) 191 | LinearProgressIndicator( 192 | modifier = Modifier 193 | .fillMaxWidth() 194 | .height(2.dp), 195 | progress = progress, 196 | color = progressLineColor, 197 | backgroundColor = Color.LightGray 198 | ) 199 | } 200 | } 201 | 202 | 203 | /** 204 | * Allow the button to be any size instead of constraining it to 48dp 205 | * **/ 206 | @Composable 207 | private fun AdaptiveIconButton( 208 | onClick: () -> Unit, 209 | modifier: Modifier = Modifier, 210 | enabled: Boolean = true, 211 | interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, 212 | content: @Composable () -> Unit 213 | ) { 214 | Box( 215 | modifier = modifier 216 | .clip(CircleShape) 217 | .clickable( 218 | onClick = onClick, 219 | enabled = enabled, 220 | interactionSource = interactionSource, 221 | indication = LocalIndication.current 222 | ), 223 | contentAlignment = Alignment.Center 224 | ) { 225 | val contentAlpha = if (enabled) LocalContentAlpha.current else ContentAlpha.disabled 226 | CompositionLocalProvider(LocalContentAlpha provides contentAlpha, content = content) 227 | } 228 | } 229 | 230 | private val BigIconButtonSize = 52.dp 231 | private val SmallIconButtonSize = 32.dp 232 | 233 | 234 | -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/VideoPlayerState.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer 2 | 3 | import android.content.Context 4 | import androidx.compose.runtime.* 5 | import androidx.compose.ui.platform.LocalContext 6 | import com.google.android.exoplayer2.ExoPlayer 7 | import com.google.android.exoplayer2.Player 8 | import com.google.android.exoplayer2.video.VideoSize 9 | import kotlinx.coroutines.CoroutineScope 10 | import kotlinx.coroutines.Job 11 | import kotlinx.coroutines.delay 12 | import kotlinx.coroutines.launch 13 | 14 | /** 15 | * Build and remember default implementation of [VideoPlayerState] 16 | * 17 | * @param hideControllerAfterMs time after which [VideoPlayerState.isControlUiVisible] will be set to false. 18 | * interactions with [VideoPlayerState.control] will reset the internal counter. 19 | * if null is provided the controller wont be hidden until [VideoPlayerState.hideControlUi] is called again 20 | * @param videoPositionPollInterval interval on which the [VideoPlayerState.videoPositionMs] will be updated, 21 | * you can set a lower number to update the ui faster though it will consume more cpu resources. 22 | * Take in consideration that this value is updated only when [VideoPlayerState.isControlUiVisible] is set to true, 23 | * if you need to get the last value use [ExoPlayer.getCurrentPosition]. 24 | * @param coroutineScope this scope will be used to poll for [VideoPlayerState.videoPositionMs] updates 25 | * @param context used to build an [ExoPlayer] instance 26 | * @param config you can use this to configure [ExoPlayer] 27 | * */ 28 | @Composable 29 | fun rememberVideoPlayerState( 30 | hideControllerAfterMs: Long? = 3000, 31 | videoPositionPollInterval: Long = 500, 32 | coroutineScope: CoroutineScope = rememberCoroutineScope(), 33 | context: Context = LocalContext.current, 34 | config: ExoPlayer.Builder.() -> Unit = { 35 | setSeekForwardIncrementMs(10 * 1000) 36 | setSeekForwardIncrementMs(10 * 1000) 37 | } 38 | ): VideoPlayerState = remember { 39 | VideoPlayerStateImpl( 40 | player = ExoPlayer.Builder(context).apply(config).build(), 41 | coroutineScope = coroutineScope, 42 | hideControllerAfterMs = hideControllerAfterMs, 43 | videoPositionPollInterval = videoPositionPollInterval 44 | ).also { 45 | it.player.addListener(it) 46 | } 47 | } 48 | 49 | class VideoPlayerStateImpl( 50 | override val player: ExoPlayer, 51 | private val coroutineScope: CoroutineScope, 52 | private val hideControllerAfterMs: Long?, 53 | private val videoPositionPollInterval: Long, 54 | ) : VideoPlayerState, Player.Listener { 55 | override val videoSize = mutableStateOf(player.videoSize) 56 | override val videoResizeMode = mutableStateOf(ResizeMode.Fit) 57 | override val videoPositionMs = mutableStateOf(0L) 58 | override val videoDurationMs = mutableStateOf(0L) 59 | 60 | override val isFullscreen = mutableStateOf(false) 61 | override val isPlaying = mutableStateOf(player.isPlaying) 62 | override val playerState = mutableStateOf(player.playbackState) 63 | 64 | override val isOptionsUiVisible = mutableStateOf(false) 65 | override val isControlUiVisible = mutableStateOf(false) 66 | override val control = object : VideoPlayerControl { 67 | override fun play() { 68 | controlUiLastInteractionMs = 0 69 | player.play() 70 | } 71 | 72 | override fun pause() { 73 | controlUiLastInteractionMs = 0 74 | player.pause() 75 | } 76 | 77 | override fun forward() { 78 | controlUiLastInteractionMs = 0 79 | player.seekForward() 80 | } 81 | 82 | override fun rewind() { 83 | controlUiLastInteractionMs = 0 84 | player.seekBack() 85 | } 86 | 87 | override fun setVideoResize(mode: ResizeMode) { 88 | controlUiLastInteractionMs = 0 89 | videoResizeMode.value = mode 90 | } 91 | 92 | override fun setFullscreen(value: Boolean) { 93 | controlUiLastInteractionMs = 0 94 | isFullscreen.value = value 95 | } 96 | } 97 | 98 | override fun hideOptionsUi() { 99 | isOptionsUiVisible.value = true 100 | } 101 | 102 | override fun showOptionsUi() { 103 | isOptionsUiVisible.value = false 104 | } 105 | 106 | private var pollVideoPositionJob: Job? = null 107 | private var controlUiLastInteractionMs = 0L 108 | 109 | override fun hideControlUi() { 110 | controlUiLastInteractionMs = 0 111 | isControlUiVisible.value = false 112 | pollVideoPositionJob?.cancel() 113 | pollVideoPositionJob = null 114 | } 115 | 116 | override fun showControlUi() { 117 | isControlUiVisible.value = true 118 | pollVideoPositionJob?.cancel() 119 | pollVideoPositionJob = coroutineScope.launch { 120 | if (hideControllerAfterMs != null) { 121 | while (true) { 122 | videoPositionMs.value = player.currentPosition 123 | delay(videoPositionPollInterval) 124 | controlUiLastInteractionMs += videoPositionPollInterval 125 | if (controlUiLastInteractionMs >= hideControllerAfterMs) { 126 | hideControlUi() 127 | break 128 | } 129 | } 130 | } else { 131 | while (true) { 132 | videoPositionMs.value = player.currentPosition 133 | delay(videoPositionPollInterval) 134 | } 135 | } 136 | } 137 | } 138 | 139 | override fun onIsPlayingChanged(isPlaying: Boolean) { 140 | this.isPlaying.value = isPlaying 141 | } 142 | 143 | override fun onPlaybackStateChanged(playbackState: Int) { 144 | if (playbackState == Player.STATE_READY) videoDurationMs.value = player.duration 145 | this.playerState.value = playbackState 146 | } 147 | 148 | override fun onVideoSizeChanged(videoSize: VideoSize) { 149 | this.videoSize.value = videoSize 150 | } 151 | } 152 | 153 | 154 | interface VideoPlayerState { 155 | val player: ExoPlayer 156 | 157 | val videoSize: State 158 | val videoResizeMode: State 159 | val videoPositionMs: State 160 | val videoDurationMs: State 161 | 162 | val isFullscreen: State 163 | val isPlaying: State 164 | val playerState: State 165 | 166 | val isOptionsUiVisible: State 167 | val isControlUiVisible: State 168 | val control: VideoPlayerControl 169 | 170 | fun hideOptionsUi() 171 | fun showOptionsUi() 172 | 173 | fun hideControlUi() 174 | fun showControlUi() 175 | } 176 | 177 | interface VideoPlayerControl { 178 | fun play() 179 | fun pause() 180 | 181 | fun forward() 182 | fun rewind() 183 | 184 | fun setFullscreen(value: Boolean) 185 | fun setVideoResize(mode: ResizeMode) 186 | } -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/Forward10.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.Forward10: ImageVector 9 | get() { 10 | if (_forward10 != null) { 11 | return _forward10!! 12 | } 13 | _forward10 = materialIcon(name = "Rounded.Forward10") { 14 | materialPath { 15 | moveTo(18.92f, 13.0f) 16 | curveToRelative(-0.5f, 0.0f, -0.91f, 0.37f, -0.98f, 0.86f) 17 | curveToRelative(-0.48f, 3.37f, -3.77f, 5.84f, -7.42f, 4.96f) 18 | curveToRelative(-2.25f, -0.54f, -3.91f, -2.27f, -4.39f, -4.53f) 19 | curveTo(5.32f, 10.42f, 8.27f, 7.0f, 12.0f, 7.0f) 20 | verticalLineToRelative(2.79f) 21 | curveToRelative(0.0f, 0.45f, 0.54f, 0.67f, 0.85f, 0.35f) 22 | lineToRelative(3.79f, -3.79f) 23 | curveToRelative(0.2f, -0.2f, 0.2f, -0.51f, 0.0f, -0.71f) 24 | lineToRelative(-3.79f, -3.79f) 25 | curveToRelative(-0.31f, -0.31f, -0.85f, -0.09f, -0.85f, 0.36f) 26 | lineTo(12.0f, 5.0f) 27 | curveToRelative(-4.94f, 0.0f, -8.84f, 4.48f, -7.84f, 9.6f) 28 | curveToRelative(0.6f, 3.11f, 2.9f, 5.5f, 5.99f, 6.19f) 29 | curveToRelative(4.83f, 1.08f, 9.15f, -2.2f, 9.77f, -6.67f) 30 | curveToRelative(0.09f, -0.59f, -0.4f, -1.12f, -1.0f, -1.12f) 31 | close() 32 | moveTo(10.9f, 16.0f) 33 | verticalLineToRelative(-4.27f) 34 | horizontalLineToRelative(-0.09f) 35 | lineToRelative(-1.77f, 0.63f) 36 | verticalLineToRelative(0.69f) 37 | lineToRelative(1.01f, -0.31f) 38 | lineTo(10.05f, 16.0f) 39 | close() 40 | moveTo(14.32f, 11.78f) 41 | curveToRelative(-0.18f, -0.07f, -0.37f, -0.1f, -0.59f, -0.1f) 42 | reflectiveCurveToRelative(-0.41f, 0.03f, -0.59f, 0.1f) 43 | reflectiveCurveToRelative(-0.33f, 0.18f, -0.45f, 0.33f) 44 | reflectiveCurveToRelative(-0.23f, 0.34f, -0.29f, 0.57f) 45 | reflectiveCurveToRelative(-0.1f, 0.5f, -0.1f, 0.82f) 46 | verticalLineToRelative(0.74f) 47 | curveToRelative(0.0f, 0.32f, 0.04f, 0.6f, 0.11f, 0.82f) 48 | reflectiveCurveToRelative(0.17f, 0.42f, 0.3f, 0.57f) 49 | reflectiveCurveToRelative(0.28f, 0.26f, 0.46f, 0.33f) 50 | reflectiveCurveToRelative(0.37f, 0.1f, 0.59f, 0.1f) 51 | reflectiveCurveToRelative(0.41f, -0.03f, 0.59f, -0.1f) 52 | reflectiveCurveToRelative(0.33f, -0.18f, 0.45f, -0.33f) 53 | reflectiveCurveToRelative(0.22f, -0.34f, 0.29f, -0.57f) 54 | reflectiveCurveToRelative(0.1f, -0.5f, 0.1f, -0.82f) 55 | verticalLineToRelative(-0.74f) 56 | curveToRelative(0.0f, -0.32f, -0.04f, -0.6f, -0.11f, -0.82f) 57 | reflectiveCurveToRelative(-0.17f, -0.42f, -0.3f, -0.57f) 58 | reflectiveCurveToRelative(-0.29f, -0.26f, -0.46f, -0.33f) 59 | close() 60 | moveTo(14.33f, 14.35f) 61 | curveToRelative(0.0f, 0.19f, -0.01f, 0.35f, -0.04f, 0.48f) 62 | reflectiveCurveToRelative(-0.06f, 0.24f, -0.11f, 0.32f) 63 | reflectiveCurveToRelative(-0.11f, 0.14f, -0.19f, 0.17f) 64 | reflectiveCurveToRelative(-0.16f, 0.05f, -0.25f, 0.05f) 65 | reflectiveCurveToRelative(-0.18f, -0.02f, -0.25f, -0.05f) 66 | reflectiveCurveToRelative(-0.14f, -0.09f, -0.19f, -0.17f) 67 | reflectiveCurveToRelative(-0.09f, -0.19f, -0.12f, -0.32f) 68 | reflectiveCurveToRelative(-0.04f, -0.29f, -0.04f, -0.48f) 69 | verticalLineToRelative(-0.97f) 70 | curveToRelative(0.0f, -0.19f, 0.01f, -0.35f, 0.04f, -0.48f) 71 | reflectiveCurveToRelative(0.06f, -0.23f, 0.12f, -0.31f) 72 | reflectiveCurveToRelative(0.11f, -0.14f, 0.19f, -0.17f) 73 | reflectiveCurveToRelative(0.16f, -0.05f, 0.25f, -0.05f) 74 | reflectiveCurveToRelative(0.18f, 0.02f, 0.25f, 0.05f) 75 | reflectiveCurveToRelative(0.14f, 0.09f, 0.19f, 0.17f) 76 | reflectiveCurveToRelative(0.09f, 0.18f, 0.12f, 0.31f) 77 | reflectiveCurveToRelative(0.04f, 0.29f, 0.04f, 0.48f) 78 | verticalLineToRelative(0.97f) 79 | close() 80 | } 81 | } 82 | return _forward10!! 83 | } 84 | 85 | private var _forward10: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/Fullscreen.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.Fullscreen: ImageVector 9 | get() { 10 | if (_fullscreen != null) { 11 | return _fullscreen!! 12 | } 13 | _fullscreen = materialIcon(name = "Rounded.Fullscreen") { 14 | materialPath { 15 | moveTo(6.0f, 14.0f) 16 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 17 | verticalLineToRelative(3.0f) 18 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 19 | horizontalLineToRelative(3.0f) 20 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 21 | reflectiveCurveToRelative(-0.45f, -1.0f, -1.0f, -1.0f) 22 | lineTo(7.0f, 17.0f) 23 | verticalLineToRelative(-2.0f) 24 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 25 | close() 26 | moveTo(6.0f, 10.0f) 27 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 28 | lineTo(7.0f, 7.0f) 29 | horizontalLineToRelative(2.0f) 30 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 31 | reflectiveCurveToRelative(-0.45f, -1.0f, -1.0f, -1.0f) 32 | lineTo(6.0f, 5.0f) 33 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 34 | verticalLineToRelative(3.0f) 35 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 36 | close() 37 | moveTo(17.0f, 17.0f) 38 | horizontalLineToRelative(-2.0f) 39 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 40 | reflectiveCurveToRelative(0.45f, 1.0f, 1.0f, 1.0f) 41 | horizontalLineToRelative(3.0f) 42 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 43 | verticalLineToRelative(-3.0f) 44 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 45 | reflectiveCurveToRelative(-1.0f, 0.45f, -1.0f, 1.0f) 46 | verticalLineToRelative(2.0f) 47 | close() 48 | moveTo(14.0f, 6.0f) 49 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 50 | horizontalLineToRelative(2.0f) 51 | verticalLineToRelative(2.0f) 52 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 53 | reflectiveCurveToRelative(1.0f, -0.45f, 1.0f, -1.0f) 54 | lineTo(19.0f, 6.0f) 55 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 56 | horizontalLineToRelative(-3.0f) 57 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 58 | close() 59 | } 60 | } 61 | return _fullscreen!! 62 | } 63 | 64 | private var _fullscreen: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/FullscreenExit.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.FullscreenExit: ImageVector 9 | get() { 10 | if (_fullscreenExit != null) { 11 | return _fullscreenExit!! 12 | } 13 | _fullscreenExit = materialIcon(name = "Rounded.FullscreenExit") { 14 | materialPath { 15 | moveTo(6.0f, 16.0f) 16 | horizontalLineToRelative(2.0f) 17 | verticalLineToRelative(2.0f) 18 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 19 | reflectiveCurveToRelative(1.0f, -0.45f, 1.0f, -1.0f) 20 | verticalLineToRelative(-3.0f) 21 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 22 | lineTo(6.0f, 14.0f) 23 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 24 | reflectiveCurveToRelative(0.45f, 1.0f, 1.0f, 1.0f) 25 | close() 26 | moveTo(8.0f, 8.0f) 27 | lineTo(6.0f, 8.0f) 28 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 29 | reflectiveCurveToRelative(0.45f, 1.0f, 1.0f, 1.0f) 30 | horizontalLineToRelative(3.0f) 31 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 32 | lineTo(10.0f, 6.0f) 33 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 34 | reflectiveCurveToRelative(-1.0f, 0.45f, -1.0f, 1.0f) 35 | verticalLineToRelative(2.0f) 36 | close() 37 | moveTo(15.0f, 19.0f) 38 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 39 | verticalLineToRelative(-2.0f) 40 | horizontalLineToRelative(2.0f) 41 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 42 | reflectiveCurveToRelative(-0.45f, -1.0f, -1.0f, -1.0f) 43 | horizontalLineToRelative(-3.0f) 44 | curveToRelative(-0.55f, 0.0f, -1.0f, 0.45f, -1.0f, 1.0f) 45 | verticalLineToRelative(3.0f) 46 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 47 | close() 48 | moveTo(16.0f, 8.0f) 49 | lineTo(16.0f, 6.0f) 50 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 51 | reflectiveCurveToRelative(-1.0f, 0.45f, -1.0f, 1.0f) 52 | verticalLineToRelative(3.0f) 53 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 54 | horizontalLineToRelative(3.0f) 55 | curveToRelative(0.55f, 0.0f, 1.0f, -0.45f, 1.0f, -1.0f) 56 | reflectiveCurveToRelative(-0.45f, -1.0f, -1.0f, -1.0f) 57 | horizontalLineToRelative(-2.0f) 58 | close() 59 | } 60 | } 61 | return _fullscreenExit!! 62 | } 63 | 64 | private var _fullscreenExit: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/MoreVert.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.MoreVert: ImageVector 9 | get() { 10 | if (_moreVert != null) { 11 | return _moreVert!! 12 | } 13 | _moreVert = materialIcon(name = "Rounded.MoreVert") { 14 | materialPath { 15 | moveTo(12.0f, 8.0f) 16 | curveToRelative(1.1f, 0.0f, 2.0f, -0.9f, 2.0f, -2.0f) 17 | reflectiveCurveToRelative(-0.9f, -2.0f, -2.0f, -2.0f) 18 | reflectiveCurveToRelative(-2.0f, 0.9f, -2.0f, 2.0f) 19 | reflectiveCurveToRelative(0.9f, 2.0f, 2.0f, 2.0f) 20 | close() 21 | moveTo(12.0f, 10.0f) 22 | curveToRelative(-1.1f, 0.0f, -2.0f, 0.9f, -2.0f, 2.0f) 23 | reflectiveCurveToRelative(0.9f, 2.0f, 2.0f, 2.0f) 24 | reflectiveCurveToRelative(2.0f, -0.9f, 2.0f, -2.0f) 25 | reflectiveCurveToRelative(-0.9f, -2.0f, -2.0f, -2.0f) 26 | close() 27 | moveTo(12.0f, 16.0f) 28 | curveToRelative(-1.1f, 0.0f, -2.0f, 0.9f, -2.0f, 2.0f) 29 | reflectiveCurveToRelative(0.9f, 2.0f, 2.0f, 2.0f) 30 | reflectiveCurveToRelative(2.0f, -0.9f, 2.0f, -2.0f) 31 | reflectiveCurveToRelative(-0.9f, -2.0f, -2.0f, -2.0f) 32 | close() 33 | } 34 | } 35 | return _moreVert!! 36 | } 37 | 38 | private var _moreVert: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/Pause.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.Pause: ImageVector 9 | get() { 10 | if (_pause != null) { 11 | return _pause!! 12 | } 13 | _pause = materialIcon(name = "Rounded.Pause") { 14 | materialPath { 15 | moveTo(8.0f, 19.0f) 16 | curveToRelative(1.1f, 0.0f, 2.0f, -0.9f, 2.0f, -2.0f) 17 | lineTo(10.0f, 7.0f) 18 | curveToRelative(0.0f, -1.1f, -0.9f, -2.0f, -2.0f, -2.0f) 19 | reflectiveCurveToRelative(-2.0f, 0.9f, -2.0f, 2.0f) 20 | verticalLineToRelative(10.0f) 21 | curveToRelative(0.0f, 1.1f, 0.9f, 2.0f, 2.0f, 2.0f) 22 | close() 23 | moveTo(14.0f, 7.0f) 24 | verticalLineToRelative(10.0f) 25 | curveToRelative(0.0f, 1.1f, 0.9f, 2.0f, 2.0f, 2.0f) 26 | reflectiveCurveToRelative(2.0f, -0.9f, 2.0f, -2.0f) 27 | lineTo(18.0f, 7.0f) 28 | curveToRelative(0.0f, -1.1f, -0.9f, -2.0f, -2.0f, -2.0f) 29 | reflectiveCurveToRelative(-2.0f, 0.9f, -2.0f, 2.0f) 30 | close() 31 | } 32 | } 33 | return _pause!! 34 | } 35 | 36 | private var _pause: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/PlayArrow.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.PlayArrow: ImageVector 9 | get() { 10 | if (_playArrow != null) { 11 | return _playArrow!! 12 | } 13 | _playArrow = materialIcon(name = "Rounded.PlayArrow") { 14 | materialPath { 15 | moveTo(8.0f, 6.82f) 16 | verticalLineToRelative(10.36f) 17 | curveToRelative(0.0f, 0.79f, 0.87f, 1.27f, 1.54f, 0.84f) 18 | lineToRelative(8.14f, -5.18f) 19 | curveToRelative(0.62f, -0.39f, 0.62f, -1.29f, 0.0f, -1.69f) 20 | lineTo(9.54f, 5.98f) 21 | curveTo(8.87f, 5.55f, 8.0f, 6.03f, 8.0f, 6.82f) 22 | close() 23 | } 24 | } 25 | return _playArrow!! 26 | } 27 | 28 | private var _playArrow: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/Replay10.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.Replay10: ImageVector 9 | get() { 10 | if (_replay10 != null) { 11 | return _replay10!! 12 | } 13 | _replay10 = materialIcon(name = "Rounded.Replay10") { 14 | materialPath { 15 | moveTo(11.99f, 5.0f) 16 | lineTo(11.99f, 2.21f) 17 | curveToRelative(0.0f, -0.45f, -0.54f, -0.67f, -0.85f, -0.35f) 18 | lineTo(7.35f, 5.65f) 19 | curveToRelative(-0.2f, 0.2f, -0.2f, 0.51f, 0.0f, 0.71f) 20 | lineToRelative(3.79f, 3.79f) 21 | curveToRelative(0.31f, 0.31f, 0.85f, 0.09f, 0.85f, -0.35f) 22 | lineTo(11.99f, 7.0f) 23 | curveToRelative(3.73f, 0.0f, 6.68f, 3.42f, 5.86f, 7.29f) 24 | curveToRelative(-0.47f, 2.27f, -2.31f, 4.1f, -4.57f, 4.57f) 25 | curveToRelative(-3.57f, 0.75f, -6.75f, -1.7f, -7.23f, -5.01f) 26 | curveToRelative(-0.06f, -0.48f, -0.48f, -0.85f, -0.98f, -0.85f) 27 | curveToRelative(-0.6f, 0.0f, -1.08f, 0.53f, -1.0f, 1.13f) 28 | curveToRelative(0.62f, 4.39f, 4.8f, 7.64f, 9.53f, 6.72f) 29 | curveToRelative(3.12f, -0.61f, 5.63f, -3.12f, 6.24f, -6.24f) 30 | curveToRelative(0.99f, -5.13f, -2.9f, -9.61f, -7.85f, -9.61f) 31 | close() 32 | moveTo(10.89f, 16.0f) 33 | horizontalLineToRelative(-0.85f) 34 | verticalLineToRelative(-3.26f) 35 | lineToRelative(-1.01f, 0.31f) 36 | verticalLineToRelative(-0.69f) 37 | lineToRelative(1.77f, -0.63f) 38 | horizontalLineToRelative(0.09f) 39 | lineTo(10.89f, 16.0f) 40 | close() 41 | moveTo(15.17f, 14.24f) 42 | curveToRelative(0.0f, 0.32f, -0.03f, 0.6f, -0.1f, 0.82f) 43 | reflectiveCurveToRelative(-0.17f, 0.42f, -0.29f, 0.57f) 44 | reflectiveCurveToRelative(-0.28f, 0.26f, -0.45f, 0.33f) 45 | reflectiveCurveToRelative(-0.37f, 0.1f, -0.59f, 0.1f) 46 | reflectiveCurveToRelative(-0.41f, -0.03f, -0.59f, -0.1f) 47 | reflectiveCurveToRelative(-0.33f, -0.18f, -0.46f, -0.33f) 48 | reflectiveCurveToRelative(-0.23f, -0.34f, -0.3f, -0.57f) 49 | reflectiveCurveToRelative(-0.11f, -0.5f, -0.11f, -0.82f) 50 | verticalLineToRelative(-0.74f) 51 | curveToRelative(0.0f, -0.32f, 0.03f, -0.6f, 0.1f, -0.82f) 52 | reflectiveCurveToRelative(0.17f, -0.42f, 0.29f, -0.57f) 53 | reflectiveCurveToRelative(0.28f, -0.26f, 0.45f, -0.33f) 54 | reflectiveCurveToRelative(0.37f, -0.1f, 0.59f, -0.1f) 55 | reflectiveCurveToRelative(0.41f, 0.03f, 0.59f, 0.1f) 56 | reflectiveCurveToRelative(0.33f, 0.18f, 0.46f, 0.33f) 57 | reflectiveCurveToRelative(0.23f, 0.34f, 0.3f, 0.57f) 58 | reflectiveCurveToRelative(0.11f, 0.5f, 0.11f, 0.82f) 59 | verticalLineToRelative(0.74f) 60 | close() 61 | moveTo(14.32f, 13.38f) 62 | curveToRelative(0.0f, -0.19f, -0.01f, -0.35f, -0.04f, -0.48f) 63 | reflectiveCurveToRelative(-0.07f, -0.23f, -0.12f, -0.31f) 64 | reflectiveCurveToRelative(-0.11f, -0.14f, -0.19f, -0.17f) 65 | reflectiveCurveToRelative(-0.16f, -0.05f, -0.25f, -0.05f) 66 | reflectiveCurveToRelative(-0.18f, 0.02f, -0.25f, 0.05f) 67 | reflectiveCurveToRelative(-0.14f, 0.09f, -0.19f, 0.17f) 68 | reflectiveCurveToRelative(-0.09f, 0.18f, -0.12f, 0.31f) 69 | reflectiveCurveToRelative(-0.04f, 0.29f, -0.04f, 0.48f) 70 | verticalLineToRelative(0.97f) 71 | curveToRelative(0.0f, 0.19f, 0.01f, 0.35f, 0.04f, 0.48f) 72 | reflectiveCurveToRelative(0.07f, 0.24f, 0.12f, 0.32f) 73 | reflectiveCurveToRelative(0.11f, 0.14f, 0.19f, 0.17f) 74 | reflectiveCurveToRelative(0.16f, 0.05f, 0.25f, 0.05f) 75 | reflectiveCurveToRelative(0.18f, -0.02f, 0.25f, -0.05f) 76 | reflectiveCurveToRelative(0.14f, -0.09f, 0.19f, -0.17f) 77 | reflectiveCurveToRelative(0.09f, -0.19f, 0.11f, -0.32f) 78 | reflectiveCurveToRelative(0.04f, -0.29f, 0.04f, -0.48f) 79 | verticalLineToRelative(-0.97f) 80 | close() 81 | } 82 | } 83 | return _replay10!! 84 | } 85 | 86 | private var _replay10: ImageVector? = null -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/SkipNext.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.SkipNext: ImageVector 9 | get() { 10 | if (_skipNext != null) { 11 | return _skipNext!! 12 | } 13 | _skipNext = materialIcon(name = "Rounded.SkipNext") { 14 | materialPath { 15 | moveTo(7.58f, 16.89f) 16 | lineToRelative(5.77f, -4.07f) 17 | curveToRelative(0.56f, -0.4f, 0.56f, -1.24f, 0.0f, -1.63f) 18 | lineTo(7.58f, 7.11f) 19 | curveTo(6.91f, 6.65f, 6.0f, 7.12f, 6.0f, 7.93f) 20 | verticalLineToRelative(8.14f) 21 | curveToRelative(0.0f, 0.81f, 0.91f, 1.28f, 1.58f, 0.82f) 22 | close() 23 | moveTo(16.0f, 7.0f) 24 | verticalLineToRelative(10.0f) 25 | curveToRelative(0.0f, 0.55f, 0.45f, 1.0f, 1.0f, 1.0f) 26 | reflectiveCurveToRelative(1.0f, -0.45f, 1.0f, -1.0f) 27 | verticalLineTo(7.0f) 28 | curveToRelative(0.0f, -0.55f, -0.45f, -1.0f, -1.0f, -1.0f) 29 | reflectiveCurveToRelative(-1.0f, 0.45f, -1.0f, 1.0f) 30 | close() 31 | } 32 | } 33 | return _skipNext!! 34 | } 35 | 36 | private var _skipNext: ImageVector? = null 37 | -------------------------------------------------------------------------------- /videoplayer/src/main/java/com/imherrera/videoplayer/icons/SkipPrevious.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer.icons 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.materialIcon 5 | import androidx.compose.material.icons.materialPath 6 | import androidx.compose.ui.graphics.vector.ImageVector 7 | 8 | internal val Icons.Rounded.SkipPrevious: ImageVector 9 | get() { 10 | if (_skipPrevious != null) { 11 | return _skipPrevious!! 12 | } 13 | _skipPrevious = materialIcon(name = "Rounded.SkipPrevious") { 14 | materialPath { 15 | moveTo(7.0f, 6.0f) 16 | curveToRelative(0.55f, 0.0f, 1.0f, 0.45f, 1.0f, 1.0f) 17 | verticalLineToRelative(10.0f) 18 | curveToRelative(0.0f, 0.55f, -0.45f, 1.0f, -1.0f, 1.0f) 19 | reflectiveCurveToRelative(-1.0f, -0.45f, -1.0f, -1.0f) 20 | lineTo(6.0f, 7.0f) 21 | curveToRelative(0.0f, -0.55f, 0.45f, -1.0f, 1.0f, -1.0f) 22 | close() 23 | moveTo(10.66f, 12.82f) 24 | lineToRelative(5.77f, 4.07f) 25 | curveToRelative(0.66f, 0.47f, 1.58f, -0.01f, 1.58f, -0.82f) 26 | lineTo(18.01f, 7.93f) 27 | curveToRelative(0.0f, -0.81f, -0.91f, -1.28f, -1.58f, -0.82f) 28 | lineToRelative(-5.77f, 4.07f) 29 | curveToRelative(-0.57f, 0.4f, -0.57f, 1.24f, 0.0f, 1.64f) 30 | close() 31 | } 32 | } 33 | return _skipPrevious!! 34 | } 35 | 36 | private var _skipPrevious: ImageVector? = null 37 | -------------------------------------------------------------------------------- /videoplayer/src/test/java/com/imherrera/videoplayer/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.imherrera.videoplayer 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } --------------------------------------------------------------------------------