Git Product home page Git Product logo

get-picture-color's People

Contributors

iggh966380 avatar jasonaiii avatar

Watchers

 avatar  avatar

get-picture-color's Issues

MDN: URL.createObjectURL()

可以建立一個包含物件URL的字串,代表了傳入參數的物件

這個URL的生命週期會跟document綁在一起,離開該頁面 -> URL銷毀 (在SPA中?)

假如要手動銷毀object URL,使用revokeObjectURL() 即可

語法

createObjectURL(object);

其中object可以是檔案,二進位檔(圖片),mediasource(影片)

return代表了傳入的object網址

使用上的注意:

記憶體管理:

在呼叫了createObjURL之後都會建立一個新的物件URL,就算是在這之前就有針對同樣的物件建立過物件URL,也因此在確定用不到該物件URL之後要呼叫 revokeObjURL() 進行釋放,儘管在離開頁面後就會自動銷毀,但基於效能及記憶體管理,進行手動釋放還是比較好的做法。

針對媒體串流(影片):
在較為老舊的媒體資源中,在使用video標籤時需要進行createObjURL建立媒體串流物件的URL,不過現在已經不需要這麼做,瀏覽器也都在移除針對這件事的支持度。

如果真的還有code是依賴著createObjURL()的話,可以用srcObject直接綁定在媒體串流上

針對媒體串流只剩下ie10還有在支援

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.