快速开始
快速开始
基于 qplayer2-core 的播放器使用
导入头文件
import { QPlayerContextFactory, QIPlayerContext, QLogLevel,QMediaModel,QSurfaceRenderView} from '@qiniu/qplayer2-core/qplayer2-core'
初始化
@State mPlayerContext : QIPlayerContext = QPlayerContextFactory.createPlayerContext(
QLogLevel.LOG_INFO,
(AppStorage.get("context") as Context).filesDir,
bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).versionName,
"",getContext(this) as common.UIAbilityContext)
设置显示视图
一个 QSurfaceRenderView 对应一个 mPlayerContext , 如果一个 mPlayerContext 对应多个 QSurfaceRenderView 无法保证预期效果
QSurfaceRenderView({ mQPlayerContext: this.mPlayerContext, mXComponentId: this.mXComponentId })
.width('100%')
.height('100%')
播放
let builder : QMediaModelBuilder = new QMediaModelBuilder()
builder.addStreamElement("",QPlayerUrlType.QAUDIO_AND_VIDEO,1080,"http://demo-videos.qnsdk.com/qiniu-2023-1080p.mp4",true,"","")
let model : QMediaModel = builder.build(false)
this.mPlayerContext.get_control_handler().playMediaModel(model,0)
销毁
this.mPlayerContext.get_control_handler().release()
文档反馈
(如有产品使用问题,请 提交工单)