当前位置: 首页> 文旅> 艺术 > 微信小程序怎么关闭未成年模式_武汉seo技术是什么_哈尔滨关键词优化方式_方法seo

微信小程序怎么关闭未成年模式_武汉seo技术是什么_哈尔滨关键词优化方式_方法seo

时间:2025/7/14 15:33:45来源:https://blog.csdn.net/lixinxiaos/article/details/144211298 浏览次数:1次
微信小程序怎么关闭未成年模式_武汉seo技术是什么_哈尔滨关键词优化方式_方法seo

一个老牌子的播放器了,项目可能已经有些日子没有维护了。但是使用效果还是不错的。支持多种视频格式,及重力感应、调节亮度等多种效果。想来想去,还是记录下来,我会在文章的最后注明github地址:
首先引入依赖:

gradlerepositories {mavenCentral()
}dependencies {# 必选,内部默认使用系统mediaplayer进行解码implementation 'xyz.doikki.android.dkplayer:dkplayer-java:3.3.7'# 可选,包含StandardVideoController的实现implementation 'xyz.doikki.android.dkplayer:dkplayer-ui:3.3.7'# 可选,使用exoplayer进行解码implementation 'xyz.doikki.android.dkplayer:player-exo:3.3.7'# 可选,使用ijkplayer进行解码implementation 'xyz.doikki.android.dkplayer:player-ijk:3.3.7'# 可选,如需要缓存或者抖音预加载功能请引入此库implementation 'xyz.doikki.android.dkplayer:videocache:3.3.7'
}

首先需要引入相关依赖,需要注意,播放器内部默认使用系统MediaPlayer进行解码

 VideoViewManager.setConfig(VideoViewConfig.newBuilder()//使用使用IjkPlayer解码.setPlayerFactory(IjkPlayerFactory.create())//使用ExoPlayer解码.setPlayerFactory(ExoMediaPlayerFactory.create())//使用MediaPlayer解码.setPlayerFactory(AndroidMediaPlayerFactory.create()).build());

然后就是在xml中引入使用:

<xyz.doikki.videoplayer.player.VideoViewandroid: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(); //开始播放,不调用则不自动播放

生命周期的回调:

@Overrideprotected void onPause() {super.onPause();videoView.pause();}@Overrideprotected void onResume() {super.onResume();videoView.resume();}@Overrideprotected void onDestroy() {super.onDestroy();videoView.release();}@Overridepublic void onBackPressed() {if (!videoView.onBackPressed()) {super.onBackPressed();}}

在AndroidManifest.xml中

<activityandroid:name=".PlayerActivity"android:configChanges="orientation|screenSize|keyboardHidden"android:screenOrientation="portrait" /> <!-- or android:screenOrientation="landscape"-->

最后就是关于临时切换解码器的代码:

//使用IjkPlayer解码
mVideoView.setPlayerFactory(IjkPlayerFactory.create());
//使用ExoPlayer解码
mVideoView.setPlayerFactory(ExoMediaPlayerFactory.create());
//使用MediaPlayer解码
mVideoView.setPlayerFactory(AndroidMediaPlayerFactory.create());

到此,是正常的代码使用。下面是github地址:
https://github.com/Doikki/DKVideoPlayer/wiki

不过我在使用时,封装了一个工具类,以及添加阿里云的播放器解码。如果需要请看下面的文章:
DKVideoPlayer播放器之AliyunPlayer解码

关键字:微信小程序怎么关闭未成年模式_武汉seo技术是什么_哈尔滨关键词优化方式_方法seo

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: