├── .gitattributes ├── .gitignore ├── .idea ├── encodings.xml ├── gradle.xml ├── misc.xml ├── render.experimental.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ ├── android │ │ └── developer │ │ │ └── arsl │ │ │ └── videoplayer │ │ │ └── ExampleInstrumentedTest.java │ │ └── example │ │ └── videoplayer │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── videoplayer │ │ │ ├── MainActivity.java │ │ │ ├── MyAdapter.java │ │ │ └── videoPlayerActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout-land │ │ └── activity_main.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_video_player.xml │ │ └── video_item.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 │ │ └── technolog.mp4 │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ ├── android │ └── developer │ │ └── arsl │ │ └── videoplayer │ │ └── ExampleUnitTest.java │ └── example │ └── videoplayer │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.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/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/render.experimental.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.example.videoplayer" 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 'com.android.support:appcompat-v7:28.0.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation 'com.android.support:cardview-v7:28.0.0' 29 | implementation 'com.android.support:recyclerview-v7:28.0.0' 30 | 31 | } 32 | -------------------------------------------------------------------------------- /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/androidTest/java/com/android/developer/arsl/videoplayer/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.android.developer.arsl.videoplayer; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.android.developer.arsl.videoplayer", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/videoplayer/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.videoplayer; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.videoplayer", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/videoplayer/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.videoplayer; 2 | 3 | import android.Manifest; 4 | import android.content.pm.PackageManager; 5 | import android.support.annotation.NonNull; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.content.ContextCompat; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.support.v7.widget.GridLayoutManager; 11 | import android.support.v7.widget.RecyclerView; 12 | import android.widget.Toast; 13 | 14 | import java.io.File; 15 | import java.util.ArrayList; 16 | 17 | public class MainActivity extends AppCompatActivity { 18 | 19 | RecyclerView myRecyclerView; 20 | MyAdapter obj_adapter; 21 | public static int REQUEST_PERMISSION = 1; 22 | File directory; 23 | boolean bolean_permission; 24 | public static ArrayList fileArrayList = new ArrayList<>(); 25 | 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | 32 | myRecyclerView = (RecyclerView)findViewById(R.id.listVideoRecycler); 33 | 34 | //Phone Memory And SD Card 35 | directory = new File("/mnt/"); 36 | 37 | //SD Card 38 | //directory = new File("/storage/"); 39 | 40 | GridLayoutManager manager = new GridLayoutManager(MainActivity.this,2); 41 | myRecyclerView.setLayoutManager(manager); 42 | 43 | permissionForVideo(); 44 | } 45 | 46 | private void permissionForVideo() { 47 | 48 | if ((ContextCompat.checkSelfPermission(getApplicationContext(), 49 | Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)){ 50 | 51 | 52 | if((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, 53 | Manifest.permission.READ_EXTERNAL_STORAGE))){ 54 | } 55 | else{ 56 | ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 57 | REQUEST_PERMISSION); 58 | } 59 | 60 | } 61 | else{ 62 | bolean_permission = true; 63 | getFile(directory); 64 | obj_adapter = new MyAdapter(getApplicationContext(),fileArrayList); 65 | myRecyclerView.setAdapter(obj_adapter); 66 | 67 | } 68 | 69 | 70 | 71 | } 72 | 73 | @Override 74 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 75 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); 76 | 77 | if(requestCode == REQUEST_PERMISSION){ 78 | 79 | if(grantResults.length>0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){ 80 | 81 | bolean_permission = true; 82 | getFile(directory); 83 | obj_adapter = new MyAdapter(getApplicationContext(),fileArrayList); 84 | myRecyclerView.setAdapter(obj_adapter); 85 | 86 | } 87 | else{ 88 | Toast.makeText(this, "Please Allow the Permission", Toast.LENGTH_SHORT).show(); 89 | } 90 | 91 | 92 | 93 | } 94 | } 95 | 96 | public ArrayList getFile(File directory){ 97 | 98 | File listFile[] = directory.listFiles(); 99 | if(listFile!=null && listFile.length>0){ 100 | 101 | for(int i = 0;i { 21 | 22 | private Context context; 23 | ArrayList videoArrayList; 24 | 25 | public MyAdapter(Context context, ArrayList videoArrayList) { 26 | this.context = context; 27 | this.videoArrayList = videoArrayList; 28 | } 29 | 30 | @Override 31 | public VideoHolder onCreateViewHolder(ViewGroup viewGroup, int i) { 32 | 33 | View mview = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.video_item,viewGroup,false); 34 | return new VideoHolder(mview); 35 | } 36 | 37 | @Override 38 | public void onBindViewHolder(@NonNull final VideoHolder videoHolder, int i) { 39 | 40 | videoHolder.txtFileName.setText(MainActivity.fileArrayList.get(i).getName()); 41 | Bitmap bitmapThumbnail = ThumbnailUtils.createVideoThumbnail(videoArrayList.get(i).getPath(), MediaStore.Images.Thumbnails.MINI_KIND); 42 | videoHolder.imageThumbnail.setImageBitmap(bitmapThumbnail); 43 | 44 | videoHolder.mCardView.setOnClickListener(new View.OnClickListener() { 45 | @Override 46 | public void onClick(View v) { 47 | 48 | Intent intent = new Intent(context,videoPlayerActivity.class); 49 | intent.putExtra("position",videoHolder.getAdapterPosition()); 50 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 51 | context.startActivity(intent); 52 | 53 | } 54 | }); 55 | } 56 | 57 | @Override 58 | public int getItemCount() { 59 | if(videoArrayList.size()>0){ 60 | return videoArrayList.size(); 61 | } 62 | else 63 | return 1; 64 | } 65 | } 66 | class VideoHolder extends RecyclerView.ViewHolder{ 67 | 68 | TextView txtFileName; 69 | ImageView imageThumbnail; 70 | CardView mCardView; 71 | 72 | VideoHolder(View view){ 73 | super(view); 74 | 75 | txtFileName = view.findViewById(R.id.txt_videoFileName); 76 | imageThumbnail = view.findViewById(R.id.iv_thmnail); 77 | mCardView = view.findViewById(R.id.myCardview); 78 | 79 | 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/videoplayer/videoPlayerActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.videoplayer; 2 | 3 | import android.media.MediaPlayer; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.WindowManager; 7 | import android.widget.MediaController; 8 | import android.widget.VideoView; 9 | 10 | public class videoPlayerActivity extends AppCompatActivity { 11 | 12 | VideoView videoView; 13 | int position = -1; 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_video_player); 18 | 19 | videoView = (VideoView)findViewById(R.id.myPlayer); 20 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 21 | position = getIntent().getIntExtra("position",-1); 22 | getSupportActionBar().hide(); 23 | playerVideo(); 24 | 25 | } 26 | 27 | private void playerVideo() { 28 | 29 | 30 | MediaController mediaController = new MediaController(this); 31 | mediaController.setAnchorView(videoView); 32 | 33 | videoView.setMediaController(mediaController); 34 | videoView.setVideoPath(String.valueOf(MainActivity.fileArrayList.get(position))); 35 | videoView.requestFocus(); 36 | 37 | videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 38 | @Override 39 | public void onPrepared(MediaPlayer mp) { 40 | 41 | videoView.start(); 42 | 43 | } 44 | } 45 | ); 46 | 47 | videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 48 | @Override 49 | public void onCompletion(MediaPlayer mp) { 50 | videoView.setVideoPath(String.valueOf(MainActivity.fileArrayList.get(position = position+1))); 51 | videoView.start(); 52 | } 53 | }); 54 | 55 | } 56 | 57 | @Override 58 | public void onBackPressed() { 59 | super.onBackPressed(); 60 | videoView.stopPlayback(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /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/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-land/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 |