查了很多东西,终于发现一个非常不错的第三方框架给大家,直接写用法 1.添加类库 或者将library下载并导入项目中使用 2.添加布局 注意:一定要定死宽高 3.设置视频地址、控制器等 4.在 5.在 6. 下面是在项目中的代码 
gradle  dependencies {     # 必选,内部默认使用系统mediaplayer进行解码     implementation 'com.github.dueeeke.dkplayer:dkplayer-java:3.2.6'      # 可选,包含StandardVideoController的实现     implementation 'com.github.dueeeke.dkplayer:dkplayer-ui:3.2.6'      # 可选,使用exoplayer进行解码     implementation 'com.github.dueeeke.dkplayer:player-exo:3.2.6'      # 可选,使用ijkplayer进行解码     implementation 'com.github.dueeeke.dkplayer:player-ijk:3.2.6'          # 可选,如需要缓存或者抖音预加载功能请引入此库     implementation 'com.github.dueeeke.dkplayer:videocache:3.2.6' }  <com.dueeeke.videoplayer.player.VideoView         android:id="@+id/player"         android:layout_width="match_parent"         android:layout_height="300dp" />
 videoView.setUrl(URL_VOD); //设置视频地址 StandardVideoController controller = new StandardVideoController(this);  controller.addDefaultControlComponent("标题", false); videoView.setVideoController(controller); //设置控制器 videoView.start(); //开始播放,不调用则不自动播放
Activity中 @Override     protected void onPause() {         super.onPause();         videoView.pause();     }      @Override     protected void onResume() {         super.onResume();         videoView.resume();     }      @Override     protected void onDestroy() {         super.onDestroy();         videoView.release();     }           @Override     public void onBackPressed() {         if (!videoView.onBackPressed()) {             super.onBackPressed();         }     }
AndroidManifest.xml中 
<activity     android:name=".PlayerActivity"     android:configChanges="orientation|screenSize|keyboardHidden"     android:screenOrientation="portrait" /> private void setUrl() {     try{         //使用IjkPlayer解码         OCFile file = getIntent().getParcelableExtra("file");         Account mAccount = getIntent().getParcelableExtra("account");         OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, YHLMyVideoActivity.this);         OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton().             getClientFor(ocAccount, YHLMyVideoActivity.this);         String url = client.getBaseUri()+"/remote.php/webdav"+file.getRemotePath();         String userAgent = OwnCloudClientManagerFactory.getUserAgent();         Map<String, String> headers = new HashMap<>();         String authorization = getSharedPreferences("hptk", Context.MODE_PRIVATE)             .getString("Authorization", "");         headers.put("Authorization", authorization);         headers.put(OCS_API_HEADER, OCS_API_HEADER_VALUE);         headers.put("User-Agent", userAgent);         Log_OC.d("aaa","User-Agent = " + userAgent);         Log_OC.d("aaa","authorization = " + authorization);         Log_OC.d("aaa","url = " + url);         //-------------         mVideoView.setPlayerFactory(IjkPlayerFactory.create());         StandardVideoController controller = new StandardVideoController(this);         //根据屏幕方向自动进入/退出全屏         controller.setEnableOrientation(true);         PrepareView prepareView = new PrepareView(this);//准备播放界面         controller.addControlComponent(prepareView);         controller.addControlComponent(new CompleteView(this));//自动完成播放界面         controller.addControlComponent(new ErrorView(this));//错误界面         TitleView titleView = new TitleView(this);//标题栏         controller.addControlComponent(titleView);         VodControlView vodControlView = new VodControlView(this);//点播控制条         //是否显示底部进度条。默认显示         vodControlView.showBottomProgress(true);         controller.addControlComponent(vodControlView);         GestureView gestureControlView = new GestureView(this);//滑动控制视图         controller.addControlComponent(gestureControlView);         //根据是否为直播决定是否需要滑动调节进度         controller.setCanChangePosition(true);         //设置标题         titleView.setTitle("");         mVideoView.setVideoController(controller);         mVideoView.setUrl(url,headers);         //播放状态监听         mVideoView.addOnStateChangeListener(mOnStateChangeListener);         mVideoView.start();      }catch (Exception e){      }  }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算
 官方软件产品操作指南 (170)
官方软件产品操作指南 (170)