Skip to content

Commit

Permalink
video controls
Browse files Browse the repository at this point in the history
  • Loading branch information
szuprefix committed Mar 11, 2020
1 parent a80e76e commit 704299f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-django",
"version": "0.7.4",
"version": "0.7.5",
"description": "个人实验项目, 本框架的目标是借鉴并超越django admin的自动化思想, 实现UI前端的极简快速定制开发",
"main": "index.js",
"files": [
Expand Down
51 changes: 39 additions & 12 deletions src/components/media/qcloud/Controls.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<template>
<div v-if="isActive">
<popup-radio title="画质" v-model="definition" :options="definitionOptions"></popup-radio>
<!--<x-button @click.native="changeSrc(f)" v-for="f in files" :key="f.Definition">{{f.name}}</x-button>-->
<div class="wechat_android_video_control">
<span @click="showPopup = true">{{definitionMap[definition]}}</span>
<span @click="togglePlaybackRate">{{playbackRate}}x</span>
</div>
<!--<popup-radio title="倍速" v-model="playbackRate" :options="playbackRateOptions"></popup-radio>-->
<popup v-model="showPopup">
<group title="画质">
<radio v-model="definition" :options="definitionOptions" :fill-mode="false"></radio>
</group>
</popup>
</div>
</template>
<script>
import {XButton, PopupRadio} from 'vux'
import {XButton, PopupRadio, Popup, Radio, Group} from 'vux'
import {get} from 'lodash'
import Cache from 'vue-django/src/utils/cache'
export default{
Expand All @@ -15,12 +23,21 @@
data () {
return {
definition: 20,
definitionMap: {
10: '流畅',
20: '标清',
30: '高清',
1100: '纯音频'
},
breakPoint: 0,
playbackRate: 1,
playbackRates: [0.5, 1, 1.25, 1.5, 2],
showPopup: false,
currentTime: 0,
cache: Cache(`qcloud.vod.${this.fileId}.currentTime`)
}
},
components: {XButton, PopupRadio},
components: {XButton, PopupRadio, Popup, Radio, Group},
mounted () {
if (this.isActive) {
this.init()
Expand All @@ -35,6 +52,9 @@
this.breakPoint = ct
this.setCurrentTime(ct)
},
togglePlaybackRate () {
this.playbackRate = this.playbackRates.find(a => a > this.playbackRate) || this.playbackRates[0]
},
init () {
let ct = this.cache.read() || 0
this.breakPoint = ct
Expand Down Expand Up @@ -70,17 +90,10 @@
return this.options.FileId || this.options.FileId
},
files () {
let dm = {
10: '流畅',
20: '标清',
30: '高清',
1100: '纯音频'
}
return get(this.options, 'TranscodeInfo.TranscodeSet', [])
.filter(a => [10, 20, 30, 1100].includes(a.Definition))
.map(a => {
return {definition: a.Definition, name: dm[a.Definition], url: a.Url}
return {definition: a.Definition, name: this.definitionMap[a.Definition], url: a.Url}
})
},
isActive () {
Expand All @@ -95,7 +108,21 @@
watch: {
definition (v) {
this.changeSrc(this.files.find(a => a.definition === v))
},
playbackRate (v) {
this.getEl().playbackRate = v
}
}
}
</script>
<style>
.wechat_android_video_control {
background-color: darkgray;
color: white;
padding: 0.5rem;
}
.wechat_android_video_control span {
padding: 0 1rem;
}
</style>
2 changes: 1 addition & 1 deletion src/components/mobile/model/Panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
let d = {meta: {}}
this.items.forEach((f) => {
let p = f.placeholder || 'meta'
let v = a[f.name]
let v = (f.name === '$' && a) || a[f.name]
if (f.format) {
v = f.format(v)
}
Expand Down
10 changes: 6 additions & 4 deletions src/mixins/server_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
},
onServerResponseError: function (error) {
this.loading = false
if(error == 'cancel'){ // confirm dialog cancel ?
if (error == 'cancel') { // confirm dialog cancel ?
return
}
if ([404,403,405,429, 537].includes(error.code) && error.msg.detail) {
Expand All @@ -73,9 +73,11 @@ export default {
if (error.code === 400) {
// this.errors = this.formErrors = joinErrors(error.msg)
} else if (error.code === 401) {
this.$store.state.bus.$emit("user-logout")
} else if (error.code === 502){
this.alertError("网关错误")
this.$store.state.bus.$emit('user-logout')
} else if (error.code === 502) {
this.alertError('网关错误')
} else if (error instanceof Error) {
this.alertError({code: error.name, msg: error.message})
} else {
this.alertError(error)
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {formatRelative, subDays, distance_in_words_to_now} from 'date-fns'
import zh_cn from 'date-fns/locale/zh_cn'

function dateTime (t) {
export function dateTime (t) {
if (typeof t === 'string' && !t.includes('+')) {
t = t.concat('+08:00')
}
Expand Down Expand Up @@ -141,6 +141,7 @@ export function duration (a) {
}

export default {
dateTime,
date2now,
date,
parseTime,
Expand Down

0 comments on commit 704299f

Please sign in to comment.