Commit e5ad7f26 by 李伟康

修复音频没加载完点击直播后会播放音频BUG

1 parent be651b29
export function Audio(url, callBack) { export function Audio (url, callBack) {
// this.IsIOS = false // this.IsIOS = false
this.IsIOS = window.$IsIOS this.IsIOS = window.$IsIOS
this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)() this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)()
...@@ -8,7 +8,7 @@ export function Audio(url, callBack) { ...@@ -8,7 +8,7 @@ export function Audio(url, callBack) {
this.toggleBGM = function (off) { this.toggleBGM = function (off) {
if (typeof this.sourceNode == 'object' && !this.IsIOS) { if (typeof this.sourceNode == 'object' && !this.IsIOS) {
if (this.isPlayingBGM || off) { if (this.isPlayingBGM || off) {
this.sourceNode.stop() this.sourceNode && this.sourceNode.stop()
this.isPlayingBGM = false this.isPlayingBGM = false
console.log('暂停——————————————', this.sourceNode) console.log('暂停——————————————', this.sourceNode)
} else this._playSourceNode() } else this._playSourceNode()
...@@ -20,7 +20,7 @@ export function Audio(url, callBack) { ...@@ -20,7 +20,7 @@ export function Audio(url, callBack) {
this.stopVideo = function () { this.stopVideo = function () {
if (typeof this.sourceNode == 'object' && !this.IsIOS) { if (typeof this.sourceNode == 'object' && !this.IsIOS) {
if (this.isPlayingBGM) { if (this.isPlayingBGM) {
this.sourceNode.stop() this.sourceNode && this.sourceNode.stop()
this.isPlayingBGM = false this.isPlayingBGM = false
console.log('暂停——————————————', this.sourceNode) console.log('暂停——————————————', this.sourceNode)
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!