Android video download of afinal framework, specify the path

As one of the most popular Android frameworks, the afinal framework has many functions and is mainly divided into the following four modules:                                         

 

1.FinalDB module: The orm framework in android , one line of code can add, delete, modify and check. Support one-to-many, many-to-one and other queries.

 

2.FinalActivity module: The ioc framework in android , UI binding and event binding can be performed in a fully annotated way . No need to findViewById and setClickListener etc.

 

3.FinalHttp module: encapsulates http data requests through httpclient , and supports ajax loading.

 

4.FinalBitmap module: Through FinalBitmap , when imageview loads bitmap , it does not need to consider the phenomenon such as oom and picture dislocation that occur when the android container quickly slides during the bitmap loading process .

<!--EndFragment-->However, today's main test is the function of FinalHttp to download a video from the Internet. If nothing else, you can make a mobile video downloader within half an hour. Specify the download path to a local folder and play it with a local player

Then there are some preparations that need to be done before hitting the code.

================================================================================

One: #ready URL#

There are many articles on the Internet, but without exception, they did not tell me how to find the URL that can download the video, which is the download address. Of course, it may be that I am too naive, and the great gods pass by. Don't laugh at it---although I found a URL It's a bit difficult, but finding a video is absolutely simple, first find a video online:

Step 1: Find the video or album page you need to download

 It will jump to a search page and click on the link of any episode of video:



 Then paste it into the official website of Shuoshu to parse out the download address.

Click for specific details: http://www.flvcd.com/index.htm    Shuoshu's official website, which has detailed answers for beginners (my mother is no longer afraid that I can't find the video download address)

Two: #Prepare to import afinal.jar package#

There are many downloadable packages on the Internet, which can be downloaded by Baidu. The blogger's articles about afinal data storage also have download packages, and students who are interested can find them.

Then import the jar package into libs:



 

 ok everything is ready, just owe the east wind

=================================================================================

Add a textview to the layout file for downloading after clicking and monitoring the download progress and the cache path after downloading

  <TextView
        android:id="@+id/videopress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/image"
        android:layout_below="@+id/image"
        android:layout_marginTop="85dp"
        android:onClick="loadvideo"
        android:text="Click to download video" />

 In MainActivity:

 

 

class loadvideo implements OnClickListener{

		@Override
		public void onClick(View v) {
			//Initialize FinalHttp
			FinalHttp fh=new FinalHttp();
			//file save path
			 File f = new File("/storage/emulated/0/imageloader/video");
			 //If the file path does not exist, create a new one
			 if (!f.exists()) {  
	            f.mkdir();
	        }  
			 //Set the download address, cache address, set support for resuming the download, stop the download task or start the task at any time, Ajax asynchronous loading, start the download
			fh.download("http://f01.v1.cn/group1/M00/13/9F/CgoBNlJINEyACQ0uAGGgCQ1tRfA557.flv",
					"/storage/emulated/0/imageloader/video/岳麓书院.flv",  true,new AjaxCallBack<File>(){
	          //During the download process, count is the file size, current is how much has been downloaded, and a percentage display is made
				public void onLoading(long count, long current) {  
	                vp.setText("Download progress: "+current+"/"+count);  
	           }  

	          //After the download is complete, output the download location  
	           public void onSuccess(File t) {  
	               vp.setText("Download to: "+t==null?"null":t.getAbsoluteFile().toString());  
	           }  

	       });  
		}
		
	}

 So do you think you're done, nonono, remember to add permissions in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />  
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

 It took 4 seconds to download a 6M video here.

Now let's see the effect

=================================================================================

【Effect】:


 

 




 

 
 
 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326616690&siteId=291194637