先前做了一个小视频的功能,里面有播放多个视频的功能,为了效率,我加了视频缓存功能;
一方面耗费用户的流量,另一方面直接从本地播放要更流畅
网上看资料,一个视频缓存库,使用起来很方便,还不错,就分享给大家
//视频缓存
implementation 'com.danikula:videocache:2.7.1'
效果
代码:
public class MainActivity extends AppCompatActivity {
private static final int MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE = 1;
String url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = findViewById(R.id.videoView);