Android uses vitamio to build its own universal player (10) – local playback (thumbnail, video information, video scanning service)

preface

Vitamio is the sincere work of our team. In addition to building vplayer into the best player of Android, vitamio should also be built into the best player component of Android. Although there are still some problems with the release of the new internal test SDK, it already has high scalability, convenience and many built-in practical functions. Subsequent articles will continue to dig into and introduce the use details and methods of vitamio. This chapter will provide video information such as display thumbnails and video size, and introduce the use of vitamio's built-in content provider and file scanning service.

be careful

The ContentProvider in this chapter can no longer be used in the SDK released on August 31, 2012. The usage will be updated in subsequent articles.

series

1. Android uses vitamio to build its own universal player (1) -- ready

2. Android uses vitamio to build its own universal player (2) - gesture to control brightness, volume and zoom

3. Android uses vitamio to build its own universal player (3) - local playback (main interface, video list)

4. Android uses vitamio to build its own universal player (4) - local playback (fast search, data storage)

5. Android uses vitamio to build its own universal player (5) -- online play (play Youku Video)

6. Android uses vitamio to build its own universal player (6) - online play (playlist)

7. Android uses vitamio to build its own universal player (7) - play online (download video)

8. Android uses vitamio to build its own universal player (8) -- detail optimization

9. Android uses vitamio to build its own universal player (9) -- online play (online TV)

text

1、 Target

1.1 obtain video thumbnails, etc

The previous articles are the video file information obtained by scanning. Here is the code for obtaining video thumbnails and video broadband. Please refer to part 2.1 of the article.

1.2 calling the scanning service of vitamio

The new SDK has built-in video scanning service, which provides all the data required for local video playback.

2、 Realize

2.1 scan and obtain the thumbnail, width and height of the video by yourself

Code Description:

a) The size of thumbnails can be adjusted. You can see the default size.

b) The code here is that the thumbnail exists under the current video path by default, and the file name is the same as the video name, with an additional JPG suffix.

2.2 calling video scanning service of vitamio

2.2.1 AndroidManifest.xml

Code Description:

It mainly refers to the registration of mediascannerservice service and mediascannerreceiver listener.

2.2.2 start the scanning service (mainframe activity)

Code Description:

The opreference object encapsulates the SharedPreferences stored data. Here, it is determined whether to start the application for the first time. If yes, start the video scanning service.

2.2.3 obtaining data (fragmentfile)

Code Description:

a) . fragmentfile inherits loadercallbacks < cursor >, you can search the relevant information.

b) Where video.media.data is the path of the video.

c) . method of taking thumbnail:

Video.Thumbnails.getThumbnail(ctx.getApplicationContext(),ctx.getContentResolver(),_id,Video.Thumbnails.MICRO_KIND,null)

This "_id" is video.media_ ID and thumbnail are stored in SD. You can add some cache processing by yourself.

3、 Precautions

3.1 before starting the video service scanning, it is necessary to ensure that the decoding library has been decompressed, that is, the calling code: libschecker.checkvitamiolibs

3.2 ensure that mediascannerservice is in the same process as the current application, that is, do not specify its Android: process, otherwise the video scanning service cannot be used.

3.3 at present, there is still a problem in the broadcast reception, that is, it is impossible to know whether the scan has been completed. The current method is to judge whether there is the service 5 seconds after each data change. If there is no service, it means that the scanning has been completed. See the method mediascannerreceiver.isservicerunning.

Decoding library

https://bitbucket.org/ABitNo/ffmpegandroid

http://vplayer.net The link has been given at the bottom of the home page. Note that the code will not be synchronized in real time. Friends in need can refer to it.

4、 Oplayer

4.1 download

Please move #taocode (SVN):

Project address: http://code.taobao.org/p/oplayer

Svn address: http://code.taobao.org/svn/oplayer/

4.2 update

a) . move the SD remaining capacity to the bottom and display the loading icon on its left.

b) . keep the original fragmentfile as fragmentfildold, and the new version has been switched to use the built-in video scanning service of vitamio.

c) . change the adapter to cursoradapter, update the functions of A-Z and participate in code update.

d) . preference is added to store general setting data, such as whether to start for the first time.

5、 Supplementary notes

It has been emphasized in the SDK release version. Here again:

5.1 vitamio related projects cannot exist on the same device at the same time, nor can they coexist with vplayer. This is a known bug, which will be solved in the next version.

5.2 the example project of vitamio needs to be compiled above API level14, but the minimum version can support more than 7 (Android: minsdkversion = "7"). You can delete the values-v11 and values-v14 folders. Vitamio is compatible with Android version 2.1 or above in the current project. You can try it.

5.3 there may be several reasons why the network video cannot be played and is very slow:

a) Your Internet speed is not good

b) The video server does not work, or its bandwidth is insufficient

c) It may be a problem with the playback component. We are still making continuous improvement and increasing the optimization of network playback. Thank you for your understanding and support.

In this case, if it is convenient, please send us the video test address and attach a brief description. ( vplayer@yixia.com )

5.4 the problem of initializing the decoded packet interface remains

Generally, there is only one reason for this: there are other vitamio related items on your device. Refer to 5.1.

end

This article took me at least 10 hours. I stayed up until 2 o'clock last night in order to solve the doubts of users and finally better serve users. If the documents are not complete enough, please share the usage methods, skills and precautions with you in this way. Please understand.

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
分享
二维码
< <上一篇
下一篇>>