标签 APlayer 下的文章

APlayer Typecho插件兼容instantclick.js

超级推荐用这个大佬写的aplayer插件地址:https://github.com/MoePlayer/APlayer-Typecho然后在预加载重载函数里写上loadMeting();即可如果遇到切换页面音乐不停止的问题,再重载函数里再补充这条语句if (typeof aplayers !== 'undefined'){ for (var i = 0; i < aplayers.length; i++) { try {aplayers[i].destroy()} catch(e){} } }↓以下文章内容已弃用APlayer Typecho插件https://github.com/FaithPatrick/APlayer-Typecho-Plugininstantclick 3.0.1版兼容方法来自https://muguang.me/php/typecho-theme-apollo.html将预加载的执行代码<script data-no-instant> InstantClick.init(); </script>改为<script data-no-instant> if (!window.audios) { audios = []; for (var i = 0; i < APlayers.length; i++) { audios[i] = APlayers[i].audio; } } InstantClick.on('change', function (isInitialLoad) { for (var i = 0; i < APlayers.length; i++) { audios.push(APlayers[i].audio); } for(var i = 0; i < audios.length; i++) {if(audios[i]){audios[i].pause()}}; }); InstantClick.init(); </script> <script>var APlayerOptions = [];</script>//如果无效果尝试删掉这行instantclick 3.1.0版兼容[不完美]这个是我参考上边的瞎弄弄出来的,虽然完全看不懂QAQ。。。打开插件的plugin.php将里面的<script> var len = APlayerOptions.length; for(var i=0;i<len;i++){ if(document.getElementById('player' + APlayerOptions[i]['id'])) { APlayers[i] = new APlayer({ element: document.getElementById('player' + APlayerOptions[i]['id']), narrow: false, preload: APlayerOptions[i]['preload'], mutex: APlayerOptions[i]['mutex'], autoplay: APlayerOptions[i]['autoplay'], showlrc: APlayerOptions[i]['showlrc'], music: APlayerOptions[i]['music'], theme: APlayerOptions[i]['theme'] }); //APlayers[i].init(); } } </script>改为<script data-no-instant>//就是这里有修改,其他都没动 var len = APlayerOptions.length; for(var i=0;i<len;i++){ if(document.getElementById('player' + APlayerOptions[i]['id'])) { APlayers[i] = new APlayer({ element: document.getElementById('player' + APlayerOptions[i]['id']), narrow: false, preload: APlayerOptions[i]['preload'], mutex: APlayerOptions[i]['mutex'], autoplay: APlayerOptions[i]['autoplay'], showlrc: APlayerOptions[i]['showlrc'], music: APlayerOptions[i]['music'], theme: APlayerOptions[i]['theme'] }); //APlayers[i].init(); } } </script>将预加载的执行代码<script data-no-instant> InstantClick.init(); </script>改为<script data-no-instant> if (!window.audios) { audios = []; for (var i = 0; i < APlayers.length; i++) { audios[i] = APlayers[i].audio; } } InstantClick.on('change', function(isInitialLoad) { if (isInitialLoad === false) { var len = APlayerOptions.length; for(var i=0;i<len;i++){ if(document.getElementById('player' + APlayerOptions[i]['id'])) { APlayers[i] = new APlayer({ element: document.getElementById('player' + APlayerOptions[i]['id']), narrow: false, preload: APlayerOptions[i]['preload'], mutex: APlayerOptions[i]['mutex'], autoplay: APlayerOptions[i]['autoplay'], showlrc: APlayerOptions[i]['showlrc'], music: APlayerOptions[i]['music'], theme: APlayerOptions[i]['theme'] }); //APlayers[i].init(); } } for (var i = 0; i < APlayers.length; i++) {audios.push(APlayers[i].audio);} for(var i = 0; i < audios.length; i++) {if(audios[i]){audios[i].pause()}}; } }); InstantClick.init();</script&g...

阅读文章
1/1