Analysis of problems related to playing video files in assets files on Android

This article describes the problems related to Android playing video files in assets files. Share with you for your reference, as follows:

Today, I did a function to play the video files in the project instead of SD card video files.

I started trying to put the video files in the assets file directory.

This is because when the WebView was written to load the assets folder, it was written as follows:

And so on, I try to video Put 3gp in the assets directory and write the following code:

Started the Android system player and prompted some information (not recorded), which roughly means that the file under this path cannot be played / the file under this path cannot be found.

Google said that there is almost no solution on the Chinese Web page. According to the Convention, go http://stackoverflow.com Search the answer and find this post:

I want to play a video from my assets or raw folder in my app inANDROID

The final solution to playing video files in the Android project is:

1. Put the video file under the RES / raw file of the project.

2. The video file must be in the video format supported by Android (3gp, WMV, MP4), and the name must be lowercase letters, data, underline, for example: my_ video_ file. mp4

3. When you reference this resource file in the code, you must use the rstatics class and remove the suffix of the file: r.raw my_ video_ file

4. This activity class should have a helper method getpackagename (), so that you can construct the correct URI in your code.

More readers interested in Android related content can view the special topics of this site: summary of Android multimedia application development skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and solutions to common problems, summary of Android multimedia operation skills (audio, video, recording, etc.), summary of Android basic component usage Summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>