当前位置: 首页 > 后端技术 > PHP

开发者进阶之路-UIBPlayer(视频播放)demo分享

时间:2023-03-29 21:04:11 PHP

本文来自APICloud官方论坛UIBPlayer封装了百度云播放器SDK。本模块有UI方案,打开后是一个功能齐全的播放器界面。百度云播放器突破了Android和iOS平台对视频格式的限制,支持目前所有主流媒体格式(mp4、avi、wmv、flv、mkv、mov、rmvb等)。模块亮点介绍:自带UI,用户只需自行设计图标和调整参数即可。双击播放、暂停、手势滑动改变播放进度、屏幕亮度和音量播放,点击唤醒。使用前先去百度开放平台获取AccessKey,并在config.xml文件中进行配置,否则会出现死机等异常。有关说明,请参阅模块文档。直接调用打开接口打开播放器。代码如下:varUIBPlayer=api.require('UIBPlayer');UIBPlayer.open({rect:{x:0,y:0,w:api.winWidth,h:300},videoScalingMode:"FIT_WITH_CROPPING",path:'http://wvideo.spriteapp.cn/video/2016/0328/56f8ec01d9bfe_wpd.mp4',autoPlay:false,enableLooping:true,pauseInBackground:true,coverImg:'widget://image/uibplayer/cover.png',样式:{head:{bg:'rgba(161,161,161,0.5)',height:44,marginTop:api.safeArea.top,hide:false,backBtn:{size:30,backImg:'widget://image/uibplayer/back.png',marginLeft:5},titleLabel:{标题:'蝙蝠侠',size:20,color:'#fff',width:200,numberLines:1,leftMargin:5,backgroundColor:'rgba(0,0,0,0)'},customButtons:[{w:30,h:30,rightMagin:5,img:'widget://image/uibplayer/setting.png',imgSelected:'widget://image/uibplayer/settinged.png',},{w:30,h:30,rightMagin:5,img:'widget://image/uibplayer/mess.png',imgSelected:'widget://image/uibplayer/messed.png',}]},foot:{bg:'rgba(161,161,161,0.5)',height:44,marginBottom:0,hide:false,playBtn:{size:44,playImg:'widget://image/uibplayer/play.png',pauseImg:'widget://image/uibplayer/pause.png',marginLeft:0},currentTimeLabel:{textSize:14,textColor:"#FFF",marginLeft:5},seekBar:{sliderImg:'widget://image/uibplayer/slide.png',progressColor:'#696969',progressSelectedColor:'#333333',marginLeft:5,marginRight:5},totalTimeLabel:{textSize:14,textColor:"#FFF",marginRight:5},fullScreenBtn:{大小:30,img:'widget://image/uibplayer/unfullscreen.png',fullScreenImg:'widget://image/uibplayer/fullscreen.png',marginRight:10}}},修复edOn:api.frameName,固定:false});复制代码不同用户需要去百度开放平台申请一个key,在自己项目的config.xml中配置,提交代码然后编译自定义loader