快速开始
快速开始
基于qplayer2-core的播放器使用
初始化
在对应布局文件xml中加入播放器控件
<com.qiniu.qmedia.ui.QSurfacePlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.qiniu.qmedia.ui.QSurfacePlayerView>
初始化播放器代码建议放在Activity的onCreate
中或者是Fragment的onCreate
中
mQSurfacePlayerView = findViewById(R.id.player_view)
mQSurfacePlayerView.playerControlHandler.init(this)
mQSurfacePlayerView.playerControlHandler.setDecodeType(QPlayerSetting.QPlayerDecoder.QPLAYER_DECODER_SETTING_AUTO)
mQSurfacePlayerView.playerControlHandler.setDecodeType(QPlayerSetting.QPlayerDecoder.QPLAYER_DECODER_SETTING_AUTO)
mQSurfacePlayerView.playerControlHandler.setSeekMode(QPlayerSetting.QPlayerSeek.QPLAYER_SEEK_SETTING_NORMAL)
mQSurfacePlayerView.playerControlHandler.setStartAction(QPlayerSetting.QPlayerStart.QPLAYER_START_SETTING_PLAYING)
mQSurfacePlayerView.playerControlHandler.setSpeed(1.0)
播放
builder = QMediaModelBuilder()
url = "http://demo-videos.qnsdk.com/movies/qiniu.mp4"
builder.addStreamElement("", QURLType.QAUDIO_AND_VIDEO, 0, url, true)
var mediaModel = builder.build(false))
mQSurfacePlayerView.playerControlHandler.playMediaModel(mediaModel, 0)
销毁
销毁代码建议放在Activity的onDestroy
中或者Fragment的onDestroy
中
mQSurfacePlayerView.playerControlHandler.release()
文档反馈
(如有产品使用问题,请 提交工单)