Android studio downloads videos locally

Recently, I have been studying the problem of downloading videos locally, such as iqiyi, Tencent video, Xunlei look, etc. if half of the video downloaded in a player quit the app and log in again from scratch, it would be too sad. Therefore, when doing video and audio projects, one function to be realized is breakpoint continuation, That is, the video or audio downloaded by the user is stored in the database in the form of byte stream. The next time the user downloads again, it will continue to download the last database, so that the user experience will be very good and the cost will be greatly saved

Well, without much nonsense, let's get to the point today

1、 Effect drawing first

2、 Using greendao, we need to import dependencies

1. The following items are added in gradle dependency

2. Add the following in gradle dependency

3. Since we want to download online, we must not forget the read-write permission

3、 Of course, there are also entity classes. After writing entity classes, make project under build to let him automatically generate the three classes of greendao

4、 I used the singleton mode, so I initialized the database operation in the global configuration

5、 Because we are multithreaded, we write a class that holds the download information of each thread

6、 Write a class to record, modify, add and download, and empty the database

7、 Multi thread download practice class

8、 Write another interface class

9、 Write your own layout file

10、 Present your Java code and mainactivity class

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