Skip to main content

Display video from any particular folder

Hi, In this post ,I'm going to talk about how to display list of videos from any particular folder of devices.
So frist we will have to decide complete path of folder in which want to extract own data.
Now have a look about this code 
package com.dilip.finalvideo;



import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;



import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;



public class FinalVideoActivity extends Activity {
     private List<String> item = new ArrayList<String>();
   
     private List<String> path = null;
     private String root="/data/jpgs";
     private TextView myPath;
ListView list;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            System.out.println("upper main");
        setContentView(R.layout.menu);
        System.out.println("below main");
        myPath = (TextView)findViewById(R.id.text);
        list=(ListView)findViewById(R.id.lv);
        System.out.println("I am in main");
        getDir(root);
    }
        private void getDir(String dirPath)
        { System.out.println("I am in getDir");
        //String[] fileList=null;
        List<String> title=new ArrayList<String>();
        ArrayList<String> result=new ArrayList<String>();
        String[] fileList=null;
        File videoFiles = new File(root);
       
        if(videoFiles.isDirectory())
        {
            fileList=videoFiles.list();
                  }



       for(int i=0;i<fileList.length;i++)
       {
           Log.e("Video:"+i+" File name",fileList[i]);
           result.add(fileList[i]);
       }
       Log.d("Value of result", result.get(1));
       System.out.println("upper title");
       title=Arrays.asList(fileList);        
        list.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 ,fileList ));



       
         list.setOnItemClickListener(new OnItemClickListener(){



            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
                // TODO Auto-generated method stub
                fun();
                 registerForContextMenu( arg1 );
                 arg1.setLongClickable(false);  // undo setting of this flag in registerForContextMenu
                   // this.openContextMenu(arg1);



                   
            }           
         });
         } 
This code can display list of videos but it doesn't display video thumbnails.


Comments

Popular posts from this blog

Android O New Features Overview

This post assumes, you are an experienced developer who wants to get started with the latest version of Android. Android O is not a huge update to the OS and application framework like M but it still has many useful features for both developer and an user. Android O has focus on below areas. Notification redesigned Picture-in-Picture(PIP)  Visual adaption for different devices  Battery life improved Setting app reorganized Notification redesigned: Android O notification changes includes more easy and manageable way to manager your notification behavior and settings. It includes: Notification Channel: Notification channel allows you to create user customizable channel for each type of notification you wanna display. A single application can have multiple channel, a separate channel for each type of notification you wanna display. Having said this, you can create s separate channel for audio & image notification. User can disable specific notification channel instead

Java 8 Overview

Java 1.8 has introduced major features for the Java developers. It includes various upgrade to the Java programming, JVM, Tools and libraries. The main purpose of Java 1.8 release has been to simplify programming, utilize functional programming benefits and enable parallel programming/processing in Java programming language. Java 1.8 feature  Lambda(->) Expression Functional interfaces Default Methods in interface static method inside interface     Pre defined functional interfaces Predicate Function Consumer ::(Method reference and constructor reference by using double colon(::)operator) Stream API Date & Time API

Overview of how to develop native code with Android NDK:

  Create a jni directory and place native source code under $PROJECT/jni/... Create Android.mk directory and place it under $PROJECT/jni/... to describe source code to the NDK build system. Create Application.mk and place it under $PROJECT/jni/...to describe project in more details to the NDK build system.It is an optional. Finally need to build native source code by running '$NDK/ndk-build' from project directory or it's sub-directory. Android.mk An Android.mk file is a small build script that we write to describe sources to the NDK build system. It's syntax is like this... LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:=hello-jni LOCAL_SRC_FILES:=hello-jni.c include $(BUILD_SHARED_LIBRARY) NDK groups your sources into "modules", where each module can be one of the following: Static library Shared library We can write several module in a single 'Android.mk' or can write seve