Read/write of video files in raw of Android-Diary

Source: Internet
Author: User

Copy and retrieve thumbnails of multimedia files in the raw folder in Android


1. multimedia files in the raw folder

Get the input stream of the test file in this folder

InputStream is = getResources (). openRawResource (R. raw. test );

Obtain the file name.

String fileName = getResources (). getResourceName (R. raw. test); (package name + file name)

2. For the first installation, write the file to the SD card

SD card read and write permissions:

<! -- Create and delete file permissions in SDCard -->
<Uses-permission android: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS"/>
<! -- Write data to SDCard -->
<Uses-permission android: name = "android. permission. WRITE_EXTERNAL_STORAGE"/>


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0950153296-0.png "title =" raw.png "alt =" 175759743.png"/>

3. Use the VideoView control to play the video file.

Mview. setVideoPath ("file path"); // sets the file path
Mwebview. requestFocus ();
Mwebview. start (); // playback

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0950151V0-1.png "title =" videoview.png "alt =" 180409355.png"/>

Playback controller.

4. Obtain an image in the video file as a thumbnail.

When obtaining thumbnails, use the file path on the SD card. I use the uri of the raw file "android: resource //" + package name + R. raw. test. Therefore, use the path of the SD card ("/mnt/sdcard/xx.mp4 ").

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0950156003-2.png "title =" bitmap.png "alt =" 180819353.png"/>

5. Display thumbnails. Remove the thumbnails during playback and display the VideoView control.

This article is from the "tagmic" blog, please be sure to keep this source http://6315712.blog.51cto.com/6305712/1296613

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.