-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,55 @@ | ||
// PlaySound使用的全局变量 | ||
// var resPath = "https://courseres.sflep.com/Test/"; | ||
// var soundfile = ""; | ||
// var bufferingTimer: any; | ||
|
||
import { store } from "@src/store"; | ||
// import { addMessage } from "@src/store/actions"; | ||
import logger from "@utils/logger"; | ||
|
||
/** | ||
* 替换原生的playSound函数,以实现无限播放听力 | ||
*/ | ||
export function hackPlaySound() { | ||
((unsafeWindow || window) as any).PlaySound = (src: string, id: string) => { | ||
var count = $("#hdPlay_" + id).val(); | ||
if (count <= 0) return; | ||
|
||
if (soundfile == "") { | ||
soundfile = resPath + "ItemRes/sound/" + src; | ||
createSoundPlayer(); | ||
} else { | ||
soundfile = resPath + "ItemRes/sound/" + src; | ||
jwplayer("soundplayer").load([{ file: soundfile }]); | ||
//clearTimeout(bufferingTimer); | ||
|
||
// var remainCount = 3; | ||
// if (paperAnswer && paperAnswer[id]) { | ||
// try { | ||
// remainCount = parseInt(paperAnswer[id].value); | ||
// } catch (e) {} | ||
// } | ||
|
||
// if (remainCount <= 0) return; | ||
|
||
if (soundPlayer) { | ||
soundPlayer.stop(); | ||
try { | ||
jwplayer("soundplayer").remove(); | ||
} catch (e) {} | ||
} | ||
// jwplayer("soundplayer").onPlaylistComplete(function() { | ||
// jwplayer("soundplayer").load([{ file: "" }]); | ||
// }); | ||
jwplayer("soundplayer").onBufferFull(function () { | ||
clearTimeout(bufferingTimer); | ||
|
||
var sp = $("#btnPlay_" + id); | ||
|
||
sp.html('<span class=" fa fa-play-circle play_symble">' + "无限" + "次播放机会</span>"); | ||
//以下为原生调用 | ||
// if (sp.length > 0) { | ||
// var count = $("#hdPlay_" + id).val(); | ||
// if (count > 0) count--; | ||
// SetCurrentSoundInfo(); | ||
|
||
// //sp.val('播放(' + count + '次机会)'); | ||
currentSoundId = id; | ||
const soundfile = testEnv.resPath + "sound/" + src; | ||
|
||
// $("#hdPlay_" + id).val(count); | ||
// if (count == 0) { | ||
// //$('#btnPlay_' + id).attr("disabled", "disabled"); | ||
// $("#btnPlay_" + id).attr("href", "javascript:void(0);"); | ||
// } | ||
soundPlayer = jwplayer("soundplayer").setup({ | ||
flashplayer: "script/jwplayer.flash.swf?c=" + Math.random(), | ||
file: soundfile, | ||
height: 0, | ||
width: 0, | ||
primary: "html5", | ||
}); | ||
soundPlayer.play(); | ||
|
||
// // SaveCurrentPart(false, true); //异步保存,实时更新听力次数 | ||
// } | ||
// soundPlayer.onBufferFull(function () { | ||
// SetCurrentSoundInfo(); | ||
// }); | ||
|
||
sp.removeClass("loading"); | ||
}); | ||
// $("#btnPlay_" + currentSoundId).html( | ||
// '<span class=" fa fa-play-circle play_symble">正在加载</span>', | ||
// ); | ||
// $("#btnPlay_" + currentSoundId).addClass("loading"); | ||
|
||
$("#btnPlay_" + id).val("正在加载"); | ||
bufferingTimer = setTimeout("PlayerExpireCheck('" + id + "', 0)", 1000); | ||
$("#btnPlay_" + id).addClass("loading"); | ||
// remainCount--; | ||
// autoSaveSound(currentSoundId, remainCount); | ||
|
||
jwplayer("soundplayer").play(); | ||
//if (remainCount <= 0) | ||
// sp.attr("href", "javascript:void(0);"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters