Giter Club home page Giter Club logo

Comments (4)

hustKiwi avatar hustKiwi commented on September 16, 2024

现在初始化 MuPlayer 是单实例,一般而言,即便是SAP应用,只要合理的控制页面渲染,比如留好页面内容的占位,每次切换页面只是更改占位中的DOM,这样按说不会影响到 muplayer。MuPlayer在初始化时,会默认把audio和swf的容器放在body内容的最后。因此,即便是SAP,只要合理规划,MuPlayer并不需要初始化后被销毁的情况,也不会存在内容泄露问题。可以用手机访问一下我们百度音乐的webapp:http://music.baidu.com/ ,看一下我们的处理方式。

不过我可以加一个 destroy 方法,但不保证达到你说的销毁内存的效果。据我所知,在前端,内存的销毁需满足三点:1. 对应的dom节点被移除 2. 绑在该实例上的事件全部被解绑 3. 该实例没有被赋值到其他全局变量上。

即便全部做到,也不一定保证立即触发内存回收机制。反而往往因为使用方的误用,例如,混乱的事件绑定,或全局变量使用,会导致内存无法被回收。因此,我会提供一个destroy方法做dom销毁及muplayer示例上的事件解绑,除此之外,是否真能被完美回收,也依赖调用方的使用。

关于ID3,我个人觉得依赖ID3存储歌曲的元信息不一定是一个产品级的解决方案,即便用,最好根据音频构建自己的曲库资源,讲解析放在后端通过API提供。如有需要,后面会以插件形式提供一个ID3解析的方式,不过估计优先级不高。年前我还有一周就休假了,还有别的事情要处理,不一定有时间去实现。后面会考虑提供一下,如果你比较熟悉,也欢迎提交 pull request

from muplayer.

janryWang avatar janryWang commented on September 16, 2024

对,其实我需要也就是dom销毁和事件解绑,这样已经够了,完美回收内存的确得看使用者,当然,对于id3这块的话,如果要给大家做插件的话,只需要留出可以访问buffer数据的接口就行了

from muplayer.

hustKiwi avatar hustKiwi commented on September 16, 2024

@janryWang 如之上讨论,添加了destroy方法(清理dom并解绑事件),但没有做详细的内存占用的测试,你如果使用时可以帮忙测测看。
注意,如果将player实例绑在其他全局变量上,在调用destroy方法后,须将player delete掉或赋值为null。这些应该业务端自己保证。另外ID3解析,我单独开了个issue:#77 ,之后会考虑提供。我下周就休年假了,估计得3月份回来再实现了。

from muplayer.

janryWang avatar janryWang commented on September 16, 2024

好的,没问题,谢谢了哈

from muplayer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.