提交 311a4c3a 编写于 作者: Q qiang

chore: build

上级 97a3d8e2
......@@ -4391,7 +4391,7 @@ var serviceContext = (function () {
const publishAudioStateChange = (state, res = {}) => publish('onAudioStateChange', Object.assign({
state
}, res));
}, res));
const initStateChage = audioId => {
const audio = audios[audioId];
......@@ -4427,10 +4427,10 @@ var serviceContext = (function () {
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',
......@@ -4458,8 +4458,9 @@ var serviceContext = (function () {
autoplay = false,
loop = false,
obeyMuteSwitch,
volume,
sessionCategory = AUDIO_DEFAULT_SESSION_CATEGORY
volume,
sessionCategory = AUDIO_DEFAULT_SESSION_CATEGORY,
playbackRate
}) {
const audio = audios[audioId];
if (audio) {
......@@ -4468,7 +4469,9 @@ var serviceContext = (function () {
autoplay
};
if (src) {
audio.src = style.src = getRealPath$1(src);
// iOS 设置 src 会重新播放
const realSrc = getRealPath$1(src);
if (audio.src !== realSrc) audio.src = style.src = realSrc;
}
if (startTime) {
audio.startTime = style.startTime = startTime;
......@@ -4476,9 +4479,12 @@ var serviceContext = (function () {
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);
}
......@@ -4611,9 +4617,16 @@ var serviceContext = (function () {
}
}
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) {
......@@ -4675,8 +4688,8 @@ var serviceContext = (function () {
errMsg: `${api}:ok`
}
}
function setBackgroundAudioState (args) {
setMusicState(args);
function setBackgroundAudioState (args, name) {
setMusicState(args, name);
return {
errMsg: 'setBackgroundAudioState:ok'
}
......@@ -12096,7 +12109,7 @@ var serviceContext = (function () {
callbacks$5[name] = [];
});
const props = [
const props = [
{
name: 'duration',
readonly: true
......@@ -12146,10 +12159,15 @@ var serviceContext = (function () {
name: 'protocol',
readonly: true,
default: 'http'
},
{
name: 'playbackRate',
default: 1,
cache: true
}
];
const backgroundEvents = ['prev', 'next'];
const backgroundEvents = ['prev', 'next'];
class BackgroundAudioManager {
constructor () {
......@@ -12167,15 +12185,15 @@ var serviceContext = (function () {
} : {});
}
});
});
backgroundEvents.forEach((name) => {
onMethod(`onBackgroundAudio${name[0].toUpperCase() + name.substr(1)}`, () => {
callbacks$5[name].forEach(callback => {
if (typeof callback === 'function') {
callback({});
}
});
});
});
backgroundEvents.forEach((name) => {
onMethod(`onBackgroundAudio${name[0].toUpperCase() + name.substr(1)}`, () => {
callbacks$5[name].forEach(callback => {
if (typeof callback === 'function') {
callback({});
}
});
});
});
props.forEach(item => {
const name = item.name;
......@@ -12190,30 +12208,30 @@ var serviceContext = (function () {
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, {
......@@ -20188,9 +20206,13 @@ var serviceContext = (function () {
},
{
name: 'volume'
},
{
name: 'sessionCategory'
},
{
name: 'sessionCategory'
},
{
name: 'playbackRate',
cache: true
}
];
......@@ -20223,25 +20245,25 @@ var serviceContext = (function () {
}
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);
......@@ -20249,7 +20271,7 @@ var serviceContext = (function () {
audioId: this.id
});
delete innerAudioContexts[this.id];
}
}
_operate (type, options) {
invokeMethod('operateAudio', Object.assign({}, options, {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册