提交 97a3d8e2 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-h5/dist/index.umd.min.js
......@@ -579,6 +579,14 @@ var getSystemInfo = {
}
};
var showActionSheet = {
args (fromArgs) {
if (typeof fromArgs === 'object') {
fromArgs.alertText = fromArgs.title;
}
}
};
// import navigateTo from 'uni-helpers/navigate-to'
const protocols = {
......@@ -586,7 +594,8 @@ const protocols = {
// navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
showActionSheet
};
const todos = [
'vibrate',
......
......@@ -797,6 +797,16 @@ describe('mp:compiler-extra', () => {
'<block wx:if="{{$root.m0}}"><view>{{$root.m1}}</view></block>',
'with(this){var m0=test1(key)&&test2(key);var m1=m0?getValue(key):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}'
)
assertCodegen(
'<view v-if="test.test(key)&&test2(key)">{{getValue(key)}}</view>',
'<block wx:if="{{$root.g0}}"><view>{{$root.m0}}</view></block>',
'with(this){var g0=test.test(key)&&test2(key);var m0=g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
)
assertCodegen(
'<view v-if="show"><view v-if="test.test(key)&&test2(key)">{{getValue(key)}}</view></view>',
'<block wx:if="{{show}}"><view><block wx:if="{{$root.g0}}"><view>{{$root.m0}}</view></block></view></block>',
'with(this){var g0=show?test.test(key)&&test2(key):null;var m0=show&&g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
)
assertCodegen(
'<view v-for="(item,index) in list" :key="index"><view v-if="item">{{getValue(item)}}</view></view>',
'<block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><block wx:if="{{item.$orig}}"><view>{{item.m0}}</view></block></view></block>',
......
......@@ -251,6 +251,11 @@ module.exports = {
t.isMemberExpression(callee) // message.split('').reverse().join('')
) {
// Object.assign...
path = path.findParent((path) => path.isLogicalExpression()) || path
path.skip()
if (path.findParent((path) => path.shouldSkip)) {
return
}
path.replaceWith(getMemberExpr(path, IDENTIFIER_GLOBAL, path.node, this))
}
},
......
const path = require('path')
const t = require('@babel/types')
const babelTraverse = require('@babel/traverse').default
const {
normalizePath
} = require('@dcloudio/uni-cli-shared')
const {
parseComponents
} = require('./util')
......@@ -58,7 +55,7 @@ module.exports = function (ast, state = {}) {
}
} catch (e) {
if (state.filename) {
console.error('at ' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, state.filename)) + ':1')
console.error('at ' + require('@dcloudio/uni-cli-shared').normalizePath(path.relative(process.env.UNI_INPUT_DIR, state.filename)) + ':1')
}
throw e
}
......@@ -66,4 +63,4 @@ module.exports = function (ast, state = {}) {
ast,
state
}
}
}
const path = require('path')
const t = require('@babel/types')
const babelTraverse = require('@babel/traverse').default
const {
normalizePath
} = require('@dcloudio/uni-cli-shared')
const {
parseComponents
} = require('./util')
......@@ -110,7 +107,7 @@ module.exports = function (ast, state = {
components: [],
options: {}
}) {
try {
try {
babelTraverse(ast, {
CallExpression (path) {
const callee = path.node.callee
......@@ -185,7 +182,7 @@ module.exports = function (ast, state = {
})
} catch (e) {
if (state.filename) {
console.error('at ' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, state.filename)) + ':1')
console.error('at ' + require('@dcloudio/uni-cli-shared').normalizePath(path.relative(process.env.UNI_INPUT_DIR, state.filename)) + ':1')
}
throw e
}
......@@ -193,4 +190,4 @@ module.exports = function (ast, state = {
ast,
state
}
}
}
......@@ -20,7 +20,7 @@ eventNames.forEach(name => {
callbacks[name] = []
})
const props = [
const props = [
{
name: 'duration',
readonly: true
......@@ -70,10 +70,15 @@ const props = [
name: 'protocol',
readonly: true,
default: 'http'
},
{
name: 'playbackRate',
default: 1,
cache: true
}
]
const backgroundEvents = ['prev', 'next']
const backgroundEvents = ['prev', 'next']
class BackgroundAudioManager {
constructor () {
......@@ -91,15 +96,15 @@ class BackgroundAudioManager {
} : {})
}
})
})
backgroundEvents.forEach((name) => {
onMethod(`onBackgroundAudio${name[0].toUpperCase() + name.substr(1)}`, () => {
callbacks[name].forEach(callback => {
if (typeof callback === 'function') {
callback({})
}
})
})
})
backgroundEvents.forEach((name) => {
onMethod(`onBackgroundAudio${name[0].toUpperCase() + name.substr(1)}`, () => {
callbacks[name].forEach(callback => {
if (typeof callback === 'function') {
callback({})
}
})
})
})
props.forEach(item => {
const name = item.name
......@@ -114,30 +119,30 @@ class BackgroundAudioManager {
this._options[name] = value
invokeMethod('setBackgroundAudioState', Object.assign({}, this._options, {
audioId: this.id
}))
}), name)
}
}
Object.defineProperty(this, name, data)
})
}
}
play () {
this._operate('play')
}
}
pause () {
this._operate('pause')
}
}
stop () {
this._operate('stop')
}
}
seek (position) {
this._operate('seek', {
currentTime: position
})
}
}
_operate (type, options) {
invokeMethod('operateBackgroundAudio', Object.assign({}, options, {
......@@ -157,4 +162,4 @@ let backgroundAudioManager
export function getBackgroundAudioManager () {
return backgroundAudioManager || (backgroundAudioManager = new BackgroundAudioManager())
}
}
......@@ -60,9 +60,13 @@ const props = [
},
{
name: 'volume'
},
{
name: 'sessionCategory'
},
{
name: 'sessionCategory'
},
{
name: 'playbackRate',
cache: true
}
]
......@@ -95,25 +99,25 @@ class InnerAudioContext {
}
Object.defineProperty(this, name, data)
})
}
}
play () {
this._operate('play')
}
}
pause () {
this._operate('pause')
}
}
stop () {
this._operate('stop')
}
}
seek (position) {
this._operate('seek', {
currentTime: position * 1e3
})
}
}
destroy () {
clearInterval(this.__timing)
......@@ -121,7 +125,7 @@ class InnerAudioContext {
audioId: this.id
})
delete innerAudioContexts[this.id]
}
}
_operate (type, options) {
invokeMethod('operateAudio', Object.assign({}, options, {
......
......@@ -86,9 +86,16 @@ function stopTimeUpdateTimer () {
}
}
function setMusicState (args) {
function setMusicState (args, name) {
initMusic()
const props = ['src', 'startTime', 'coverImgUrl', 'webUrl', 'singer', 'epname', 'title']
if (name && name === 'playbackRate') {
const val = args[name]
audio.playbackRate && audio.playbackRate(parseFloat(val))
return
}
const style = {}
Object.keys(args).forEach(key => {
if (props.indexOf(key) >= 0) {
......@@ -150,8 +157,8 @@ export function operateMusicPlayer ({
errMsg: `${api}:ok`
}
}
export function setBackgroundAudioState (args) {
setMusicState(args)
export function setBackgroundAudioState (args, name) {
setMusicState(args, name)
return {
errMsg: 'setBackgroundAudioState:ok'
}
......
......@@ -5,7 +5,7 @@ import {
import {
publish
} from '../../bridge'
const AUDIO_DEFAULT_SESSION_CATEGORY = 'playback'
const audios = {}
......@@ -14,7 +14,7 @@ const evts = ['play', 'canplay', 'ended', 'stop', 'waiting', 'seeking', 'seeked'
const publishAudioStateChange = (state, res = {}) => publish('onAudioStateChange', Object.assign({
state
}, res))
}, res))
const initStateChage = audioId => {
const audio = audios[audioId]
......@@ -50,10 +50,10 @@ const initStateChage = audioId => {
export function createAudioInstance () {
const audioId = `${Date.now()}${Math.random()}`
const audio = audios[audioId] = plus.audio.createPlayer('')
const audio = audios[audioId] = plus.audio.createPlayer('')
audio.src = ''
audio.volume = 1
audio.startTime = 0
audio.startTime = 0
audio.setSessionCategory(AUDIO_DEFAULT_SESSION_CATEGORY)
return {
errMsg: 'createAudioInstance:ok',
......@@ -81,8 +81,9 @@ export function setAudioState ({
autoplay = false,
loop = false,
obeyMuteSwitch,
volume,
sessionCategory = AUDIO_DEFAULT_SESSION_CATEGORY
volume,
sessionCategory = AUDIO_DEFAULT_SESSION_CATEGORY,
playbackRate
}) {
const audio = audios[audioId]
if (audio) {
......@@ -91,7 +92,9 @@ export function setAudioState ({
autoplay
}
if (src) {
audio.src = style.src = getRealPath(src)
// iOS 设置 src 会重新播放
const realSrc = getRealPath(src)
if (audio.src !== realSrc) audio.src = style.src = realSrc
}
if (startTime) {
audio.startTime = style.startTime = startTime
......@@ -99,9 +102,12 @@ export function setAudioState ({
if (typeof volume === 'number') {
audio.volume = style.volume = volume
}
audio.setStyles(style)
if (sessionCategory) {
audio.setSessionCategory(sessionCategory)
audio.setStyles(style)
if (sessionCategory) {
audio.setSessionCategory(sessionCategory)
}
if (playbackRate && audio.playbackRate) {
audio.playbackRate(playbackRate)
}
initStateChage(audioId)
}
......
export default {
args (fromArgs) {
if (typeof fromArgs === 'object') {
fromArgs.alertText = fromArgs.title
}
}
}
......@@ -2,13 +2,15 @@
import redirectTo from '../../helpers/redirect-to'
import previewImage from '../../helpers/normalize-preview-image'
import getSystemInfo from '../../helpers/system-info'
import showActionSheet from '../../helpers/show-action-sheet'
export const protocols = {
redirectTo,
// navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
showActionSheet
}
export const todos = [
'vibrate',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册