阅读背景:

Android 实现简单的视频播放

来源:互联网 
<VideoView android:id="@+id/videoView" android:layout_width="match_parent" android:layout_height="251dp" android:layout_gravity="center_horizontal" /> // 加载视屏 String videoUrl = "https://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?" + "filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023" + "&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"; Uri uri = Uri.parse(videoUrl); VideoView videoView = this.findViewById(R.id.videoView); //设置视频控制器 videoView.setMediaController(new MediaController(this)); //播放完成回调 videoView.setOnCompletionListener(new MyPlayerOnCompletionListener()); //设置视频路径 videoView.setVideoURI(uri); //开始播放视频 Button button6 = findViewById(R.id.button6); button6.setOnClickListener(view -> { videoView.start(); }); class MyPlayerOnCompletionListener implements MediaPlayer.OnCompletionListener { @Override public void onCompletion(MediaPlayer mp) { Toast.makeText( LocalVideoActivity.this, "播放完成了", Toast.LENGTH_SHORT).show(); } } <VideoView android:id="@+id/videoView" android:la



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: