This commit is contained in:
2024-07-17 14:06:06 +08:00
parent 5c589a22fa
commit 11e9354b54
278 changed files with 331052 additions and 3935 deletions

View File

@@ -1,772 +0,0 @@
<template>
<div class="prism-player" :id="playerId" :style="playStyle"></div>
</template>
<script>
export default {
name: "Aliplayer",
props: {
source: {
type: String,
default: ""
},
//媒体转码服务的媒体Id。
vid: {
type: String,
default: ""
},
//播放权证
playauth: {
type: String,
default: ""
},
//容器的大小
height: {
type: String,
default: "460px"
},
//容器的大小
width: {
type: String,
default: "100%"
},
//视频的高度大小
videoWidth: {
type: String,
default: "100%"
},
//视频的宽度大小
videoHeight: {
type: String,
default: "460px"
},
//播放器自动加载目前仅h5可用
preload: {
type: Boolean,
default: false
},
//播放器默认封面图片请填写正确的图片url地址。需要autoplay为false才生效
cover: {
type: String,
default: ""
},
//播放内容是否为直播,直播时会禁止用户拖动进度条。
isLive: {
type: Boolean,
default: false
},
//播放器是否自动播放在移动端autoplay属性会失效。
autoplay: {
type: Boolean,
default: false
},
//播放器自动循环播放。
rePlay: {
type: Boolean,
default: false
},
//指定使用H5播放器。
useH5Prism: {
type: Boolean,
default: false
},
//指定使用Flash播放器。
useFlashPrism: {
type: Boolean,
default: false
},
//H5是否内置播放有的Android浏览器不起作用。
playsinline: {
type: Boolean,
default: false
},
//显示播放时缓冲图标默认true。
showBuffer: {
type: Boolean,
default: true
},
//URL 皮肤图片,不建议随意修改该字段,如要修改,请参照皮肤定制。
skinRes: {
type: String,
default: ""
},
//进度条
skinLayout: {
type: Array,
default: function () {
return [{
"name": "bigPlayButton",
"align": "cc",
"x": 30,
"y": 80
},
{
"name": "errorDisplay",
"align": "tlabs",
"x": 0,
"y": 0
},
{
"name": "infoDisplay"
},
{
"name": "controlBar",
"align": "blabs",
"x": 0,
"y": 0,
"children": [
{name: "progress", align: "blabs", x: 0, y: 44}, //播放进度条
{name: "playButton", align: "tl", x: 15, y: 12}, //播放开始暂停按钮
{name: "timeDisplay", align: "tl", x: 10, y: 7}, //播放视频时间
{
"name": "fullScreenButton", //全屏按钮
"align": "tr",
"x": 10,
"y": 10
},
{
"name": "volume", //音量
"align": "tr",
"x": 5,
"y": 10
}
]
}]
}
},
//默认为hover。可选的值为clickhoveralways
controlBarVisibility: {
type: String,
default: "hover"
},
//控制栏自动隐藏时间ms
showBarTime: {
type: String,
default: ""
},
/***
* JSON串用于定制性接口参数目前支持
1.“fullTitle”“测试页面”
全屏时显示视频标题仅flash支持
2. “m3u8BufferLength”“30”
播放m3u8时加载缓存ts文件长度单位仅flash支持
3. “liveStartTime”“2016/08/17 12:00:00”
直播开始时间,用于提示直播未开始(仅flash支持)。
4. “liveOverTime”“2016/08/17 14:00:00”
直播结束时间用于提示直播结束仅flash支持
*/
extraInfo: {
type: String,
default: ""
},
/**
*是否允许系统右键菜单显示默认为false。
*/
enableSystemMenu: {
type: Boolean,
default: false
},
/***
*
*指定播放地址格式只有使用vid的播放方式时支持
可选值为mp4m3u8flvmp3默认为空仅H5支持。
* */
format: {
type: String,
default: "m3u8"
},
/***
*
* 指定返回音频还是视频只有使用vid的播放方式时支持。
可选值为videoaudio默认为video
audio主要是针对只包含音频的视频格式比如音频的mp4仅H5支持。
* */
mediaType: {
type: String,
default: "video"
},
/***
* 指定排序方式只有使用vid + plauth播放方式时支持。
desc表示按倒序排序从大到小排序
asc表示按正序排序从小到大排序
默认值asc仅H5支持。
* */
qualitySort: {
type: String,
default: "asc"
},
/***
* 显示视频清晰度多个用逗号分隔比如FD,LD此值是vid对应流清晰度的一个子集
取值范围FD流畅LD标清SD高清HD超清OD原画2K2K4K4K仅H5支持。
* */
definition: {
type: String,
default: ""
},
/**
* 默认视频清晰度此值是vid对应流的一个清晰度
取值范围FD流畅LD标清SD高清HD超清OD原画2K2K4K4K仅H5支持。
* */
defaultDefinition: {
type: String,
default: ""
},
/**
* 声明启用同层H5播放器启用时设置的值为h5
* */
x5_type: {
type: String,
default: "h5"
},
/**
* 声明视频播放时是否进入到TBS的全屏模式默认为false。
当需要把视频做为背景时设置为true
* */
x5_fullscreen: {
type: Boolean,
default: false
},
/**
* 声明视频播在界面上的位置默认为“center”。
可选值为“top”“center”
* */
x5_video_position: {
type: String,
default: "center"
},
/**
* 声明 TBS 播放器支持的方向,可选值:
landscape:横屏)
portraint:竖屏
landscape
* */
x5_orientation: {
type: String,
default: "portraint"
},
/**
* 声明TBS全屏播放是否横屏默认值为true。
* */
x5LandscapeAsFullScreen: {
type: String,
default: "true"
},
/**
* 延迟播放时间,单位为秒。
* */
autoPlayDelay: {
type: Number,
default: 0
},
/**
* 延迟播放提示文本
* */
autoPlayDelayDisplayText: {
type: String,
default: "正在转码,请稍后......"
},
/**
* 国际化默认为zh-cn
如果未设置,则采用浏览器语言。
可选值为zh-cnen-us或其它值。
* */
language: {
type: String,
default: "zh-cn"
},
/**
* 自定义国际化文本json结构key的值需要和language属性值对应起来。
例子:{jp:{Play:”Play”}}
* */
languageTexts: {
type: Object,
default: function () {
return {}
}
},
/**
* flash启用截图功能
* */
snapshot: {
type: Boolean,
default: false
},
/**
* H5设置截图水印。
* */
snapshotWatermark: {
type: Object,
default: function () {
return {}
}
},
/**
* Safari浏览器可以启用Hls插件播放Safari 11除外。
* */
useHlsPluginForSafari: {
type: Boolean,
default: false
},
/**
* H5播放flv时设置是否启用播放缓存只在直播下起作用。
* */
enableStashBufferForFlv: {
type: Boolean,
default: false
},
/**
* H5播放flv时初始缓存大小只在直播下起作用。
* */
stashInitialSizeForFlv: {
type: Number,
default: 10
},
/**
* 缓冲多长时间后提示用户切换低清晰度默认20秒。
* */
loadDataTimeout: {
type: Number,
default: 20
},
/**
*最大缓冲超时时间超过这个时间会有错误提示默认60秒。
* */
waitingTimeout: {
type: Number,
default: 60
},
/**
* 直播开始时间直播时移功能使用格式为“2018/01/04 12:00:00”。
* */
liveStartTime: {
type: String,
default: ""
},
/**
* 直播结束时间直播时移功能使用格式为“2018/01/04 12:00:00”。
* */
liveOverTime: {
type: String,
default: ""
},
/**
* 直播可用时移查询地址,详情参见直播时移。
* https://help.aliyun.com/document_detail/65129.html?spm=a2c4g.11186623.2.28.3603bf80LR74sS
* */
liveTimeShiftUrl: {
type: String,
default: ""
},
/**
* flv直播和hls时移切换是重新创建播放器方法详情参见直播时移。
* https://help.aliyun.com/document_detail/65129.html?spm=a2c4g.11186623.2.28.3603bf80LR74sS
* */
recreatePlayer: {
type: Function,
default: function () {
}
},
/**
*是否显示检测按钮默认为true。
* */
diagnosisButtonVisible: {
type: Boolean,
default: true
},
/**
* 禁用进度条的Seek默认为false仅Flash支持。
* */
disableSeek: {
type: Boolean,
default: false
},
/**
* 加密类型播放点播私有加密视频时设置值为1默认值为0。
* */
encryptType: {
type: Number,
default: 0
},
/**
* 进度条打点内容数组,详情参见进度条打点。
* [
{offset:0,text:'阿里视频云端到云到端服务的重要一环'},
{offset:10,text:'除了支持点播和直播的基础播放功能外'},
{offset:20,text:'深度融合视频云业务'},
{offset:30,text:'为用户提供简单、快速、安全、稳定的视频播放服务'},
{offset:40,text:'安装播放器Demo进行体验'},
{offset:50,text:'开发人员请点击SDK下载'}
]
* https://yq.aliyun.com/articles/686043?spm=a2c4g.11186623.2.31.3603bf80LR74sS
* */
progressMarkers: {
type: Array,
default: function () {
return []
}
},
/**
* 点播失败重试次数默认3次
* */
vodRetry: {
type: Number,
default: 3
},
/**
* 直播播放失败重试次数默认5次
* */
liveRetry: {
type: Number,
default: 5
},
playStyle: {
type: String,
default: ""
},
aliplayerSdkPath: {
// Aliplayer 代码的路径
type: String,
default: "https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-min.js"
},
},
data() {
return {
playerId: "aliplayer_" + Math.random().toString(36).substr(2),
scriptTagStatus: 0,
isReload: false,
instance: null
};
},
created() {
if (window.Aliplayer !== undefined) {
// 如果全局对象存在,说明编辑器代码已经初始化完成,直接加载编辑器
this.scriptTagStatus = 2;
this.initAliplayer();
} else {
// 如果全局对象不存在,说明编辑器代码还没有加载完成,需要加载编辑器代码
this.insertScriptTag();
}
},
mounted() {
if (window.Aliplayer !== undefined) {
// 如果全局对象存在,说明编辑器代码已经初始化完成,直接加载编辑器
this.scriptTagStatus = 2;
this.initAliplayer();
} else {
// 如果全局对象不存在,说明编辑器代码还没有加载完成,需要加载编辑器代码
this.insertScriptTag();
}
},
methods: {
insertScriptTag() {
const _this = this;
let playerScriptTag = document.getElementById("playerScriptTag");
// 如果这个tag不存在则生成相关代码tag以加载代码
if (playerScriptTag === null) {
playerScriptTag = document.createElement("script");
playerScriptTag.type = "text/javascript";
playerScriptTag.src = this.aliplayerSdkPath;
playerScriptTag.id = "playerScriptTag";
let s = document.getElementsByTagName("head")[0];
s.appendChild(playerScriptTag);
}
if (playerScriptTag.loaded) {
_this.scriptTagStatus++;
} else {
playerScriptTag.addEventListener("load", () => {
_this.scriptTagStatus++;
playerScriptTag.loaded = true;
_this.initAliplayer();
});
}
_this.initAliplayer();
},
initAliplayer() {
const _this = this;
// scriptTagStatus 为 2 的时候,说明两个必需引入的 js 文件都已经被引入,且加载完成
if (
_this.scriptTagStatus === 2 &&
(_this.instance === null || _this.reloadPlayer)
) {
_this.instance && _this.instance.dispose();
document.querySelector("#" + _this.playerId).innerHTML = "";
// Vue 异步执行 DOM 更新,这样一来代码执行到这里的时候可能 template 里面的 script 标签还没真正创建
// 所以,我们只能在 nextTick 里面初始化 Aliplayer
_this.$nextTick(() => {
_this.instance = window.Aliplayer({
id: _this.playerId,
source: _this.source,
vid: _this.vid,
playauth: _this.playauth,
width: _this.width,
height: _this.height,
videoWidth: _this.videoWidth,
videoHeight: _this.videoHeight,
preload: _this.preload,
cover: _this.cover,
isLive: _this.isLive,
autoplay: _this.autoplay,
rePlay: _this.rePlay,
useH5Prism: _this.useH5Prism,
useFlashPrism: _this.useFlashPrism,
playsinline: _this.playsinline,
showBuffer: _this.showBuffer,
skinRes: _this.skinRes,
skinLayout: _this.skinLayout,
controlBarVisibility: _this.controlBarVisibility,
showBarTime: _this.showBarTime,
extraInfo: _this.extraInfo,
enableSystemMenu: _this.enableSystemMenu,
format: _this.format,
mediaType: _this.mediaType,
qualitySort: _this.qualitySort,
definition: _this.definition,
defaultDefinition: _this.defaultDefinition,
x5_type: _this.x5_type,
x5_fullscreen: _this.x5_fullscreen,
x5_video_position: _this.x5_video_position,
x5_orientation: _this.x5_orientation,
x5LandscapeAsFullScreen: _this.x5LandscapeAsFullScreen,
autoPlayDelay: _this.autoPlayDelay,
autoPlayDelayDisplayText: _this.autoPlayDelayDisplayText,
language: _this.language,
languageTexts: _this.languageTexts,
snapshot: _this.snapshot,
snapshotWatermark: _this.snapshotWatermark,
useHlsPluginForSafari: _this.useHlsPluginForSafari,
enableStashBufferForFlv: _this.enableStashBufferForFlv,
stashInitialSizeForFlv: _this.stashInitialSizeForFlv,
loadDataTimeout: _this.loadDataTimeout,
waitingTimeout: _this.waitingTimeout,
liveStartTime: _this.liveStartTime,
liveTimeShiftUrl: _this.liveTimeShiftUrl,
liveShiftSource: _this.liveShiftSource,
recreatePlayer: _this.recreatePlayer,
diagnosisButtonVisible: _this.diagnosisButtonVisible,
disableSeek: _this.disableSeek,
encryptType: _this.encryptType,
progressMarkers: _this.progressMarkers,
vodRetry: _this.vodRetry,
liveRetry: _this.liveRetry,
});
// 绑定事件,当 AliPlayer 初始化完成后,将编辑器实例通过自定义的 ready 事件交出去
_this.instance.on("ready", () => {
this.$emit("ready", _this.instance);
});
_this.instance.on("play", () => {
this.$emit("play", _this.instance);
});
_this.instance.on("pause", () => {
this.$emit("pause", _this.instance);
});
_this.instance.on("ended", () => {
this.$emit("ended", _this.instance);
});
_this.instance.on("liveStreamStop", () => {
this.$emit("liveStreamStop", _this.instance);
});
_this.instance.on("m3u8Retry", () => {
this.$emit("m3u8Retry", _this.instance);
});
_this.instance.on("hideBar", () => {
this.$emit("hideBar", _this.instance);
});
_this.instance.on("waiting", () => {
this.$emit("waiting", _this.instance);
});
_this.instance.on("snapshoted", () => {
this.$emit("snapshoted", _this.instance);
});
_this.instance.on("timeupdate", () => {
this.$emit("timeupdate", _this.instance);
});
_this.instance.on("requestFullScreen", () => {
this.$emit("requestFullScreen", _this.instance);
});
_this.instance.on("cancelFullScreen", () => {
this.$emit("cancelFullScreen", _this.instance);
});
_this.instance.on("error", () => {
this.$emit("error", _this.instance);
});
let start = true;
let startProgress = 0;
let endProgress = 0;
//禁止拖动进度条
_this.instance.on("startSeek", (e) => {
if (start) {
start = false;
startProgress = _this.instance.getCurrentTime();
}
_this.instance.pause();
// this.$emit("startSeek", _this.instance);
});
//禁止拖动进度条
_this.instance.on("completeSeek", () => {
start = true;
endProgress = _this.instance.getCurrentTime();
if (endProgress < startProgress) {
_this.instance.seek(endProgress);
} else {
_this.instance.seek(startProgress);
}
_this.instance.play();
// this.$emit("completeSeek", _this.instance);
});
});
}
},
/**
* 播放视频
*/
play: function () {
this.instance.play();
},
/**
* 暂停视频
*/
pause: function () {
this.instance.pause();
},
/**
* 重播视频
*/
replay: function () {
this.instance.replay();
},
/**
* 跳转到某个时刻进行播放
* @argument time 的单位为秒
*/
seek: function (time) {
this.instance.seek(time);
},
/**
* 获取当前时间 单位秒
*/
getCurrentTime: function () {
return this.instance.getCurrentTime();
},
/**
*获取视频总时长,返回的单位为秒
* @returns 返回的单位为秒
*/
getDuration: function () {
return this.instance.getDuration();
},
/**
获取当前的音量返回值为0-1的实数ios和部分android会失效
*/
getVolume: function () {
return this.instance.getVolume();
},
/**
设置音量vol为0-1的实数ios和部分android会失效
*/
setVolume: function (vol) {
this.instance.setVolume(vol);
},
/**
*直接播放视频urltime为可选值单位秒目前只支持同种格式mp4/flv/m3u8之间切换暂不支持直播rtmp流切换
*@argument url 视频地址
*@argument time 跳转到多少秒
*/
loadByUrl: function (url, time) {
this.instance.loadByUrl(url, time);
},
/**
* 设置播放速度
*@argument speed 速度
*/
setSpeed: function (speed) {
this.instance.setSpeed(speed);
},
/**
* 设置播放器大小w,h可分别为400px像素或60%百分比chrome浏览器下flash播放器分别不能小于397x297
*@argument w 播放器宽度
*@argument h 播放器高度
*/
setPlayerSize: function (w, h) {
this.instance.setPlayerSize(w, h);
},
/**
*目前只支持H5播放器。
暂不支持不同格式视频间的之间切换。
暂不支持直播rtmp流切换。
*/
replayByVidAndPlayAuth: function (vid, accId, accSecret, stsToken, authInfo, domainRegion) {
this.instance.replayByVidAndPlayAuth(vid, accId, accSecret, stsToken, authInfo, domainRegion);
},
/***
* 重新设置vid和权限目前只支持H5播放器。
暂不支持不同格式视频间的之间切换。
暂不支持直播rtmp流切换。
* @param vid 视频ID
* @param playauth 播放权限
*/
replayByVidAndAuthInfo: function (vid, playauth) {
this.instance.replayByVidAndAuthInfo(vid, playauth);
},
/**
* 目前只支持HTML5界面上的重载功能,暂不支持直播rtmp流切换m3u8之间切换,暂不支持直播rtmp流切换
*@argument vid 视频id
*@argument playauth 播放凭证
*/
reloaduserPlayInfoAndVidRequestMts: function (vid, playauth) {
this.instance.reloaduserPlayInfoAndVidRequestMts(vid, playauth);
},
/***
*设置截图参数
* @param width 宽度
* @param height 高度
* @param rate 截图质量
*/
setSanpshotProperties: function (width, height, rate) {
this.instance.setSanpshotProperties(width, height, rate);
},
/**
* 设置封面地址
* @param cover 封面地址
*/
setCover: function (cover) {
this.instance.setCover(cover);
},
reloadPlayer: function () {
this.isReload = true;
this.initAliplayer();
this.isReload = false;
}
}
};
</script>
<style>
@import url(https://g.alicdn.com/de/prismplayer/2.9.3/skins/default/aliplayer-min.css);
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -629,8 +629,8 @@ setTimeout(()=>{
const s_tag = document.createElement('script'); // 引入播放器js
s_tag.type = 'text/javascript';
// s_tag.src = 'https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-min.js';
s_tag.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js';
s_tag.src = 'https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-min.js';
// s_tag.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/aliplayer-min.js';
// s_tag.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/aliplayer-min.js';
s_tag.charset = 'utf-8';
s_tag.onload = () => {

View File

@@ -813,8 +813,7 @@ export default {
if (this.videoData.type == 1) {
playerOptions = {
...playerOptions,
source:"https://video.taihumed.com/d0c8e6d23e5f71ef81714531858c0102/c27e8334925a485bb7d57b46463f24ab-75b0e05b7a76efaff190b6417b2168a7-sd-nbv1-encrypt-stream.m3u8",
"playauth": this.videoData.playAuth, // 必选参数参数值可通过调用GetVideoPlayAuth接口获取。
"playauth": this.videoData.playAuth, // 必选参数参数值可通过调用GetVideoPlayAuth接口获取。
"encryptType": 1, // 必选参数当播放私有加密流时需要设置本参数值为1。其它情况无需设置。
"playConfig": {
"EncryptType": 'AliyunVoDEncryption'

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<template>
<view class="container" style="background-color: #fff; position: relative">
<view class="container" style="background-color: #000; position: relative">
<!-- <u-icon
@click="goBack"
name="arrow-left"
@@ -9,29 +9,78 @@
statusBarHeight + 2
}px; left: ${10}px;z-index: 999;`"
></u-icon>-->
<view style="width: 100%">
<common-list-aliyun
v-if="isSetFirstTime && videoData.playAuth"
:encryptType="1"
:vid="videoData.video"
:playauth="videoData.playAuth"
ref="player"
:useFlashPrism="false"
:autoplay="true"
:isLive="false"
:showBuffer="true"
:cover="cover"
:showBarTime="true"
:disableSeek="true"
showBarTime="500"
controlBarVisibility="always"
<!-- <zhimi_aliplayer_view
ref="playerView"
style="width: 100%; height: 300px"
></zhimi_aliplayer_view>
<button type="primary" @click="start()">开始</button>
<button type="primary" @click="pause()">暂停</button> -->
<view style="width: 100%; height: 200px">
<div
class=""
style="background-color: #000"
ref="videoContent"
@tap="renderScript.handleClick"
id="url-player-test"
:videoData="videoData"
:winWidth="winWidth"
:winHeight="winHeight"
:currentVideoList="currentVideoList"
:firstTime="firstTime"
:isfresh="isfresh"
:platform="platform"
:isSetFirstTime="isSetFirstTime"
:isChange="isChange"
:change:videoData="renderScript.receiveMsg"
:change:winWidth="renderScript.receiveWinWidth"
:change:winHeight="renderScript.receiveWinHeight"
:change:firstTime="renderScript.receiveFirstTime"
:change:isSetFirstTime="renderScript.receiveisSetFirstTime"
:change:isfresh="renderScript.receiveIsfresh"
:change:platform="renderScript.receiveplatform"
:change:isChange="renderScript.receiveIsChange"
:change:currentVideoList="renderScript.receiveVideoList"
></div>
<div @tap="renderScript.emitData" ref="videoContent1" v-show="false">
直接调用renderjs中的emitData的方法,传递当前播放时长
</div>
<div @tap="renderScript.endEmitData" ref="videoContent2" v-show="false">
监听结束方法记录播放时长
</div>
<div
@tap="renderScript.changeVideoData"
ref="videoContent3"
v-show="false"
>
</common-list-aliyun>
监听切换视频方法
</div>
<div @tap="renderScript.emitSetData" ref="videoContent4" v-show="false">
监听切换视频方法
</div>
<div class="fullScreenButton-container">
<div
:class="`prism-fullscreen-btn ${isFullScreen ? 'fullscreen' : ''}`"
@tap="renderScript.changeVideoScreen"
></div>
</div>
</view>
<!-- <view style="width: 100%; height: 200px; position: relative" v-else>
<video
@timeupdate="videoTimeUpdateEvent($event)"
ref="videos"
style="width: 100%; height: 100%"
autoplay
id="videoId"
object-fit="contain"
class="video-box"
:src="videoUrl"
:poster="`${videoUrl}?x-oss-process=video/snapshot,t_${1},f_jpg`"
@play="playVideo"
>
</video>
</view> -->
</view>
</template>
<script>
@@ -105,9 +154,44 @@ export default {
},
//第一次加载
onLoad(options) {},
onLoad(options) {
// console.log(options, "这是传参");
// // #ifdef APP-PLUS
// setTimeout(() => {
// plus.screen.unlockOrientation();
// plus.screen.lockOrientation("landscape-primary");
// }, 10);
// // #endif
// // #ifdef APP-PLUS
// // plus.screen.lockOrientation("portrait-primary");
// // #endif
// if (uni.getStorageSync("videoOssList")) {
// this.videoList = JSON.parse(uni.getStorageSync("videoOssList"));
// }
// console.log("this.videoList at line 53:", this.videoList);
// this.options = JSON.parse(options.data);
// this.videoId = this.options.video;
// this.timer = setInterval(() => {
// var that = this;
// if (this.currentTime) {
// that.setVideoTime();
// }
// }, 2000);
// this.$emit("child-event", this.timer);
// // this.$once("hook:beforeDestroy", () => {
// // clearInterval(this.timer);
// // });
},
methods: {
start() {
// var playerView = this.$refs.playerView;
this.$refs.playerView.start();
},
pause() {
// var playerView = ;
this.$refs.playerView.pause();
},
changeVideoData() {
this.isChange = false;
},
@@ -166,9 +250,70 @@ export default {
this.videoId = this.options.video;
console.log("这是苹果视屏id", this.videoId);
await this.getLive(isChange);
// await this.getVideo(isChange);
// this.$emit("child-event", this.timer);
},
async getVideo() {
var data = {};
var that=this;
$http
.request({
url: `sociology/course/ttt`,
method: "Post", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then(async (res) => {
console.log(" 视频播放11111111111:", res);
var credentials = res.result.credentials;
// var playerView = this.$refs.playerView;
// console.log('playerView at line 273:', playerView)
/*
STS加密播放
*/
that.$refs.playerView.setVidSts({
vid: this.videoData.video,
accessKeyId: credentials.accessKeyId,
securityToken: credentials.securityToken,
accessKeySecret: credentials.accessKeySecret,
expireTime: credentials.expireTime,
Region: "cn-shanghai",
});
// playerView.setLocalSource({
// uri: "http://duoduovideo.oss-cn-beijing.aliyuncs.com/5f093c6fb6e90.mp4",
// });
let isFullScreen = true;
// fixed fullscreen play on android
if (plus.os.name.toLowerCase() === "android") {
plus.key.addEventListener("backbutton", (e) => {
if (isFullScreen) {
that.$refs.playerView.changeScreenMode(0, false);
isFullScreen = false;
} else {
// 这里由于安卓无法监听返回按键这里只能通过plus监听然后自己模拟退回
uni.navigateBack();
}
});
}
that.$refs.playerView.setPlayerCallBack(({ type, data }) => {
switch (type) {
case "isFullScreen":
isFullScreen = Boolean(data);
break;
default:
console.log({ type, data });
}
});
});
},
async getData(data, isChange) {
var that = this;
if (!this.isSetFirstTime) {
var netWork = data.userCourseVideoPositionEntity
? data.userCourseVideoPositionEntity.position
@@ -209,9 +354,9 @@ export default {
// await this.playVideo();
// }
console.log(this.firstTime, "这是第一次播放时长");
this.isSetFirstTime = true;
await that.getVideo();
}
this.isSetFirstTime = true;
},
async playVideo(e) {
this.videoContext = uni.createVideoContext("videoId", this);
@@ -362,6 +507,678 @@ export default {
};
</script>
<script module="renderScript" lang="renderjs">
import $ from 'jquery'
// import StaticADComponent from './staticadcomponent/index.js';
/**
* 静态广告组件
*/
export default {
/**
* 静态广告组件
*/
components: {
// MyComponent
},
mounted() {
// 在适合的生命周期通过script和link标签引入播放器sdk、css
console.log(this.options, '这是monted')
this.loadWebPlayerSDK()
// this.loadComponent()
},
data() {
return {
player: null,
videoTimer: null,
curTime: null,
// firstTime: null,
curStatus: null,
// currentTime:null,
}
},
watch: {
curTime(val) {
if (this.curTime !== null && this.curStatus !== null) {
this.$refs.videoContent1.click()
}
}
},
methods: {
handleClick(event, ownerInstance) {
console.log('是否了走了点击video事件', event)
// this.player.on('ready',function(){
// var status= this.player.fullscreenService.getIsFullScreen()
// console.log('status at line 403:', status)
// console.log('触发点击事件',status))
// })
// ownerInstance.callMethod('getData')
},
emitData(event, ownerInstance) {
var that = this;
ownerInstance.callMethod('recordTime', {
time: that.curTime,
status: that.curStatus
})
},
async receiveFirstTime(newValue, oldValue, ownerVm, vm) {
// if (this.player) {
// // this.firstTime=newValue;
// // console.log('这是初始播放时间111', this.firstTime,this.player)
// // await this.player.seek(newValue);
// await this.$refs.videoContent4.click()
// }
},
async receiveisSetFirstTime(newValue, oldValue, ownerVm, vm) {
console.log('是否刚开始设置播放时间', newValue, this.firstTime, this.player);
// if (this.player) {
// // this.firstTime=newValue;
// // await this.player.seek(this.firstTime);
// }
},
emitSetData(event, ownerInstance) {
var that = this;
// this.player.seek(this.firstTime)
console.log('是否设置的第一次初始播放', this.firstTime, this.videoData.id);
ownerInstance.callMethod('setVideoFirtsetTime')
},
changeVideoScreen(event, ownerInstance) {
var that = this;
// this.$emit('changeScreenLoading',true)
var status = this.player.fullscreenService.getIsFullScreen();
ownerInstance.callMethod('screenChange', {
status: status,
primary: status ? 'portrait' : 'landscape'
})
if (status) {
setTimeout(() => {
plus.screen.lockOrientation("portrait-primary"); //锁死屏幕方向为竖屏
this.player.fullscreenService.cancelFullScreen();
// this.$emit('changeScreenLoading',false);
}, 100);
// this.player.setPlayerSize('100%','200px');
} else {
// this.player.setPlayerSize({
// w:"400px",
// height:'60%'
// });
// plus.screen.unlockOrientation();
this.player.fullscreenService.requestFullScreen();
setTimeout(() => {
// this.$emit('changeScreenLoading',false);
plus.screen.lockOrientation("landscape-primary");
}, 100);
}
},
changeVideoData(event, ownerInstance) {
var that = this;
ownerInstance.callMethod('changeVideoData', )
},
endEmitData(event, ownerInstance) {
var that = this;
ownerInstance.callMethod('handleEnd', )
},
getLive() {
console.log('这是这只只是666666:', this.firstTime, this.videoData)
if (this.player) {
this.player.dispose();
$('#url-player-test').empty();
this.player = null;
}
var fullScreenButtonComponent = Aliplayer.Component({
/**
* 初始函数在new对象时调用
*
* @param {string} adAddress - 广告视频地址
* @param {string} toAddress - 广告链接地址
*/
init: function(status, toAddress) {
this.fullScreenStatus = status
// this.adAddress = adAddress;
// this.toAddress = toAddress;
this.$html = $('.fullScreenButton-container');
// this.$html.hide();
},
/**
* 创建广告Dom元素
*/
createEl: function(el) {
this.$html.find('.ad').attr('src', this.adAddress);
var $adWrapper = this.$html.find('.ad-wrapper');
$adWrapper.attr('href', this.toAddress);
$adWrapper.click(function() {
// Aliplayer.util.stopPropagation();
});
// this.$html.find('.close').click(function () {
// this.$html.hide();
// });
// $(el).find('.prism-controlbar').append(this.$html);
$(el).find('.prism-time-display').after(this.$html);
},
ready: function(player, e) {
// this.$html.hide()
},
/**
* 隐藏广告
*/
play: function(player, e) {
// this.$html.show();
},
/**
* 显示广告
*/
pause: function(player, e) {
// this.$html.show();
},
/**
* 隐藏广告
*/
playing: function(player, e) {
this.$html.show();
// this.$html.hide();
},
waiting: function(player, e) {
// this.$html.hide()
},
timeupdate: function(player, e) {},
error: function(player, e) {},
/**
* 显示广告
*/
ended: function(player, e) {
// this.$html.show();
}
});
console.log('this.currentVideoList at line 456111111111111111111111:', this.videoList)
var playerOptions = {
id: "url-player-test",
preload: false,
"vid": this.videoData
.videoId, // 必选参数,可以通过点播控制台(路径:媒资库>音/视频查询。示例1e067a2831b641db90d570b6480f****。
width: '100%', //容器的大小
// videoWidth: '100vw', //容器的大小
// videoHeight: '100vh', //容器的大小
height: '100%', //容器的大小
playsinline: true,
controlBarVisibility: "click",
cover: "",
components: [
// {
// name: 'BulletScreenComponent',
// type: AliPlayerComponent.BulletScreenComponent,
// /** Descriptions of the scrolling text component parameters: text, style, bulletPosition
// * text: The scrolling text
// * style: The style of the scrolling text
// * bulletPosition: The position of the scrolling text. Valid values: 'top', 'bottom', and 'random'. The default is 'random'.
// */
// args: ['http://101.201.146.165:8088/Pf-EH/statics/uploadFile/2024-05-10/b0f420c7-9178-41ad-9dd6-f59a64a6e190.png']
// },
{
name: 'adComponent',
type: fullScreenButtonComponent,
args: [
'http://101.201.146.165:8088/Pf-EH/statics/uploadFile/2024-05-10/b0f420c7-9178-41ad-9dd6-f59a64a6e190.png'
]
},
{
name: 'RateComponent',
type: AliPlayerComponent.RateComponent
},
// {
// name: 'RotateMirrorComponent',
// type: AliPlayerComponent.RotateMirrorComponent
// },
],
skinLayout: [{
name: "bigPlayButton",
align: "blabs",
x: 30,
y: 80
},
{
name: "H5Loading",
align: "cc"
},
{
name: "errorDisplay",
align: "tlabs",
x: 0,
y: 0
},
{
name: "infoDisplay"
},
{
name: "tooltip",
align: "blabs",
x: 0,
y: 56
},
{
name: "thumbnail"
},
{
name: "controlBar",
align: "blabs",
x: 0,
y: 0,
children: [{
name: "progress",
align: "blabs",
x: 0,
y: 44
},
{
name: "playButton",
align: "tl",
x: 15,
y: 12
},
{
name: "timeDisplay",
align: "tl",
x: 10,
y: 7
},
// {name: "fullScreenButton", align: "tr", x: 10, y: 12},
// {name:"subtitle", align:"tr",x:15, y:12},
// {
// name: "setting",
// align: "tr",
// x: 15,
// y: 12
// },
{
name: "prism-speed-selector",
align: "tr",
x: 15,
y: 12
},
{
name: "volume",
align: "tr",
x: 5,
y: 10
}
]
}
]
}
if (this.videoData.type == 1) {
playerOptions = {
...playerOptions,
"playauth": this.videoData.playAuth, // 必选参数参数值可通过调用GetVideoPlayAuth接口获取。
"encryptType": 1, // 必选参数当播放私有加密流时需要设置本参数值为1。其它情况无需设置。
"playConfig": {
"EncryptType": 'AliyunVoDEncryption'
},
}
} else {
playerOptions = {
...playerOptions,
source: this.videoData.videoUrl
}
}
var player = new Aliplayer(playerOptions, function(player) { });
this.player = player;
console.log('是否拿到第一次初始值呢',this.platform, typeof this.firstTime, this.firstTime)
if(this.platform == 'ios'){
this.player.one('timeupdate', () => {
this.player.seek(this.firstTime);
})
player.on('canplay',function(){
console.log('这是ios数据缓冲初次设置播放位置判断')
this.player.seek(this.firstTime);
})
// var seeked = false;
// player.on('loadedmetadata',function (e) {
// if(!seeked)
// {
// seeked = true;
// this.player.seek(20);
// }
// });
// player.on('waiting',function(){
// console.log('这是ios数据缓冲初次设置播放位置判断')
// setTimeout(()=>{
// player.seek(this.firstTime)
// },500)
// })
}else{
this.player.seek(this.firstTime)
}
// var seeked = false;
// this.player.on('loadedmetadata',function (e) {
// if(!seeked)
// {
// seeked = true;
// player.seek(this.firstTime);
// }
// });
clearInterval(this.videoTimer);
this.videoTimer = null;
this.videoTimer = setInterval(() => {
var that = this;
that.curTime = parseInt(this.player.getCurrentTime());
that.curStatus = this.player.getStatus()
}, 1000);
this.$refs.videoContent4.click()
player.on('ready', function() {
// player.fullscreenService.requestFullScreen()
})
// this.
// this.$refs.videoContent.click()
this.player.on('ended', function() {
// console.log('that.curTime at line 242:', this.curTime)
// console.log('that.curStatus at line 210:', this.curStatus)
this.$refs.videoContent2.click()
})
// player.setRotate(90)
//全屏播放
// player.one('canplay', function() {
// // console.log('canplay', this.player.tag);
// player.tag.play();
// });
},
showPreview(e) {
// console.log('e at line 56:', e)
let conimg = e.target.dataset.nodes;
let imgs = conimg.match(/<img[^>]+>/g); //选择节点中的img
console.log('imgs at line 59:', imgs)
let imgList = [];
//遍历img标签的src里面的内容放在定义的数组imgList中
for (var j = 0; j < imgs.length; j++) {
imgs[j].replace(/<img[^>]*src=['"]([^'"]+)[^>]*>/gi, function(match, capture) {
imgList.push(capture)
})
}
console.log('imgList.push at line 64:', imgList)
//最后一步就是所有图片放在预览的方法previewImage中就可以了
// uni.previewImage({
// current: imgList,
// urls: imgList,
// })
uni.previewImage({
urls: imgList,
longPressActions: {
itemList: ['很抱歉,暂不支持保存图片到本地'],
success: function(res) {
// console.log(res,'+++++')
}
}
});
},
receiveScreenType(newValue) {
// console.log('newValue at line 427屏幕方向111111111111:', newValue)
},
async receiveIsfresh(newValue) {
console.log('是否走了刷新销毁方法:', this.player)
if (this.player) {
clearInterval(this.$store.state.videoTimer)
// await this.setVideoTime();
this.player.dispose();
// $('#url-player-test').empty()
// this.player.seek(newValue);
}
},
async receiveplatform(newValue) {
},
async receiveIsChange(newValue) {
// this.timer=null
if (this.isChange) {
this.checkValue()
// if (this.videoData.type == 1) {
// console.log('是否走了切换加密视频方法:', this.isChange, this.videoData)
// await this.player.replayByVidAndPlayAuth(this.videoData.video, this.videoData.playAuth)
// this.$refs.videoContent.click()
// } else {
// console.log('是否走了切换老视频/音频方法:', this.isChange, this.videoData)
// await this.player.loadByUrl(this.videoData.videoUrl)
// this.$refs.videoContent.click()
// }
}
// this.$refs.videoContent3.click()
},
receiveVideoList(newValue, oldValue, ownerVm, vm) {
// //数据变化
console.log('currentVideoListcurrentVideoListcurrentVideoList', newValue)
},
receiveMsg(newValue, oldValue, ownerVm, vm) {
//数据变化
// console.log('newValue', newValue)
// console.log('oldValue', oldValue)
// console.log('ownerVm', ownerVm)
// console.log('vm', vm)
},
receiveWinWidth(newValue, oldValue, ownerVm, vm) {
//数据变化
console.log('newValue', newValue)
// console.log('oldValue', oldValue)
// console.log('ownerVm', ownerVm)
// console.log('vm', vm)
},
receiveWinHeight(newValue, oldValue, ownerVm, vm) {
//数据变化
console.log('newValue', newValue)
// console.log('oldValue', oldValue)
// console.log('ownerVm', ownerVm)
// console.log('vm', vm)
},
checkValue() {
console.log(this.videoId, this.authId, this.videoData, "1111888888")
if ((!this.videoData.playAuth || !this.currentVideoList)) {
setTimeout(() => {
this.checkValue();
}, 1000);
} else {
console.log('这是这只只是594:', this.firstTime, this.videoData)
this.getLive();
}
},
loadWebPlayerSDK() {
return new Promise((resolve, reject) => {
const s_tag = document.createElement('script'); // 引入播放器js
s_tag.type = 'text/javascript';
s_tag.src = 'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/aliplayer-min.js';
s_tag.charset = 'utf-8';
s_tag.onload = () => {
const s_tag1 = document.createElement('script'); // 引入播放器js
s_tag1.type = 'text/javascript';
s_tag1.src =
'https://player.alicdn.com/aliplayer/presentation/js/aliplayercomponents.min.js';
s_tag1.charset = 'utf-8';
s_tag1.onload = () => {
this.checkValue();
resolve();
}
document.body.appendChild(s_tag1);
}
document.body.appendChild(s_tag);
const l_tag = document.createElement('link'); // 引入播放器css
l_tag.rel = 'stylesheet';
l_tag.href =
'https://g.alicdn.com/apsara-media-box/imp-web-player/2.20.3/skins/default/aliplayer-min.css';
document.body.appendChild(l_tag);
});
},
loadComponent() {
// return new Promise((resolve, reject) => {
// const s_tag = document.createElement('script');
// s_tag.type = 'text/javascript';
// // 需要先下载组件 js 文件,放到项目 /static/ 目录下
// // 下载地址https://github.com/aliyunvideo/AliyunPlayer_Web/blob/master/customComponents/dist/aliplayer-components/aliplayercomponents-1.0.9.min.js
// s_tag.src = '@/static/aliplayercomponents.js';
// s_tag.charset = 'utf-8';
// s_tag.onload = () => {
// resolve();
// }
// document.body.appendChild(s_tag);
// });
}
}
}
</script>
<style>
.container {
width: 100vw;

View File

@@ -0,0 +1,534 @@
<template>
<view class="container" style="background-color: #fff; position: relative">
<view style="width: 100%">
<!-- <web-view style="height: 200px" src="https://www.tmrjournals.com/aliplayer.html"></web-view> -->
<web-view
style="height: 200px"
src="../../../../static/html/aliplayer.html"
></web-view>
</view>
</view>
</template>
<script>
import store from "@/store/index.js";
import $http from "@/config/requestConfig.js";
import { mapState, mapMutations } from "vuex";
// importScripts('@/static/aliplayer/aliplayer-min.js')
export default {
props: ["currentVideo", "currentVideoList"],
data() {
return {
platform: null,
//当前是否是全屏模式
isFullScreen: false,
isfresh: false,
isChange: false,
isControl: true,
timer: null,
videoTitle: "",
videoList: [],
firstTime: 0,
options: {},
playAuth: "",
currentTime: "",
videoId: "",
videoData: {},
isSetFirstTime: false,
screenType: null,
videoUrl: null,
};
},
computed: {
...mapState(["videoOssList"]),
},
watch: {
currentVideo: {
immediate: true,
handler(newRoute) {},
},
timer(newValue) {
this.$emit("child-event", newValue);
},
},
// //页面显示
mounted() {},
beforeDestroy() {
this.handleEnd();
console.log("是否走啦习销毁");
clearInterval(this.$store.state.videoTimer);
// this.timer = null;
// store.commit("setLoadingShow", null);
plus.screen.lockOrientation("portrait-primary");
console.log("是否走啦习销毁定时器", this.timer);
},
async onUnload() {
uni.navigateTo({
url: "/pages/curriculum/order/curriculum/back",
});
// #ifdef APP-PLUS
plus.screen.lockOrientation("portrait-primary"); //锁死屏幕方向为竖屏
// plus.screen.lockOrientation("portrait-primary");
// #endif
await this.setVideoTime();
// this.player.dispose();
},
//第一次加载
onLoad(options) {},
methods: {
changeVideoData() {
this.isChange = false;
},
async changeVideo(data) {
this.currentTime = "";
this.firstTime = 0;
this.isSetFirstTime = false;
this.isChange = false;
await this.init(data, true);
},
screenChange(data) {
console.log(
"status at line 这是当前的状态158:",
data.status,
data.primary
);
this.isFullScreen = !data.status;
this.$emit("changeScreen", this.isFullScreen);
// let fullScreen = e.detail.fullScreen; // 值true为进入全屏false为退出全屏
// if (!fullScreen) {
// //退出全屏
// this.isFullScreen = false;
// } else {
// this.isFullScreen = true;
// }
},
// 控制器的显示隐藏
controlChange(e) {
this.isControl = e.detail.show;
},
quitScreen() {
// 退出全屏
const ctx = this.$refs.myVideo;
ctx.exitFullScreen();
},
// 播放进度改变
videoTimeUpdateEvent(e) {
this.playTime = parseInt(e.detail.currentTime);
this.currentTime = parseInt(e.detail.currentTime);
this.allTime = parseInt(e.detail.duration);
this.recordTime({
time: this.playTime,
});
},
async init(data, isChange) {
this.platform = this.$platform;
this.isfresh = true;
console.log("at line 59:", "是否先走init这里", this.platform);
if (uni.getStorageSync("videoOssList")) {
this.videoList = JSON.parse(uni.getStorageSync("videoOssList"));
}
this.options = data.currentVideo;
this.videoId = this.options.video;
console.log("这是苹果视屏id", this.videoId);
await this.getLive(isChange);
// this.$emit("child-event", this.timer);
},
async getData(data, isChange) {
if (!this.isSetFirstTime) {
var netWork = data.userCourseVideoPositionEntity
? data.userCourseVideoPositionEntity.position
: 0;
var list = [];
if (uni.getStorageSync("videoOssList")) {
list = JSON.parse(uni.getStorageSync("videoOssList"));
var index = list.findIndex((e) => e.id == data.id);
if (netWork) {
if (index >= 0) {
this.firstTime =
list[index].time > netWork ? list[index].time : netWork;
} else {
this.firstTime = netWork ? netWork : 0;
}
} else {
if (index >= 0) {
this.firstTime = list[index].time ? list[index].time : 0;
} else {
this.firstTime = 0;
}
}
} else {
this.firstTime = 0;
}
this.videoData = {
...data,
};
this.isChange = isChange ? isChange : false;
// this.currentTime = this.firstTime;
console.log(this.firstTime, "这是第一次播放时长222");
// await this.setVideoTime();
uni.setStorageSync("videoOssList", JSON.stringify(list));
// if (this.currentVideo.type == 0 || this.currentVideo.type == 2) {
// await this.playVideo();
// }
console.log(this.firstTime, "这是第一次播放时长");
this.isSetFirstTime = true;
}
},
recordTime(data) {
this.currentTime = data.time;
var list = [];
if (uni.getStorageSync("videoOssList")) {
list = JSON.parse(uni.getStorageSync("videoOssList"));
}
var index = list.findIndex((e) => e.id == this.videoData.id);
if (list.length > 0 && index >= 0) {
list[index] = {
...this.videoData,
time: data.time,
};
} else {
list.push({
...this.videoData,
time: data.time,
});
}
uni.setStorageSync("videoOssList", JSON.stringify(list));
},
// 获取数据
async getLive(isChange) {
var that = this;
this.isfresh = false;
var data = {
...this.options,
};
await $http
.request({
url: `sociology/course/checkVideo`,
method: "Post", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then(async (res) => {
var data = {
...res.video,
};
if (this.currentVideo.type == 1) {
var playAuth = res.video.playAuth.replace(/=/g, "");
console.log("这是接口获取的视屏凭证111", playAuth);
data = {
...data,
videoId: res.video.video,
playAuth: playAuth,
};
this.playAuth = playAuth;
await that.getData(data, isChange);
} else {
console.log("这是接口获取的视屏凭证222", res.video, data);
data = {
...data,
playAuth: new Date().getTime(),
};
await that.getData(data, isChange);
}
console.log("是否获取到初始播放值", data);
that.$forceUpdate();
});
},
async handleEnd() {
var list = JSON.parse(JSON.stringify(uni.getStorageSync("videoOssList")));
var data = list.find((e) => e.id == this.videoData.id);
this.currentTime = data.time;
console.log(
"this.currentTime at line 这是结束的时候掉的存储视频:",
this.currentTime
);
clearInterval(this.$store.state.videoTimer);
this.timer = null;
await this.setVideoTime();
},
setVideoTime(time) {
var data = {};
// var list = uni.getStorageSync("videoOssList");
// data = list.find((e) => e.id == this.videoData.id);
// console.log("这是再走生命周期哦", this.currentTime);
console.log("是否走了存储视屏," + this.videoData.id, this.currentTime);
var data = {
videoId: this.videoData.id,
position: this.currentTime, //秒数
};
$http
.request({
url: `sociology/course/saveCoursePosition`,
method: "Post", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then((res) => {
console.log("存储视屏时长接口返回信息", res);
this.$forceUpdate();
});
},
changePlayerTime(player) {
console.log("this.firstTime at line 106:", this.firstTime);
player.seek(this.firstTime);
},
goBack() {
uni.navigateBack({
delta: 1,
});
},
async setVideoFirtsetTime(time) {
this.currentTime = this.firstTime;
console.log("这里准备开始设置播放时间:", this.currentTime);
// await this.setVideoTime();
// setTimeout(() => {
// clearInterval(this.$store.state.videoTimer);
store.commit(
"setVideoTimer",
setInterval(async () => {
// if (this.currentTime) {
await this.setVideoTime();
// }
}, 60000)
);
// }, 5000);
},
},
created() {},
};
</script>
<style>
.container {
width: 100vw;
height: auto;
/deep/.pause {
width: 60rpx !important;
height: 60rpx !important;
}
}
.fds {
background-color: blue;
height: 600rpx;
position: fixed;
top: 60rpx;
}
.returnBack {
flex-direction: row;
justify-content: flex-start;
align-items: center;
height: 88rpx;
padding-left: 20rpx;
}
.txt {
color: #fff;
}
.right_title {
background: #000;
height: 96rpx;
justify-content: space-between;
flex-direction: row;
align-items: center;
margin-left: auto;
}
.return {
flex-direction: row;
align-items: center;
color: #fff;
}
.right_handle {
width: 200rpx;
flex-direction: row;
justify-content: flex-end;
padding-right: 20rpx;
}
cover-view {
display: block;
line-height: 1.2;
overflow: hidden;
white-space: nowrap;
pointer-events: auto;
}
cover-view {
visibility: visible !important;
}
cover-image {
visibility: visible !important;
}
.fullScreenButton-container {
color: #fff;
float: right;
height: 35px;
margin-top: 6px;
margin-right: 5px;
display: flex;
align-items: center;
position: relative;
i {
color: #fff;
display: inline-block;
font-size: 22px;
display: block;
margin-top: 7px;
cursor: pointer;
& + i {
margin-left: 3px;
}
@media (min-width: 768px) {
&:hover + .player-tooltip {
display: block;
}
}
}
.player-tooltip {
&.prev {
left: -10px;
}
&.list {
left: 5px;
}
&.next {
right: -12px;
}
}
}
.playlist-content {
position: absolute;
right: 0;
width: 0px;
padding-bottom: 48px;
box-sizing: border-box;
height: 100%;
transition: all 0.38s ease-in-out;
overflow: hidden;
.list {
background-color: #000;
background-color: rgba(0, 0, 0, 0.3);
height: 100%;
overflow: auto;
.video-item {
color: #fff;
padding: 0px 10px;
line-height: 35px;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
&.active {
background-color: #000;
color: #00ddff;
}
@media (min-width: 768px) {
&:hover {
background-color: #000;
color: #00ddff;
}
}
}
}
}
.player-tooltip {
position: absolute;
display: none;
font-size: 12px;
color: #fff;
line-height: 28px;
letter-spacing: 0;
text-align: center;
background: #3c3c3c;
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1);
height: 28px;
top: -48px;
padding: 0 5px;
white-space: nowrap;
}
.playlist-skip-tip {
padding: 5px 15px;
position: absolute;
top: 50%;
left: 50%;
z-index: 30;
line-height: 30px;
font-size: 14px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.8);
color: #000;
text-align: center;
transform: translate(-50%, -50%);
}
#rotating-div {
width: 100vw;
height: 100vh;
background-color: #3498db;
transform: rotate(90deg);
/* 旋转90度 */
transform-origin: center center;
/* 设置旋转中心点在div中心 */
position: fixed;
/* 固定定位,全屏显示 */
left: 0;
top: 0;
bottom: 0;
right: 0;
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,17 @@
}`"
>
<view :style="`background:#000`">
<common-video-ios
v-if="$platform == 'ios'"
@changeScreen="changeScreen"
@changeScreenLoading="changeScreenLoading"
ref="commonVideo"
:currentVideo="currentVideo"
:currentVideoList="videoArray"
>
</common-video-ios>
<common-video
v-else
@changeScreen="changeScreen"
@changeScreenLoading="changeScreenLoading"
ref="commonVideo"
@@ -20,6 +30,7 @@
:currentVideoList="videoArray"
>
</common-video>
<!-- <view style="height: 200px" v-else></view> -->
</view>
@@ -238,8 +249,6 @@
@confirm="hancleModalConfirm"
@cancel="hancleModalCancel"
></u-modal> -->
</view>
</template>
@@ -327,7 +336,7 @@ export default {
};
},
onLoad(options) {
this.options = options;
this.options = options;
this.getCourseDescriptionData();
// plus.screen.lockOrientation("default");
this.screenLoading = false;
@@ -336,7 +345,6 @@ export default {
// plus.screen.unlockOrientation(); //解除锁定屏幕方向
// plus.screen.lockOrientation("portrait-primary");
// this.getUserInfo()
// this.getCateList()
},
@@ -476,12 +484,11 @@ export default {
// id: "16457",
};
var that = this;
$http
.request({
// url: "book/buyOrder/buySave",
url:'sociology/course/getCourseCatalogueChapterDetail',
url: "sociology/course/getCourseCatalogueChapterDetail",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: {
@@ -489,9 +496,9 @@ export default {
"Content-Type": "application/json",
},
})
.then(async (res) => {
.then(async (res) => {
console.log(this.$store.state, "11111111111");
console.log('res at line 491:', res)
console.log("res at line 491:", res);
that.curriculumData = res.data.detail;
that.videoArray = res.data.videos;
if (that.videoArray.length > 0) {

File diff suppressed because it is too large Load Diff

667
pages/index/db.nvue Normal file
View File

@@ -0,0 +1,667 @@
<template>
<view class="content">
<KJ-Player class="player" ref="player" :style="{width:'100%',height:palyerHeight}"
@onTimeChanged="onTimeChanged" @onKVO="onKVO" @onNotification="onNotification" @onPip="onPip"
@onSystem="onSystem">
<cover-view v-if="isShowVideoview" class="video-view" :style="{width:'100%',height:palyerHeight}"
@click="tap" @touchstart="touchStartHandle" @touchend="touchEndHandle" @touchcancel="touchCancelHandle"
@touchmove="touchMoveHandle">
<text class="tip" v-if="isShowTip"
:style="{position:'absolute',left:0,right:0,top:tipTop}">{{tip}}</text>
<view class=" top-title" :style="{width:'100%'}" v-if="isShowTitle">
<view>
<button type="primary" @click="pip2">画中画(全局)</button>
</view>
<text :style="{color:'#fff'}">标题</text>
<view>
<button type="primary" @click="pip">画中画</button>
</view>
</view>
<view class="bottom-title" :style="{width:'100%'}" v-if="isShowTitle">
<button type="primary" @click="playOrPause">{{playOrPauseText}}</button>
<text class="text">{{leftTime}}</text>
<view class="fullControls-center">
<chunLei-slider :max="duration" :value="current" :style="{width:`${fullControlsWidth-40}px`}"
:screenLeft="40" :width="fullControlsWidth-40" @change="changeCurrent" :ratio="1">
</chunLei-slider>
</view>
<text class="text">{{rightTime}}</text>
<button type="primary" @click="full">全屏</button>
</view>
</cover-view>
</KJ-Player>
<view class="btns">
<button type="primary" @click="init">初始化(系统自带界面)</button>
<button type="primary" @click="init2">初始化(自定义界面)</button>
<button type="primary" @click="stop">销毁</button>
<button type="primary" @click="replaceCurrentItemWithPlayerItem">切换播放源</button>
<button type="primary" @click="getCurrentTime">获取当前时间</button>
<button type="primary" @click="getDuration">获取时长</button>
<button type="primary" @click="play">播放</button>
<button type="primary" @click="pause">暂停</button>
<button type="primary" @click="getStatus">获取状态</button>
<button type="primary" @click="getTimeControlStatus">获取时间控制状态</button>
<button type="primary" @click="setMuted">设置是否静音</button>
<button type="primary" @click="getMuted">获取是否静音</button>
<button type="primary" @click="setVolume">设置音量</button>
<button type="primary" @click="getVolume">获取音量</button>
<button type="primary" @click="setRate">设置速率</button>
<button type="primary" @click="getRate">获取速率</button>
<button type="primary" @click="seekToTime">设置进度</button>
<button type="primary" @click="setVideoGravity">设置视频拉伸模式</button>
<button type="primary" @click="isPictureInPictureSuspended">设备是否支持画中画</button>
<button type="primary" @click="pip">自动切换画中画</button>
<button type="primary" @click="isPictureInPictureActive">是否已开启画中画</button>
<button type="primary" @click="startPictureInPicture">开启画中画</button>
<button type="primary" @click="stopPictureInPicture">停止画中画</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
url: "http://baobab.kaiyanapp.com/api/v1/playUrl?vid=164016&resourceType=video&editionType=high&source=aliyun&playUrlType=url_oss",
isShowVideoview: false,
duration: 60 * 60 * 1000, //精确总时长
fullControlsWidth: '200', //全屏宽
current: 0, //video进度
leftTime: "00:00:00",
rightTime: "00:00:00",
statusBarHeight: "20px",
getStatusBarHeight: "20px",
headerHeight: "44px",
palyerHeight: "500rpx",
tipTop: "250rpx",
tip: "加载中...",
isShowTip: true,
isShowTitle: true,
hideTitleTime: 6000,
isFull: false,
playOrPauseText: "播放",
touchHandleType: false, //滑动记录 progress // light // voice
handleDynamicX: 0, // 动态记录滑动的记录X轴
handleDynamicY: 0, // 动态记录Y轴滑动距离
videoNowLight: 0, // 当前屏幕的亮度
videoNowVoice: 0, // 当前的音量
onceClickTimer: null,
changing: false,
isPip: true,
pip_currentTime: null,
}
},
onLoad(options) {
uni.$emit('to-pip-path', {
path: null,
});
this.pip_currentTime = options.pip_currentTime;
uni.$on('pip-to', (res) => {
console.log(JSON.stringify(res));
var dic = {
"second": res.currentTime + ""
}
this.$refs.player.seekToTime(dic, (res) => {
console.log("seekToTime:" + JSON.stringify(res))
this.play();
})
})
},
onReady() {
this.init2();
setTimeout((res) => {
this.$refs.player.sendSubviewToBack()
if (this.pip_currentTime != undefined) {
var dic = {
"second": this.pip_currentTime + ""
}
this.$refs.player.seekToTime(dic, (res) => {
console.log("seekToTime:" + JSON.stringify(res))
this.play();
})
}
}, 100)
},
onUnload() {
if (this.isPip) {
uni.$emit('to-pip-path', {
path: "/pages/index/index",
});
}
},
onBackPress() {
},
methods: {
pip2() {
this.isPip = true;
this.pause();
this.$refs.player.getCurrentTime((res) => {
console.log("getCurrentTime:" + JSON.stringify(res))
uni.$emit('to-pip', {
currentTime: res.result + "",
url: this.url,
path: null
});
})
},
onTimeChanged(res) {
this.duration = parseInt(res.detail.total);
this.current = parseInt(res.detail.current);
this.leftTime = this.formatDuring(this.current)
this.rightTime = this.formatDuring(this.duration)
},
onKVO(res) {
console.log("onKVO:" + JSON.stringify(res.detail))
var attribute = res.detail.attribute
var value = res.detail.value
if (attribute == "timeControlStatus") {
if (value == 0) { //暂停
this.playOrPauseText = "播放";
} else if (value == 1) { //由于媒体缓冲数据不足而导致播放停止
this.playOrPauseText = "暂停";
} else if (value == 2) { //播放
this.tip = "加载中...";
this.isShowTip = false;
this.playOrPauseText = "暂停";
}
} else if (attribute == "playerItemStatus") {
if (value == 0) { //未知
this.playOrPauseText = "播放";
} else if (value == 1) { //已准备好播放
this.playOrPauseText = "暂停";
} else if (value == 2) { //失败
this.tip = "播放失败";
this.isShowTip = true;
this.playOrPauseText = "播放";
}
} else if (attribute == "status") {
if (value == 0) { //未知
} else if (value == 1) { //已准备好播放
} else if (value == 2) { //失败
this.tip = "播放失败";
this.isShowTip = true;
this.playOrPauseText = "播放";
}
}
},
onNotification(res) {
console.log("onNotification:" + JSON.stringify(res.detail))
if (res.detail.method == "AVPlayerItemTimeJumpedNotification") {
console.log("发生变化");
} else if (res.detail.method == "AVPlayerItemDidPlayToEndTimeNotification") {
console.log("播放完成");
} else if (res.detail.method == "AVPlayerItemFailedToPlayToEndTimeNotification") {
console.log("未能播放到其结束时间就中断");
} else if (res.detail.method == "AVPlayerItemPlaybackStalledNotification") {
console.log("播放暂停");
}
},
onPip(res) {
console.log("onPip:" + JSON.stringify(res.detail))
if (res.detail.method == "WillStartPictureInPicture") {
console.log("即将开启画中画");
} else if (res.detail.method == "DidStartPictureInPicture") {
console.log("已开启画中画");
} else if (res.detail.method == "failedToStartPictureInPicture") {
console.log("开启画中画失败");
} else if (res.detail.method == "WillStopPictureInPicture") {
console.log("即将停止画中画");
} else if (res.detail.method == "DidStopPictureInPicture") {
console.log("已停止画中画");
} else if (res.detail.method == "restoreUserInterfaceForPictureInPictureStop") {
console.log("画中画恢复");
}
},
onSystem(res) { //系统界面,才支持
console.log("onSystem:" + JSON.stringify(res.detail))
if (res.detail.method == "willBeginFullScreen") {
console.log("即将开始全屏");
} else if (res.detail.method == "willEndFullScreen") {
console.log("即将退出全屏");
}
},
comminit(playerType) {
var dic = {
"playerType": playerType, //custom system
"urlType": "network", //local(本地路径-传绝对路径plus.io.convertLocalFileSystemURL) network(网络地址)
"url": this.url,
"autoPlay": true,
"allowsPictureInPicturePlayback": true, //是否开启画中画
"canStartPictureInPictureAutomaticallyFromInline": true, //ios14.2 是否 进入后台,自动启动画中画
"videoGravity": "ResizeAspect", //设置视频拉伸模式
"systemPlayer": { //playerType为system有效
// "showsPlaybackControls": true, //是否显示媒体播放组件
// "showsTimecodes": true, //ios13
// "allowsVideoFrameAnalysis": true,
// "updatesNowPlayingInfoCenter": true,
// "entersFullScreenWhenPlaybackBegins": true,
// "exitsFullScreenWhenPlaybackEnds": true,
// "requiresLinearPlayback": true,
},
};
this.$refs.player.init(dic, (res) => {
console.log("init:" + JSON.stringify(res))
})
},
init() {
this.isShowVideoview = false;
this.$nextTick((res) => {
this.comminit("system")
})
},
init2() {
this.isShowVideoview = true;
this.$nextTick((res) => {
this.comminit("custom")
this.duration = 60 * 60 * 1000;
this.current = 0;
this.leftTime = this.formatDuring(this.current)
this.rightTime = this.formatDuring(this.duration)
})
},
stop() {
this.$refs.player.stop()
},
replaceCurrentItemWithPlayerItem() {
var dic = {
"urlType": "network", //local(本地路径-传绝对路径plus.io.convertLocalFileSystemURL) network(网络地址)
"url": this.url
}
this.$refs.player.replaceCurrentItemWithPlayerItem(dic, (res) => {
console.log("replaceCurrentItemWithPlayerItem:" + JSON.stringify(res))
})
},
getCurrentTime() {
this.$refs.player.getCurrentTime((res) => {
console.log("getCurrentTime:" + JSON.stringify(res))
})
},
getDuration() {
this.$refs.player.getDuration((res) => {
console.log("getDuration:" + JSON.stringify(res))
})
},
play() {
this.$refs.player.play((res) => {
console.log("play:" + JSON.stringify(res))
})
},
pause() {
this.$refs.player.pause((res) => {
console.log("pause:" + JSON.stringify(res))
})
},
getStatus() {
this.$refs.player.getStatus((res) => {
console.log("getStatus:" + JSON.stringify(res))
})
},
getTimeControlStatus() {
this.$refs.player.getTimeControlStatus((res) => {
console.log("getTimeControlStatus:" + JSON.stringify(res))
})
},
setMuted() {
var dic = {
"is": true
}
this.$refs.player.setMuted(dic, (res) => {
console.log("setMuted:" + JSON.stringify(res))
})
},
getMuted() {
this.$refs.player.getMuted((res) => {
console.log("getMuted:" + JSON.stringify(res))
})
},
setVolume() {
var dic = {
"volume": "1.0"
}
this.$refs.player.setVolume(dic, (res) => {
console.log("setVolume:" + JSON.stringify(res))
})
},
getVolume() {
this.$refs.player.getVolume((res) => {
console.log("getVolume:" + JSON.stringify(res))
})
},
setRate() {
var dic = {
"rate": "2.0"
}
this.$refs.player.setRate(dic, (res) => {
console.log("setRate:" + JSON.stringify(res))
})
},
getRate() {
this.$refs.player.getRate((res) => {
console.log("getRate:" + JSON.stringify(res))
})
},
seekToTime() {
var dic = {
"second": "3000.0"
}
this.$refs.player.seekToTime(dic, (res) => {
console.log("seekToTime:" + JSON.stringify(res))
})
},
isPictureInPictureSuspended() {
this.$refs.player.isPictureInPictureSuspended((res) => {
console.log("isPictureInPictureSuspended:" + JSON.stringify(res))
})
},
pip() {
this.$refs.player.pip()
},
isPictureInPictureActive() {
this.$refs.player.isPictureInPictureActive((res) => {
console.log("isPictureInPictureActive:" + JSON.stringify(res))
})
},
startPictureInPicture() {
this.$refs.player.startPictureInPicture()
},
stopPictureInPicture() {
this.$refs.player.stopPictureInPicture()
},
setVideoGravity() {
var dic = {
"videoGravity": "ResizeAspectFill"
}
this.$refs.player.setVideoGravity(dic, (res) => {
console.log("setVideoGravity:" + JSON.stringify(res))
})
},
requestFullScreen() {
this.$refs.player.requestFullScreen((res) => {
console.log("requestFullScreen:" + JSON.stringify(res))
})
},
exitFullScreen() {
this.$refs.player.exitFullScreen((res) => {
console.log("exitFullScreen:" + JSON.stringify(res))
})
},
playOrPause() {
this.$refs.player.getTimeControlStatus((res) => {
console.log(JSON.stringify(res))
if (res.result == 0) { //暂停
this.play();
} else if (res.result == 1) { //由于媒体缓冲数据不足而导致播放停止
this.pause();
} else if (res.result == 2) { //播放
this.pause();
}
})
},
full() {
if (!this.isFull) {
plus.screen.lockOrientation("landscape-primary");
//this.$refs.vlc.requestFullScreen()
} else {
plus.screen.lockOrientation("portrait-primary");
//this.$refs.vlc.exitFullScreen()
}
this.isFull = !this.isFull;
},
formatDuring(s) {
//console.log(mss)
var hours = parseInt(s / 60 / 60);
if (hours < 10) {
hours = "0" + hours
}
var minutes = parseInt(s / 60 % 60);
if (minutes < 10) {
minutes = "0" + minutes
}
var seconds = parseInt(s % 60);
if (seconds < 10) {
seconds = "0" + seconds
}
return hours + ":" + minutes + ":" + seconds;
},
//拖动滑块
changeCurrent(e) {
this.current = e.detail.value
console.log(JSON.stringify(e));
this.changing = true;
var dic = {
"second": "" + parseInt(this.current)
}
this.$refs.player.seekToTime(dic, (res) => {
console.log("seekToTime:" + JSON.stringify(res))
})
},
changing(e) {
this.changing = false;
},
full() {
if (!this.isFull) {
plus.screen.lockOrientation("landscape-primary");
//this.$refs.vlc.requestFullScreen()
} else {
plus.screen.lockOrientation("portrait-primary");
//this.$refs.vlc.exitFullScreen()
}
this.isFull = !this.isFull;
},
tap() {
console.log("tap")
if (this.onceClickTimer != null) {
clearTimeout(this.onceClickTimer);
this.onceClickTimer = null;
}
this.isShowTitle = !this.isShowTitle;
this.$forceUpdate()
if (this.isShowTitle) {
this.onceClickTimer = setTimeout(() => {
clearTimeout(this.onceClickTimer);
this.onceClickTimer = null;
this.isShowTitle = false;
}, this.hideTitleTime)
}
},
//监听当前操作
touchStartHandle(e) {
console.log(e);
this.touchStartTimeStamp = new Date().getTime();
this.handleDynamicY = e.changedTouches[0].screenY;
this.handleDynamicX = e.changedTouches[0].screenX;
},
//监听抬起操作
touchEndHandle(e) {
//this.tap();
if (this.touchHandleType) {
this.touchStartTimeStamp = 0;
this.handleDynamicY = 0;
this.handleDynamicX = 0;
this.touchHandleType = false;
if (this.progressBtnStatus) {
this.progressBtnStatus = false;
this.progressPercent = this.progressBtnPercent;
}
}
},
// 监听是否触发滑动事件
touchMoveHandle(e) {
// 判断左右上下滑动是否超过10px
let X = e.changedTouches[0].screenX;
let Y = e.changedTouches[0].screenY;
if (this.touchHandleType) {
this.handleFun(X, Y);
return;
}
let chaX = Math.abs(X - this.handleDynamicX);
let chaY = Math.abs(Y - this.handleDynamicY);
if (chaX > 10 || chaY > 10) {
if (chaX > 10) {
this.touchHandleType = 'progress';
this.handleDynamicX = X;
} else {
let left = uni.getSystemInfoSync().screenWidth / 2;
if (this.handleDynamicX > left) {
this.touchHandleType = 'voice'
} else {
this.touchHandleType = 'light'
}
this.handleDynamicY = Y;
}
}
},
// 操作当前的方法
handleFun(X, Y) {
let chaX = X - this.handleDynamicX;
let chaY = Y - this.handleDynamicY;
switch (this.touchHandleType) {
case 'progress':
console.log("progress")
this.progressBtnStatus = true;
if (chaX > 0) {
if (this.current >= this.duration) {
this.current = this.duration;
} else {
this.current += 1000;
}
} else {
if (this.current <= 0) {
this.current = 0;
} else {
this.current -= 1000;
}
}
var dic = {
"second": "" + parseInt(this.current)
}
this.$refs.player.seekToTime(dic, (res) => {
console.log("seekToTime:" + JSON.stringify(res))
})
break;
case 'light':
console.log("light")
if (chaY < 0) {
if (this.videoNowLight + 0.02 >= 1) {
this.videoNowLight = 1;
} else {
this.videoNowLight += 0.02
}
} else {
if (this.videoNowLight - 0.02 <= 0) {
this.videoNowLight = 0;
} else {
this.videoNowLight -= 0.02
}
}
plus.screen.setBrightness(this.videoNowLight)
break;
case 'voice':
console.log("voice")
if (chaY < 0) {
if (this.videoNowVoice + 0.02 >= 1) {
this.videoNowVoice = 1;
} else {
this.videoNowVoice += 0.02
}
} else {
if (this.videoNowVoice - 0.02 <= 0) {
this.videoNowVoice = 0;
} else {
this.videoNowVoice -= 0.02
}
}
plus.device.setVolume(this.videoNowVoice);
break;
default:
this.touchHandleType = false;
break;
}
this.handleDynamicX = X;
this.handleDynamicY = Y;
}
}
}
</script>
<style>
.text {
color: #fff;
font-size: 10px;
}
.play {
justify-content: center;
align-items: center;
background-color: black;
}
.video-view {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
}
.tip {
position: absolute;
left: 0;
right: 0;
top: 250rpx;
text-align: center;
color: #fff
}
.top-title,
.bottom-title {
position: absolute;
left: 0;
right: 0;
height: 70px;
background-color: rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
flex-direction: row;
align-items: center;
color: #fff;
padding: 16px;
}
.top-title {
top: 0;
width: 750rpx;
}
.bottom-title {
bottom: 0;
width: 750rpx;
}
.fullControls-center {
flex-direction: row;
align-items: center;
justify-content: center;
height: 40px;
}
.btns {
margin-top: 40px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-items: center;
justify-content: center;
}
</style>

468
pages/index/db_old.nvue Normal file
View File

@@ -0,0 +1,468 @@
<template>
<div>
<oxeVideo ref='video'
:isLive='boxIsLive'
:coreType='boxCoreType'
:callback='boxCallback'
:style='boxStyle'></oxeVideo>
<button @click="replay"> 重播 </button>
<button @click="prev"> 上一集 </button>
<button @click="next"> 下一集 </button>
<button @click="enterTinyWindow"> 小屏播放 </button>
<button @click="remove"> 移除播放器 </button>
<button @click="addDanmaku"> 发送弹幕 </button>
<button @click="pause"> 暂停 </button>
<button @click="start"> 播放 </button>
<button @click="showVipView"> 显示vip</button>
<button @click="hideVipView"> 隐藏vip</button>
<button @click="hidePlay"> 隐藏播放器</button>
<button @click="showPlay"> 显示播放器</button>
<button @click="isFull"> 是否全屏</button>
<button @click="getDuration"> 获取时长</button>
<button @click="updateAll"> 更新视频数据</button>
<button @click="openDanmaku"> 开启弹幕</button>
<button @click="closeDanmaku"> 关闭弹幕</button>
</div>
</template>
<script>
//所有图片支持http开头网络图片
let w = uni.getSystemInfoSync().windowWidth;
let h = 400;
//component 自定义控件 radius 圆角值 backgroundColor 背景色 border 边框 borderColor边框颜色
//alignment 文字对齐0:居中 1上左对齐 2上中对齐 3上右对齐 4上两端对齐 5下左对齐 6下中对齐 7下右对齐 8下两端对齐 9居中两端对齐
//textSize:14 文字大小 textColor:'#C0FF3E' 文字颜色 alpha 背景透明度
//hidden 是否隐藏
//code:16//控件标识 同时作为点击事件返回码 01,2,3,4,5占用 不能使用 组件 code值不能重复 rect 图片位置(相对父组件component位置)
//type为full显示在全屏 small 显示在小屏
let component = {
x: w - 20,
y: 60,
w: 50,
h: 50,
type: 'full',
radius: 0,
backgroundColor: '#FFFFFF',
alpha: 0.2,
border: 0,
borderColor: '#E066FF',
code: 66,
hidden: false,
autoHidden: true,
animation: 0, //隐藏 动画 显示隐藏时起作用 0正常 1左 2右 3上 4下
pics: [{
path: '/static/btn_number.png',
x: 0,
y: 0,
w: 50,
h: 50,
code: 661
}]
}; //自定义组件
//let styles = [component];
let styles = [];
let vdata = [{
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: '第一集',
index: '01',
thumb: '/static/cover.jpg',
url: 'https://1318977462.vod-qcloud.com/c41d38favodtranscq1318977462/fb2a2e113270835010023253556/v.f1443687.mp4'
},
{
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: '第二集',
index: '02',
thumb: '/static/cover.jpg',
url: 'https://1318977462.vod-qcloud.com/c41d38favodtranscq1318977462/fb2a2e113270835010023253556/v.f1443687.mp4',
}
];
let data = {
selectAutoPlay: true, //选集点击是否自动播放 默认自动播放
forceDeviceOrientation: false, //旋转方向 true 全屏视频不旋转
radius: 0, //圆角大小 默认 0 没有圆角
showBack: true, //返回按钮是否显示小屏幕
showSelect: true, //选集按钮是否显示
showSpeed: true, //倍速按钮是否显示
showShot: true, //截图按钮是否显示
showDlna: {
small: true,
full: true
}, //投屏按钮是否显示
showDunmaku: {
small: true,
full: true
}, //弹幕按钮是否显示
showMore: {
small: true,
full: true
}, //跟多按钮是否显示
showBottomProcess: true,
autoPlay: false, //默认false
openCache: true, //是否开启缓存
fullGestureSlide: true,
smallGestureSlide: true,
isDrag: true,//进度条条是否拖动
styles: styles,//自定义控件
hideControl: false, //是否隐藏所有控件
backgroundHolder: '', //视频背景图片
backgroundAlpha: 0.3, //0 背景透明度
loop: false, //是否单急循环
ad: {
isShow: false,
url: 'http://t8.baidu.com/it/u=2247852322,986532796&fm=79&app=86&f=JPEG?w=1280&h=853',
skipUrl: 'http://wap.hao123.com'
}, //中间暂停广告,为空则不播放广告
vad: {
isShow: false,
isShowSkip: true,
type: 'image',
duration: 10,
url: 'https://cms-bucket.nosdn.127.net/eb411c2810f04ffa8aaafc42052b233820180418095416.jpeg',
skipUrl: 'http://wap.hao123.com'
}, //播放前视频广告
index: 0,
data: vdata
};
export default {
data() {
return {
boxStyle: {
'height': 400,
'width': '750upx',
},
boxIsLive: false,
boxCoreType: 0,
boxCallback: 'callback'
}
},
onLoad() {
this.wWidth = uni.getSystemInfoSync().windowWidth;
this.boxStyle.width = this.wWidth;
},
onReady() {
//事件监听
//0 小屏状态下返回按钮点击
//1 播放进度实时返回position
//2 视频广告点击事件
//3 暂停广告点击事件
//4 vip点击返回
//5 弹幕开启状态
//6 播放
//7 暂停
//8 缓冲返回
//9 网络错误
//10 钢笔图标点击
//11 选集点击事件
//12 广告详情按钮点击
//13 大小屏切换事件
//14 广告划过事件
//15 广告倒计时点击事件
//16 广告播放完成事件
//17 播放完成事件
//18 下一集事件
//20 准备播放
var globalEvent = weex.requireModule('globalEvent');
var ox = this.$refs.video;
///注意 initVideoData初始化可在 组件中添加 或在 onReady里添加 只能选择一种 数据格式一样
ox.initVideoData(data);
globalEvent.addEventListener(this.boxCallback, function(e) {
let code = e.code;
if (code == 0) {
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 200
});
} else if (code == 1) {
console.log(e);
} else if (code == 20) {
} else if (code == 10) {
} else if (code == 661) {
} else if (code == 14) {
// ox.openDanmaku();
// ox.clearDanmaku();
// ox.addDanmakus([{
// text: '32323',
// isSelf: false,
// color: '#FFFFFF'
// }
// ]);
} else if (code == 3) {
// ox.exitFullScreen();
// setTimeout(function() {
// uni.navigateTo({
// url: 'zb'
// });
// }, 3000)
}
})
},
methods: {
showVipView: function() {
var ox = this.$refs.video;
ox.showVipView();
//vip显示
},
hideVipView: function() {
var ox = this.$refs.video;
ox.hideVipView();
//vip隐藏
},
addComponent: function() {
var ox = this.$refs.video;
ox.addComponent(component);
//动态添加控件 code不能重复
},
updateComponent: function() {
var ox = this.$refs.video;
ox.updateComponent(component);
//动态更新控件 更新的控件 code一定要对应
},
updateDataAtIndex: function() {
var ox = this.$refs.video;
ox.updateDataAtIndex({
index: 1,
data: {
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: '第二集',
index: '02',
thumb: 'https://cms-bucket.nosdn.127.net/cb37178af1584c1588f4a01e5ecf323120180418133127.jpeg',
url: 'https://v3.szjal.cn/20191120/IYfYSiin/index.m3u8',
}
});
//更新索引位置视频数据
ox.playIndex(1);
},
updateAll: function() {
var ox = this.$refs.video;
ox.updateAll({data:[{
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: '第一集',
index: '01',
thumb: 'https://cms-bucket.nosdn.127.net/eb411c2810f04ffa8aaafc42052b233820180418095416.jpeg',
url: 'http://www.easydarwin.org/public/video/3/video.m3u8'
},
{
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: '第二集',
index: '02',
thumb: 'https://cms-bucket.nosdn.127.net/cb37178af1584c1588f4a01e5ecf323120180418133127.jpeg',
url: 'http://vfx.mtime.cn/Video/2019/03/21/mp4/190321153853126488.mp4',
}
]});
setTimeout(function() {
ox.playIndex(0);
}, 500)
//更新所有视频数据
},
seekTo: function() {
var ox = this.$refs.video;
ox.seekTo(1200);
//滑动到指定时间播放毫秒
},
setSpeed: function() {
var ox = this.$refs.video;
ox.setSpeed(1.5);
//设置倍数
},
setVolume: function() {
var ox = this.$refs.video;
ox.setVolume(1.5);
//设置声音
},
setMuted: function() {
var ox = this.$refs.video;
ox.setMuted(true);
//是否静音
},
clearCache: function() {
var ox = this.$refs.video;
ox.clearCache();
//清理缓存
},
next: function() {
var ox = this.$refs.video;
ox.next();
//播放下一条记录
},
prev: function() {
var ox = this.$refs.video;
ox.prev();
//播放上一条记录
},
playIndex: function() {
var ox = this.$refs.video;
ox.playIndex(2);
//播放索引记录
},
start: function() {
var ox = this.$refs.video;
ox.start();
//开始播放
},
pause: function() {
var ox = this.$refs.video;
ox.pause();
//暂停播放
},
replay: function() {
var ox = this.$refs.video;
ox.replay();
//循环播放
},
remove: function() {
var ox = this.$refs.video;
ox.remove();
//去除播放器
},
hidePlay: function() {
var ox = this.$refs.video;
ox.hidePlay();
//隐藏播放器
},
showPlay: function() {
var ox = this.$refs.video;
ox.showPlay();
//显示播放器
},
enterFullScreen: function() {
var ox = this.$refs.video;
ox.enterFullScreen();
//进入全屏
},
exitFullScreen: function() {
var ox = this.$refs.video;
ox.exitFullScreen();
//退出全屏
},
isFull: function() {
var ox = this.$refs.video;
ox.isFull(result => {
let isFull = result.isFull;
uni.showModal({
title: '提示',
content: '是否全屏:' + isFull,
success: function(res) {
}
});
});
//是否全屏
},
getSpeed: function() {
var ox = this.$refs.video;
ox.getSpeed(result => {
let speed = result.speed;
uni.showModal({
title: '提示',
content: '倍速:' + speed,
success: function(res) {
}
});
});
//获取倍速
},
addDanmaku: function() {
var ox = this.$refs.video;
ox.addDanmaku({
text: '测试',
isSelf: true
});
//单条弹幕发送
},
addDanmakus: function() {
var ox = this.$refs.video;
ox.addDanmakus([{
text: '测试',
isSelf: true,
color: '#FFFFFF'
}]);
//多条弹幕发送
},
closeDanmaku: function() {
var ox = this.$refs.video;
ox.closeDanmaku();
//关闭弹幕
},
openDanmaku: function() {
var ox = this.$refs.video;
ox.openDanmaku();
//开启弹幕
},
getDuration: function() {
var ox = this.$refs.video;
ox.duration(result => {
let duration = result.duration;
uni.showModal({
title: '时长',
content: JSON.stringify(result),
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
//获取视频时长 毫秒
},
getScreenShot: function() {
var ox = this.$refs.video;
ox.screenShot(result => {
let base64 = result.base64;
});
//截图 返回base64
},
adSkip: function() {
var ox = this.$refs.video;
ox.adSkip();
//划过广告
},
setOptionValue: function() {
var ox = this.$refs.video;
ox.setOptionValue({
value: '',
key: '',
category: 1
});
//ijk设置 option category 1 FormatOption 2 CodecOption 3 SwsOption 4 PlayerOption
},
setOptionIntValue: function() {
var ox = this.$refs.video;
ox.setOptionIntValue({
value: 0,
key: '',
category: 1
});
//ijk设置 option category 1 FormatOption 2 CodecOption 3 SwsOption 4 PlayerOption
},
setScreenScaleType: function() {
var ox = this.$refs.video;
ox.setScreenScaleType(1);
//设置视频画面 适应 1 2 3
},
enterTinyWindow: function() {
var ox = this.$refs.video;
ox.enterTinyWindow({x:80,y:400});
}
}
};
</script>
<style>
</style>

129
pages/index/dlna.nvue Normal file
View File

@@ -0,0 +1,129 @@
<template>
<div>
<view>
<view class="title">播放进度</view>
<text style="color: #576B95;">{{text}}</text>
</view>
<button @click="startSearch"> 搜索投屏设备 </button>
<button @click="startPush"> 开始投屏 </button>
<button @click="startPushed"> 开始投屏2 </button>
<button @click="stopPush"> 停止投屏 </button>
<button @click="pausePush"> 暂停 </button>
<button @click="resumePush"> 播放 </button>
<button @click="seekTo"> 快进10秒 </button>
<button @click="getVolume"> 获取电视声音 </button>
</div>
</template>
<script>
const ox = uni.requireNativePlugin('Jiang-OxePlayer');
var device;
var p = 0;
export default {
data() {
return {
text: '0'
}
},
onReady() {
console.log('44444444');
ox.initDlna();
const that = this;
var globalEvent = weex.requireModule('globalEvent');
globalEvent.addEventListener('dlnaCallback', function(e) {
console.log(e);
let code = e.code;
if (code == 10) {
let v = e.volume;
ox.setVolume({
volume: v
});
}else if(code == 0){
let t = e.position
that.text = t;
p = t;
}
});
},
methods: {
startSearch: function() {
ox.startSearch(result => {
console.log(result);
if (result.code == 0) {
var ds = result.devices;
device = ds[0];
}
});
},
startPush: function() {
ox.stopPush();
setTimeout(function() {
ox.startPush({
url: 'https://yixuancdn.bangju.com/%E6%8E%8C%E6%8F%A1%E5%81%A5%E5%BA%B7%E7%9A%84%E9%87%91%E9%92%A5%E5%8C%99%20%5BAVC%20720p%5D_batch_batch.mp4',
device: device
});
}, 1000);
},
startPushed: function() {
ox.stopPush();
setTimeout(function() {
ox.startPush({
url: 'https://yixuancdn.bangju.com/%E8%B6%B3%E9%83%A8%E5%8F%8D%E5%B0%84%E7%96%97%E6%B3%95%E7%AC%AC%E4%B8%80%E7%BB%84%E3%80%8B%20%5BAVC%20720p%5D~1.mp4',
device: device
});
}, 1000);
},
stopPush: function() {
ox.stopPush();
},
pausePush: function() {
ox.pause();
},
resumePush: function() {
ox.resume();
},
seekTo: function() {
ox.seek({position:p+10});
},
getVolume: function() {
ox.getVolume(result => {
console.log(result);
});
}
}
}
</script>
<style>
.card {
width: 750rpx;
margin-top: 60rpx;
flex-direction: row;
flex-wrap: wrap;
background-color: #C0C0C0;
}
.box {
width: 185rpx;
height: 185rpx;
justify-content: center;
align-items: center;
}
.row-box {
width: 120rpx;
height: 120rpx;
margin: 10rpx;
background-color: #00000000;
}
.uni-form-item .title {
padding: 20rpx 20;
}
</style>

57
pages/index/dlna1.nvue Normal file
View File

@@ -0,0 +1,57 @@
<template>
<div>
<button @click="startSearch"> 搜索投屏设备 </button>
<button @click="startPush"> 开始投屏 </button>
<button @click="stopPush"> 停止投屏 </button>
<button @click="pausePush"> 暂停 </button>
<button @click="resumePush"> 播放 </button>
</div>
</template>
<script>
const ox = uni.requireNativePlugin('Jiang-OxePlayer');
var device;
export default {
onReady() {
console.log('44444444');
ox.initDlna();
var globalEvent = weex.requireModule('globalEvent');
globalEvent.addEventListener('dlnaCallback', function(e) {
console.log(e);
});
},
methods: {
startSearch: function() {
ox.startSearch(result => {
console.log(result);
if(result.code==0){
var ds =result.devices;
device = ds[0];
}
});
},
startPush: function() {
ox.startPush({
url: 'http://www.easydarwin.org/public/video/3/video.m3u8',
device: device
});
},
stopPush: function() {
ox.stopPush();
},
pausePush: function() {
ox.pause();
},
resumePush: function() {
ox.resume();
}
}
}
</script>
<style>
</style>

78
pages/index/index.nvue Normal file
View File

@@ -0,0 +1,78 @@
<template>
<view>
<zhimi_aliplayer_view ref="playerView" style="width:100%;height:300px;"></zhimi_aliplayer_view>
<button type="primary" @click="start()">开始</button>
<button type="primary" @click="pause()">暂停</button>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
onShow () {
},
onHide () {
this.pause()
},
mounted() {
var playerView = this.$refs.playerView;
playerView.setVidSts({
"vid": "d0c8e6d23e5f71ef81714531858c0102",
"accessKeyId": "STS.NTGWXhnCVxeiE3jv2FPkaconD",
"securityToken": "CAISwgJ1q6Ft5B2yfSjIr5fyHOLcg5x3z6eCRxXbkjITXORNjKrFpjz2IHhMdHFuB+4YsP41lWtS7f8alqJvRoRZXkHfdsp36MzvQMIQgNCT1fau5Jko1beDewHKeT+ZsebWZ+LmNqS/Ht6md1HDkAJq3LL+bk/Mdle5MJqP+/EFA8oQUlv6F00kYu1bPQx/ssQXGGLMPPK2SH7Qj3HXEVBjt3gX6wo9y9zmnJXAtUaG1Qalmr5M9tyuGPX+MZkwZqUYesyuwel7epDG1CNt8BVQ/M909vccoWef4I/DXQcLuUTdabGNqscAMgh1fK8+Fr7vNBB7d2X80Aa6tfMUq34lVYk9O0xUlBgvRFbCU6ovuoKM/1JX7+gpfvTOV/+7+kpvCikgLwgpMPFKCRxrQicnUVK3ROLZvj6DDGitI72BtpVoufIdGoABffDnFykDKsxFFQZwKGrrVUFPL1V48K4ovYkHx15iw2mW6RqNrJDDSl56UfTxDcaRSk0HqA8+e+1pO3LW2vMRHrIhIqhu3gCbbCBATVb8v96Y5HIXIIw29gX9o0xfMgFIdHTZ+YsMSjacnXpvmslLzRD7vNiVgC2E6ySVcvzQOG0gAA==",
"accessKeySecret": "GcyVng2e6UBbmbKiEN1ArqFqy3uGSAg8dsc8N1Pajm2V",
"expireTime": "2024-07-16T10:50:38Z",
"Region": "cn-shanghai",
});
let isFullScreen = true;
// fixed fullscreen play on android
if (plus.os.name.toLowerCase() === 'android') {
plus.key.addEventListener('backbutton', e => {
if (isFullScreen) {
playerView.changeScreenMode(0, false)
isFullScreen = false
} else {
// 这里由于安卓无法监听返回按键这里只能通过plus监听然后自己模拟退回
uni.navigateBack()
}
});
}
playerView.setPlayerCallBack(({ type, data }) => {
switch (type) {
case 'isFullScreen':
isFullScreen = Boolean(data)
break
default:
console.log({ type, data })
}
})
},
methods: {
start() {
var playerView = this.$refs.playerView;
playerView.start();
},
pause() {
var playerView = this.$refs.playerView;
playerView.pause();
}
}
}
</script>
<style>
</style>

257
pages/index/new_file.html Normal file
View File

@@ -0,0 +1,257 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>顾问主页设置</title>
<link rel="stylesheet" type="text/css" href="css/aui.css" />
</head>
<body>
<div class="outerScroller" id="outerScroller">
<div class="aui-content aui-margin-b-15">
<ul id="datalist" class="aui-list">
</ul>
</div>
<footer class="aui-bar aui-bar-tab">
<div class="aui-content-padded">
<div id="btn_add" class="aui-btn aui-btn-info" tapmode onclick="add()">发布</div>
<div id="btn_edit" class="aui-btn" tapmode onclick="edit()">编辑</div>
<div id="btn_del" class="aui-btn" tapmode onclick="del()">删除</div>
</div>
</footer>
</div>
</body>
<script type="text/javascript" src="js/api.js"></script>
<script type="text/javascript" src="js/aui-dialog.js"></script>
<script type="text/javascript" src="js/mui.min.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/pull-load.min.js"></script>
<script type="text/javascript">
var dialog = new auiDialog();
var page = 1;
var isAdd = true;
var oid = '';
var username = '';
var title = '';
$(document).ready(function() {
var id = getParameter("id");
var glsort = getParameter("glsort");
var glsort2 = getParameter("glsort2");
var x_Sn = getParameter("x_Sn");
var templateId = getParameter("templateId");
var token = getParameter("token");
var baseSort = getParameter("baseSort");
var param = 'cisId=' + id + '&glsort=' + glsort + '&basesort=' + 1 + '&codesort=json&page=' + page +
'&pagesize=' + 20;
var url = 'https://www.01as.com/manage/function/qy/gwzy.aspx?' + param;
loadDataList(url, token, false);
});
new PullLoad({
container: document.getElementById("outerScroller"),
down: {
distance: 50, //默认距离
enable: true,
callback: function(end) {
//这个当作测试用。
setTimeout(function() {
var id = getParameter("id");
var glsort = getParameter("glsort");
var glsort2 = getParameter("glsort2");
var token = getParameter("token");
var baseSort = getParameter("baseSort");
page = 1;
var param = 'cisId=' + id + '&glsort=' + glsort + '&basesort=' + 1 +
'&codesort=json&page=' + page + '&pagesize=' + 20;
var url = 'https://www.01as.com/manage/function/qy/gwzy.aspx?' + param;
loadDataList(url, token, false);
isAdd = true;
var btn_add = $api.byId('btn_add');
var btn_edit = $api.byId('btn_edit');
var btn_del = $api.byId('btn_del');
btn_add.setAttribute("class", "aui-btn aui-btn-info")
btn_edit.setAttribute("class", "aui-btn")
btn_del.setAttribute("class", "aui-btn")
end(false);
}, 1500);
}
},
up: {
distance: 50, //默认距离也是创建的div的默认g高度
isScrollLoad: false,
isInitLoad: false,
enable: true,
callback: function(end) {
//这个当作测试用。
setTimeout(function() {
var id = getParameter("id");
var glsort = getParameter("glsort");
var glsort2 = getParameter("glsort2");
var token = getParameter("token");
var baseSort = getParameter("baseSort");
page++;
var param = 'cisId=' + id + '&glsort=' + glsort + '&basesort=' + 1 +
'&codesort=json&page=' + page + '&pagesize=' + 20;
var url = 'https://www.01as.com/manage/function/qy/gwzy.aspx?' + param;
loadDataList(url, token, true);
end(false);
}, 1500);
}
}
});
function loadDataList(url, token, isUp) {
$.ajax({
type: "POST",
url: url,
headers: {
'token': token
},
data: {
type: 'Get'
},
cache: false,
dataType: "text",
success: function(data, textStatus, jqXHR) {
var dd = JSON.parse(data);
if (dd.status == 'success') {
var arr = dd.data;
var listDom = $api.byId('datalist');
if (!isUp) {
listDom.innerHTML = '';
}
if (arr != null && arr.length > 0) {
$.each(arr, function(n, value) {
var str = '<div class="aui-list-item-inner">' +
'<div class="aui-list-item-title">' +
'<label><input class="aui-radio" type="radio" name="gw" value="' +
value.oid + '" data="' + value.username + '" title="' + value.title +
'">用户名:' + value.username + '(' + value.title + ')</label>' +
'</div>' +
'<div class="aui-list-item-right">查看</div>' +
'</div>';
var liDom = document.createElement("li");
liDom.setAttribute("class", "aui-list-item")
liDom.innerHTML = str;
listDom.appendChild(liDom); // 加在列表的后面,上拉加载
});
}
$('input[type=radio]').click(function() {
if (oid == this.value) {
$('input[type="radio"]').prop('checked', false);
oid = '';
isAdd = true;
var btn_add = $api.byId('btn_add');
var btn_edit = $api.byId('btn_edit');
var btn_del = $api.byId('btn_del');
btn_add.setAttribute("class", "aui-btn aui-btn-info")
btn_edit.setAttribute("class", "aui-btn")
btn_del.setAttribute("class", "aui-btn")
} else {
oid = this.value;
username = this.getAttribute("data");
title = this.getAttribute("title");
isAdd = false;
var btn_add = $api.byId('btn_add');
var btn_edit = $api.byId('btn_edit');
var btn_del = $api.byId('btn_del');
btn_add.setAttribute("class", "aui-btn")
btn_edit.setAttribute("class", "aui-btn aui-btn-info")
btn_del.setAttribute("class", "aui-btn aui-btn-info")
}
});
}
}
});
}
function add() {
if (isAdd) {
mui.openWindow({
id: 'gw_add',
url: 'gw_add.html',
show: {
aniShow: 'fade-in',
duration: 300
},
waiting: {
autoShow: false
}
});
}
}
function edit() {
if (!isAdd) {
var param = 'cisId=' + id + '&glsort=' + glsort + '&basesort=' + 1 +
'&codesort=json&page=' + page + '&pagesize=' + 20;
mui.openWindow({
id: 'gw_edit',
url: 'gw_edit.html',
show: {
aniShow: 'fade-in',
duration: 300
},
waiting: {
autoShow: false
}
});
}
}
function del() {
if (!isAdd) {
dialog.alert({
title: "提示",
msg: '确定删除记录吗?',
buttons: ['取消', '确定']
}, function(ret) {
if (ret.buttonIndex == 1) {
var param = 'cisId=' + oid;
var url = 'https://www.01as.com/manage/function/qy/gwzy.aspx?' + param;
$.ajax({
type: "POST",
url: url,
headers: {
'deloid': oid,
'token': token
},
data: {
type: 'Get'
},
cache: false,
dataType: "text",
success: function(data, textStatus, jqXHR) {
var dd = JSON.parse(data);
alert(data);
}
});
}
})
}
}
function getParameter(sProp) {
var re = new RegExp(sProp + "=([^\&]*)", "i");
var a = re.exec(document.location.search);
if (a == null) return null;
return a[1];
}
</script>
</html>

228
pages/index/zb.nvue Normal file
View File

@@ -0,0 +1,228 @@
<template>
<div>
<oxeVideo ref='video'
:isLive='boxIsLive'
:coreType='boxCoreType'
:callback='boxCallback'
:data='boxData'
:style='boxStyle'></oxeVideo>
<button @click="addDanmaku"> 发送弹幕 </button>
<button @click="pause"> 暂停 </button>
<button @click="start"> 播放 </button>
<button @click="showVipView"> 显示vip</button>
<button @click="hideVipView"> 隐藏vip</button>
<button @click="hidePlay"> 隐藏播放器</button>
<button @click="showPlay"> 显示播放器</button>
</div>
</template>
<script>
//所有图片支持http开头网络图片
let w = uni.getSystemInfoSync().windowWidth;
let h = 250;
//component 自定义控件 radius 圆角值 backgroundColor 背景色 border 边框 borderColor边框颜色
//alignment 文字对齐0:居中 1上左对齐 2上中对齐 3上右对齐 4上两端对齐 5下左对齐 6下中对齐 7下右对齐 8下两端对齐 9居中两端对齐
//textSize:14 文字大小 textColor:'#C0FF3E' 文字颜色 alpha 背景透明度
//hidden 是否隐藏
//code:16//控件标识 同时作为点击事件返回码 01,2,3,4,5占用 不能使用 组件 code值不能重复 rect 图片位置(相对父组件component位置)
//type为full显示在全屏 small 显示在小屏
let component = {
x: w - 120,
y: 60,
w: 60,
h: 80,
type: 'small',
radius: 0,
backgroundColor: '#000000',
alpha: 0.5,
border: 0,
borderColor: '#E066FF',
code: 66,
hidden: false,
autoHidden: false,
pics: [{
path: '/static/shop.jpg',
x: 0,
y: 0,
w: 60,
h: 80,
code: 661
}],
texts: []
}; //自定义组件
let styles = [component];
let data = {
forceDeviceOrientation: false, //旋转方向 true 全屏视频不旋转
radius: 5, //圆角大小 默认 0 没有圆角
showBack: true, //返回按钮是否显示小屏幕
showShot: true, //截图按钮是否显示
showDlna: {
small: true,
full: true
}, //投屏按钮是否显示
showDunmaku: {
small: true,
full: true
}, //弹幕按钮是否显示
showMore: {
small: true,
full: true
}, //跟多按钮是否显示
autoPlay: true, //默认false
styles: styles,
hideControl: false, //是否隐藏所有控件
backgroundHolder: '', //视频背景图片
backgroundAlpha: 0.3, //0 背景透明度
loop: false, //是否单急循环
ad: {
isShow: true,
url: 'http://t8.baidu.com/it/u=2247852322,986532796&fm=79&app=86&f=JPEG?w=1280&h=853',
skipUrl: 'http://wap.hao123.com'
}, //中间暂停广告,为空则不播放广告
index: 0,
data: [{
uid: '', //扩展字段 用户id(可选,会随事件返回)
vid: '', //扩展字段 视频id(可选,会随事件返回)
title: 'cctv1',
index: '01',
thumb: 'https://cms-bucket.nosdn.127.net/eb411c2810f04ffa8aaafc42052b233820180418095416.jpeg',
url: 'http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8'
}]
};
export default {
data() {
return {
boxStyle: {
'height': 250,
'width': '750upx',
},
boxIsLive: true,
boxCoreType: 1,
boxCallback: 'callback',
boxData: data
}
},
onLoad() {
this.wWidth = uni.getSystemInfoSync().windowWidth;
this.boxStyle.width = this.wWidth;
},
onReady() {
//事件监听
//0 小屏状态下返回按钮点击
//1 播放进度实时返回position
//3 暂停广告点击
//4 vip点击返回
//5 弹幕开启状态
//6 播放
//7 暂停
//8 缓冲返回
//9 网络错误
//10 钢笔图标点击
//11 选集点击事件
var globalEvent = weex.requireModule('globalEvent');
var ox = this.$refs.video;
///注意 initVideoData初始化可在 组件中添加 或在 onReady里添加 只能选择一种 数据格式一样
//ox.initVideoData(data);
globalEvent.addEventListener(this.boxCallback, function(e) {
let code = e.code;
if (code == 0) {
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 200
});
}else if(code == 1){
}
})
},
methods: {
showVipView: function() {
var ox = this.$refs.video;
ox.showVipView();
//vip显示
},
hideVipView: function() {
var ox = this.$refs.video;
ox.hideVipView();
//vip隐藏
},
addComponent: function() {
var ox = this.$refs.video;
ox.addComponent(component);
//动态添加控件 code不能重复
},
updateComponent: function() {
var ox = this.$refs.video;
ox.updateComponent(component);
//动态更新控件 更新的控件 code一定要对应
},
setVolume: function() {
var ox = this.$refs.video;
ox.setVolume(1.5);
//设置声音
},
setMuted: function() {
var ox = this.$refs.video;
ox.setMuted(true);
//设置静音
},
start: function() {
var ox = this.$refs.video;
ox.start();
//开始播放
},
pause: function() {
var ox = this.$refs.video;
ox.pause();
//暂停播放
},
replay: function() {
var ox = this.$refs.video;
ox.replay();
//循环播放
},
remove: function() {
var ox = this.$refs.video;
ox.remove();
//去除播放器
},
hidePlay: function() {
var ox = this.$refs.video;
ox.hidePlay();
//隐藏播放器
},
showPlay: function() {
var ox = this.$refs.video;
ox.showPlay();
//显示播放器
},
enterFullScreen: function() {
var ox = this.$refs.video;
ox.enterFullScreen();
//进入全屏
},
exitFullScreen: function() {
var ox = this.$refs.video;
ox.exitFullScreen();
//退出全屏
},
addDanmaku: function() {
var ox = this.$refs.video;
ox.addDanmaku({
text: '测试',
isSelf: true
});
//弹幕
}
}
};
</script>
<style>
</style>