首页后端开发JAVAAPlayer Typecho插件兼容instantclick.js

APlayer Typecho插件兼容instantclick.js

时间2023-04-25 02:27:01发布访客分类JAVA浏览1377
导读:超级推荐用这个大佬写的aplayer插件地址:https://github.com/MoePlayer/APlayer-Typecho 然后在预加载重载函数里写上loadMeting( ;即可如果遇到切换页面音乐不停止的问题,再重载函数里...

超级推荐用这个大佬写的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-Plugin

instantclick 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;
    ilen;
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;
    ilen;
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;
    ilen;
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>
    

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

phpplugintypecho插件函数

若转载请注明出处: APlayer Typecho插件兼容instantclick.js
本文地址: https://pptw.com/jishu/7868.html
Typecho不修改源码不关闭反垃圾保护兼容pjax 【详细教程】HTML、CSS 和 JS 实现一个任务管理工具-ToDoList

游客 回复需填写必要信息