├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── encodings.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── ir │ │ └── hamedt │ │ └── floatingvideoplayer │ │ └── MainActivity.java │ └── res │ ├── drawable-hdpi │ ├── ic_close_white_48dp.png │ └── ic_video_library_white_48dp.png │ ├── drawable-mdpi │ ├── ic_close_white_48dp.png │ └── ic_video_library_white_48dp.png │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable-xhdpi │ ├── ic_close_white_48dp.png │ └── ic_video_library_white_48dp.png │ ├── drawable-xxhdpi │ ├── ic_close_white_48dp.png │ └── ic_video_library_white_48dp.png │ ├── drawable-xxxhdpi │ ├── ic_close_white_48dp.png │ └── ic_video_library_white_48dp.png │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ └── floating_layout.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── raw │ └── matrix.mp4 │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample2.gif └── settings.gradle /.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 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 21 | 22 | 23 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | xmlns:android 32 | 33 | ^$ 34 | 35 | 36 | 37 |
38 |
39 | 40 | 41 | 42 | xmlns:.* 43 | 44 | ^$ 45 | 46 | 47 | BY_NAME 48 | 49 |
50 |
51 | 52 | 53 | 54 | .*:id 55 | 56 | http://schemas.android.com/apk/res/android 57 | 58 | 59 | 60 |
61 |
62 | 63 | 64 | 65 | .*:name 66 | 67 | http://schemas.android.com/apk/res/android 68 | 69 | 70 | 71 |
72 |
73 | 74 | 75 | 76 | name 77 | 78 | ^$ 79 | 80 | 81 | 82 |
83 |
84 | 85 | 86 | 87 | style 88 | 89 | ^$ 90 | 91 | 92 | 93 |
94 |
95 | 96 | 97 | 98 | .* 99 | 100 | ^$ 101 | 102 | 103 | BY_NAME 104 | 105 |
106 |
107 | 108 | 109 | 110 | .* 111 | 112 | http://schemas.android.com/apk/res/android 113 | 114 | 115 | ANDROID_ATTRIBUTE_ORDER 116 | 117 |
118 |
119 | 120 | 121 | 122 | .* 123 | 124 | .* 125 | 126 | 127 | BY_NAME 128 | 129 |
130 |
131 |
132 |
133 |
134 |
-------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Hamed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # floating-video-player-android 2 | Sample Floating Video Player project for android platform 3 | 4 | ## Demo 5 |
6 | 7 |
8 | 9 | ## Usage 10 | ##### You need plugin [floating-layout-android](https://github.com/HamedTaherpour/floating-layout-android) 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | buildToolsVersion "29.0.0" 6 | defaultConfig { 7 | applicationId "ir.hamedt.floatingvideoplayer" 8 | minSdkVersion 19 9 | targetSdkVersion 30 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'androidx.appcompat:appcompat:1.2.0' 24 | 25 | implementation 'com.github.HamedTaherpour:floating-layout-android:1.1.5' 26 | } 27 | -------------------------------------------------------------------------------- /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 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/ir/hamedt/floatingvideoplayer/MainActivity.java: -------------------------------------------------------------------------------- 1 | package ir.hamedt.floatingvideoplayer; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.provider.Settings; 11 | import android.view.View; 12 | import android.widget.VideoView; 13 | 14 | import io.hamed.floatinglayout.FloatingLayout; 15 | import io.hamed.floatinglayout.callback.FloatingListener; 16 | 17 | 18 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 19 | 20 | private FloatingLayout floatingLayout; 21 | private VideoView videoView; 22 | 23 | private FloatingListener floatingListener = new FloatingListener() { 24 | @Override 25 | public void onCreateListener(View view) { 26 | initVideoView(view); 27 | view.findViewById(R.id.btn_close).setOnClickListener(MainActivity.this); 28 | } 29 | 30 | @Override 31 | public void onCloseListener() { 32 | videoView.stopPlayback(); 33 | } 34 | }; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_main); 40 | 41 | findViewById(R.id.btn_run).setOnClickListener(this); 42 | } 43 | 44 | private void initVideoView(View view) { 45 | videoView = view.findViewById(R.id.video_player); 46 | 47 | Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.matrix); 48 | videoView.setVideoURI(uri); 49 | videoView.start(); 50 | } 51 | 52 | @Override 53 | public void onClick(View view) { 54 | switch (view.getId()) { 55 | case R.id.btn_run: 56 | if (!isNeedPermission()) 57 | showFloating(); 58 | else 59 | requestPermission(); 60 | break; 61 | case R.id.btn_close: 62 | floatingLayout.destroy(); 63 | break; 64 | } 65 | } 66 | 67 | private boolean isNeedPermission() { 68 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this); 69 | } 70 | 71 | private void requestPermission() { 72 | Intent intent = new Intent( 73 | Settings.ACTION_MANAGE_OVERLAY_PERMISSION, 74 | Uri.parse("package:" + getPackageName()) 75 | ); 76 | startActivityForResult(intent, 25); 77 | } 78 | 79 | private void showFloating() { 80 | floatingLayout = new FloatingLayout(getApplicationContext(), R.layout.floating_layout); 81 | floatingLayout.setFloatingListener(floatingListener); 82 | floatingLayout.create(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_close_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-hdpi/ic_close_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_video_library_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-hdpi/ic_video_library_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_close_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-mdpi/ic_close_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_video_library_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-mdpi/ic_video_library_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_close_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xhdpi/ic_close_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_video_library_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xhdpi/ic_video_library_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_close_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xxhdpi/ic_close_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_video_library_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xxhdpi/ic_video_library_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_close_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xxxhdpi/ic_close_white_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_video_library_white_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedTaherpour/floating-video-player-android/9d409a77e6e7a72e4c8913cff02b3f2216634851/app/src/main/res/drawable-xxxhdpi/ic_video_library_white_48dp.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 |