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.


Popular posts from this blog

Display video from specific folder with rounded shape thumbnail

Hi friends ,This is complete post, about how to display video form specific folder and display it with rounded shape and play it on click event. For Rounded shape I have used custom ImageView.
Now have a look on code part.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:columnWidth="100dp"
    android:gravity="center"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth" >



</GridView>
gridlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="verti…

Custom Volley-Gson request implementation

This page covers Volley-Gson integration and also Volley custom Request. We assume that, you are familiar with Volley and Gson.

Volley has some inbuilt request which you can use, if your response is a String, Image, or JSON, in that case, you don't need to implement a custom Request.  To use Gson with Volley, we need to implement a custom request.
To make a custom request, you need to perform following operation.
Extend Request<T> class, where T is the type of parsed response or expected response. Implement the abstract methods parseNetworkResponse() and deliverResponse().  parseNetworkResponse:  A response contains parse response of a given type i.e Gson.

@Override
    protected Response<T> parseNetworkResponse(NetworkResponse response) {
        try {
            String json = new String(
                    response.data, HttpHeaderParser.parseCharset(response.headers));
            if (BuildConfig.IS_DEBUG)
                Log.d(TAG, "Response :: " + …

Display News and Videos through RSS and Display it in Listview

Hi friends , In this tutorial ,i'm going to describe about how to fetch data from rss feed.Here i had also problem ,when i was developing my recent project.I had also faced  many problem and at last i developed my best project.



Here is the code that describe how to fetch news headline from rss
This class describes how to parse XML data:
import java.net.URL;
import java.util.ArrayList;



import org.xmlpull.v1.XmlPullParser;



import android.content.res.XmlResourceParser;
import android.util.Log;
import android.util.Xml;



public class XmlFeedParser {

    //Feed Parsing Method
    public ArrayList<Implement> parse(String url) {

        //Array of Episode Objects
        ArrayList<Implement> episodes = null;

        try {
            //Encode the URL into a URL Object
            URL episode_feed_url = new URL(url);

            //Open a Connection to the feed
            XmlPullParser parser = Xml.newPullParser();
            try {
                parser.setInput(episode_feed_url.o…