Skip to content

Commit

Permalink
add warning for relative url of playVoice
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Mar 31, 2017
1 parent 87bd51f commit 140dbf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/command.js
Expand Up @@ -27,7 +27,12 @@ import confirm from './component/confirm'
import Toast from './component/toast'
import mask from './component/mask'
import qrscan from './component/qrscan'
import {getRedirectData, validPath, dataURItoBlob, toNumber} from './util'
import {getRedirectData,
validPath,
dataURItoBlob,
isAbs,
warn,
toNumber} from './util'

let appData = {} //eslint-disable-line
let fileIndex = 0
Expand Down Expand Up @@ -533,7 +538,8 @@ export function stopRecord() {

export function playVoice(data) {
let url = data.args.filePath
let audio = document.getElementById("audio");
if (!isAbs(url)) warn('playVoice 相对路径 url 仅在 WEPT 中可用,请在应用上线前切换为线上 url')
let audio = document.getElementById("audio")
if (audio.src && audio.paused && !audio.ended) {
// resume
audio.play()
Expand Down
4 changes: 4 additions & 0 deletions src/util.js
Expand Up @@ -128,3 +128,7 @@ export function warn(msg) {
console.warn(msg)
}
}

export function isAbs(url) {
return /^http/.test(url)
}

0 comments on commit 140dbf8

Please sign in to comment.