天給大家整理了一些 素材網站 讓大家更好通過各種計劃.
圖片素材庫
國內:
https://huaban.com
http://699pic.com
https://www.58pic.com
百度圖片
國外:
https://pixabay.com
https://unsplash.com
https://gratisography.com/page/3/
https://cn.freeimages.com/image
https://www.freepik.com
https://foter.com
https://visualhunt.com
https://www.inspirationde.com/
視頻素材庫
https://pixabay.com/zh/videos/
https://mixkit.co/videos/
https://gaiamount.com
https://www.filmstocks.com/c/effects-filmora-effects.html
https://www.skypixel.com/tags?group=equipment
音頻素材庫
https://www.free-stock-music.com/search.php?cat=&mood=&license=&bpm=&length=&keyword=
http://www.aigei.com/
https://audionautix.com/
https://www.audiolibrary.com.co/
https://www.youtube.com/audiolibrary/music
字體素材庫
國內無授權免費的商用字體:思源字體、站酷字體、瀨戶字體、龐門正道標題本、手書體中文簡體、阿里巴巴普惠體
https://www.zcool.com.cn
站長之家—站長素材
片頭素材庫
https://panzoid.com/tools/clipmaker
使用時下載谷歌翻譯插件,將網站的英文翻譯成中文,便于實操。
視頻解析網站:
https://youtube.iiilab.com/
http://www.tutujiexi.com/kuaishou.html
語音轉字幕
https://www.iflyrec.com/
https://jianwai.netease.com/
語音合成
https://www.data-baker.com/tts.html
學習資源網站:
https://www.doyoudo.com
http://www.syseen.com(用QQ瀏覽器打開)
高清電影 電視劇 網站:
https://gaoqing.fm/
http://www.btdx8.com/
http://www.yournextfilm.com/us/
http://gaoqing.la/
http://www.bttt.la/
http://neets.cc/found
http://www.ttmeiju.com/
http://www.zimuku.net/
http://keepvid.com/
http://www.mtime.com/trailer/trailer/
http://yugaopian.cn/
http://www.imdb.com/
http://www.btbtdy.com/
http://www.hao4k.com/
http://ww手機,電腦找尋優質素材
找圖片
手機的壁紙軟件
花瓣
https://huaban.com/
站酷
https://www.zcool.com.cn/
千圖
https://www.58pic.com/
有的圖片需要會員
千庫網
https://588ku.com/
缺點:有的圖片需要會員
堆糖
https://www.duitang.com/
Pexels
https://www.pexels.com/
缺點:只支持英文搜圖。
500PX
https://web.500px.com/
缺點:雖然支持中文,但是采用中文進行搜索準確率太低。
找文案
微博,知乎,簡書,天涯,小紅書,貼吧,豆瓣,公眾號,各大自媒體平臺(頭條號,大魚號,企鵝號)等
抖音拍
拍同款
翻拍
數英網(市場營銷、廣告傳媒、創意設計、電商、移動互聯網等)
https://www.digitaling.com/
頂尖文案(全球范圍內最優秀的創意資訊)
https://www.topys.cn/
廣告門(是中國廣告傳播行業領先在線媒體及產業互動資訊服務平臺)
https://www.adquan.com/
梅花網(營銷者的信息中心)
https://www.meihua.info/
中華廣告網(國內最專業的廣告行業門戶網站)
http://www.a.com.cn/index.html
SocialBeta (社交媒體和數字營銷內容)
https://socialbeta.com/
商業洞察(品牌行銷廣告創意)
https://www.motive.com.tw/
廣告最好看(視頻廣告文案)
https://zhk8.com/
我是文案(文案案例、文案新聞、文案寫作)
http://copywrite-tw.com/
找視頻
bilibili b站(動漫,2次元)
騰訊,愛奇藝,優酷等各大平臺
瘋狂影視
http://ifkdy.com/
搜索全網電影電視的影視搜素引擎
視屏資源網站
www.ygdy8.com
80s
茶狐杯
https://www.cupfox.com/
中國最大的影視資源聚合搜索引擎
手機實操
微信搜索 西果工具小程序
可去抖音水印
迅雷下載
安卓可用
手機
手機自帶的軟件
電腦實操
瀏覽器上
bianlu1
貓抓,適合抓音頻(抓語音,音樂)不適合抓視頻
邊播邊錄
手機上面沒有貓抓,在QQ瀏覽器上面有“資源嗅探”可以抓取語音和音樂
語言合成(標貝科技)
https://www.data-baker.com/
錄屏
電腦
ev錄屏
http://xinzhi.wenda.so.com/a/1547632721203232
手機,電腦找尋優質素材
找圖片
手機的壁紙軟件
花瓣
https://huaban.com/
站酷
https://www.zcool.com.cn/
千圖
https://www.58pic.com/
有的圖片需要會員
千庫網
https://588ku.com/
缺點:有的圖片需要會員
堆糖
https://www.duitang.com/
Pexels
https://www.pexels.com/
缺點:只支持英文搜圖。
500PX
https://web.500px.com/
缺點:雖然支持中文,但是采用中文進行搜索準確率太低。
找文案
微博,知乎,簡書,天涯,小紅書,貼吧,豆瓣,公眾號,各大自媒體平臺(頭條號,大魚號,企鵝號)等
抖音拍
拍同款
翻拍
數英網(市場營銷、廣告傳媒、創意設計、電商、移動互聯網等)
https://www.digitaling.com/
頂尖文案(全球范圍內最優秀的創意資訊)
https://www.topys.cn/
廣告門(是中國廣告傳播行業領先在線媒體及產業互動資訊服務平臺)
https://www.adquan.com/
梅花網(營銷者的信息中心)
https://www.meihua.info/
中華廣告網(國內最專業的廣告行業門戶網站)
http://www.a.com.cn/index.html
SocialBeta (社交媒體和數字營銷內容)
https://socialbeta.com/
商業洞察(品牌行銷廣告創意)
https://www.motive.com.tw/
廣告最好看(視頻廣告文案)
https://zhk8.com/
我是文案(文案案例、文案新聞、文案寫作)
http://copywrite-tw.com/
找視頻
bilibili b站(動漫,2次元)
騰訊,愛奇藝,優酷等各大平臺
瘋狂影視w.viphd.co/
為52題需要創建一個web 后臺,并開發一個客戶端來請求,并在界面顯示。
涉及到internet web 請求相關的內容。
如下題目,實現本身很容易,但是做題的目的不純是做題,還是先做下基礎學習。
翻譯下面這本書,講的不是很深,但是基本原理說的還是很清晰的:
https://launchschool.com/books/http/read/introduction#gettingstarted
Introduction
Getting Started
If you're like most people, you've been using the internet for a long time - years, perhaps decades - and typing in those pesky URL addresses at the top of your browser, starting with the letters H, T, T, P, followed by the colon, slash, slash, w, w, w then the domain, over and over and over, yet never knowing or caring to know about what it stood for.
HTTP is at the core of what the web is about, and also at the core of dynamic web applications. Understanding HTTP is central to understanding how modern web applications work and how they're built. This book will cover some basic concepts around HTTP, and you'll have a much better understanding of how the web and web applications work after going through it.
翻譯:HTTP是因特網的核心,這本書會介紹HTTP幾個基礎的概念。
Who Is This Guide For?
This book is geared towards those who have been using the internet for a while, but have never built dynamic web applications before. It's meant for people interested in understanding how web applications work, and lays the foundational knowledge to learning more advanced web application development concepts.
翻譯:這篇文章是為一些人,這些人已經用了internet 很久了,不過從來沒有搭建過動態web 應用。為有興趣了解web 怎么工作的人,介紹一些基礎知識,這樣可以學到更高級的web 應用開發的概念。
How To Read This Guide?
Most of this book is going to be reading oriented. That is, there are not a lot of exercises, because this is mostly a book about concepts. However, where there are examples, please take time to follow along and learn by doing. There is no better way to truly understand a topic than by doing.
翻譯:這本書沒有太多的練習,主要是面向讀者。
Background
A Brief Overview & History
When you type a URL into the address bar of your web browser, you expect to see the website displayed in your browser. When you click on a link, or submit a form, your browser may display the next page, or display errors in your form so you can correct them and submit again. Your browser is the interface or window, through which you interact with the world wide web.
Under your browser's hood lies a collection of files -- CSS, HTML, Javascript, videos, images, etc. -- that makes displaying the page possible. All these files were sent from a server to your browser, the client, by an application protocol called HTTP (yes, this is why URLs in your browser address bar start with "http://").
HTTP, or Hypertext Transfer Protocol, was invented by Tim Berners-Lee in the 1980s. It is a system of rules, a protocol, that serve as a link between applications and the transfer of hypertextdocuments. Stated differently, it's an agreement, or message format, of how machines communicate with each other. HTTP follows a simple model where a client makes a request to a server and waits for a response. Hence, it's referred to as a request response protocol. Think of the request and the response as text messages, or strings, which follow a standard format that the other machine can understand.
The HTTP protocol has been through several changes from its inception. The protocol started in its most simplified form returning only HTML pages. In 1991, the first document version HTTP/0.9 was released. In 1992, HTTP/1.0 was released with the ability to transmit different file types like CSS documents, videos, scripts and images. 1995 saw the release of HTTP/1.1, which introduced the ability to reuse established connections for subsequent requests, among a host of other features. Further improvements made to HTTP/1.1 in 1999 resulted in what we mostly see today. The evolution of HTTP doesn't stop there though. HTTP/2 is fast gaining traction, and the latest version, HTTP/3, is currently in development.
快速介紹背景和歷史:
瀏覽器這個帽子底下,藏著一堆文件:CSS、HTML、javascript,video,images 等等。這些內容都是從一個服務器發送到你的瀏覽器上的。(瀏覽器又叫客戶端) HTTP 就是一個請求回復的協議。可以把請求回復理解為 用文本信息、字符串 進行傳輸,以機器語言來返回。
1992 年 HTTP/1.0 能夠傳輸不同的文件類型,比如CSS、Videos,scriptes、images. 1995 年 HTTP/1.1 開始能夠重復使用已經建立的鏈接,進行隨后的請求。
1999年的 HTTP/1.1 更新版本 基本就是我們現在看到的版本。 目前HTTP/2 正在快速獲得大眾支持。
How the Internet Works
The Internet consists of millions of interconnected networks that allow all sorts of computers and devices to communicate with each other. By convention, all devices that participate in a network are provided unique labels. The general term for this type of label is an Internet Protocol Address or IP Address and is similar to a computer's phone number on the Internet. Port numbers add more detail about how to communicate (think of company phone extensions). IP Addresses are represented as:
192.168.0.1
When a port number is needed, the address is specified as:
192.168.0.1:1234
where the IP Address is 192.168.0.1 and the port number is 1234. An IP Address acts as the identifier for a device or server, which can contain hundreds or thousands of ports, each used for a different communication purpose to that device or server.
When it comes to the wider Internet, effective communication begins when each device has a public IP address provided by an Internet Service Provider. But what about an address like http://www.google.com? How does your computer know what IP address it's mapped to? When we wish to connect to Google's main page, we do not type in the IP Address, we type in its URL.
internet 如何工作
翻譯:這里介紹了IP地址的工作原理,其中IP地址類似電話號碼,端口號同一個電話號碼中不同的用途方式。
DNS
This mapping from URL to IP address is handled by the Domain Name System or DNS. DNS is a distributed database which translates domain names like www.google.com to an IP address, so that the IP address can then be used to make a request to the server. Stated differently, it keeps track of domain names and their corresponding IP addresses on the Internet. So an address like www.google.com might be resolved to an IP address 197.251.230.45.
By the way, you can also get to Google's main page by typing the IP address into your browser's address bar. However, most people want to use a user-friendly address like www.google.com, instead of memorizing a number of digits. DNS databases are stored on computers called DNS servers. It is important to know that there is a very large world-wide network of hierarchically organized DNS servers, and no single DNS server contains the complete database. If a DNS server does not contain a requested domain name, the DNS server routes the request to another DNS server up the hierarchy. Eventually, the address will be found in the DNS database on a particular DNS server, and the corresponding IP address will be used to receive the request.
Your typical interaction with the Internet starts with a web browser when you:
Enter a URL like http://www.google.com into your web browser's address bar.
The browser creates an HTTP request, which is packaged up and sent to your device's network interface.
If your device already has a record of the IP address for the domain name in its DNS cache, it will use this cached address. If the IP address isn't cached, a DNS request will be made to the Domain Name System to obtain the IP address for the domain.
The packaged-up HTTP request then goes over the Internet where it is directed to the server with the matching IP address.
The remote server accepts the request and sends a response over the Internet back to your network interface which hands it to your browser.
Finally, the browser displays the response in the form of a web page.
The above set of steps is a simplification of what happens at a technical level. The main thing to understand though is that when your browser issues a request, it's simply sending some text to an IP address. Because the client (web browser) and the server (recipient of the request) have an agreement, or protocol, in the form of HTTP, the server can take apart the request, understand its components and send a response back to the web browser. The web browser will then process the response strings into content that you can understand. Navigating to websites like Facebook, Google and Twitter means you've been using HTTP all along. The details were hidden, but your browser was issuing the requests and processing the responses automatically. The different parts of the Internet look something like:
翻譯:
這里介紹了DNS的概念,DNS 是一個分布式的數據庫,做 域名 和 IP地址的互相翻譯。
這里介紹,DNS 其實是一堆服務器,通過不同的層級來控制規模。(感興趣的讀者可以了解下,一級域名、二級域名 等概念,)
當打開internet 瀏覽器,正常的處理邏輯如下:
1. 在瀏覽器鍵入一個url 。http://www.google.com
2. 瀏覽器創建一個HTTP請求,并封裝好后發到個人設備(比如手機)的網卡上。
3. 如果網卡已經緩存了這個域名(www.goolge.com)中的IP,他會直接使用緩存的地址。否則向域名系統獲取這個域名對應的地址。(譯者備注:dns 遞歸查詢)
4. 打包好的HTTP請求會直接向擁有這個地址的服務器發送。
5. 遠程的服務器接受了這個請求,并通過internet 返回一個包到你的個人設備(比如手機)的網卡上,網卡傳回給你的瀏覽器。
6. 最后瀏覽器已web 界面的方式展現了回復。
上面的步驟是從技術層層面一個簡單的描述。internet 不同的部分就如下圖一樣。
Clients and Servers
The most common client is an application you interact with on a daily basis called a Web Browser. Examples of web browsers include Internet Explorer, Firefox, Safari and Chrome, including mobile versions. Web browsers are responsible for issuing HTTP requests and processing the HTTP response in a user-friendly manner onto your screen. Web browsers aren't the only clients around, as there are many tools and applications that can also issue HTTP requests.
The content you're requesting is located on a remote computer called a server. Servers are nothing more than machines or devices capable of handling inbound requests, and their job is to issue a response back. Often, the response they send back contains relevant data as specified in the request.
最常見的客戶端就是Web 瀏覽器。瀏覽器主要用來做HTTP 請求,以及處理HTTP 請求,并投放到客戶端屏幕上,瀏覽器處理后,人可以看得更清楚。
你申請的文件 放在遠端的電腦上,這個電腦我們叫做服務器。服務器就是處理進來的請求,并返回一個答復。一般針對一個請求的數據都存放在回復中(response).
Resources
Resource is a generic term for things you interact with on the Internet via a URL. This includes images, videos, web pages and other files. Resources are not limited to files and web pages. Resources can also be in the form of software that lets you trade stock or play a video game. There is no limit to the number of resources available on the Internet.
翻譯:資源指的是通過url從 internet 申請的東西。包括圖片、視頻、web 界面及其它。
Statelessness
A protocol is said to be stateless when it's designed in such a way that each request/response pair is completely independent of the previous one. It is important to be aware of HTTP as a stateless protocol and the impact it has on server resources and ease of use. In the context of HTTP, it means that the server does not need to hang on to information, or state, between requests. As a result, when a request breaks en route to the server, no part of the system has to do any cleanup. Both these reasons make HTTP a resilient protocol, as well as a difficult protocol for building stateful applications. Since HTTP, the protocol of the internet, is inherently stateless that means web developers have to work hard to simulate a stateful experience in web applications.
When you go to Facebook, for example, and log in, you expect to see the internal Facebook page. That was one complete request/response cycle. You then click on the picture -- another request/response cycle -- but you do not expect to be logged out after that action. If HTTP is stateless, how did the application maintain state and remember that you already input your username and password? In fact, if HTTP is stateless, how does Facebook even know this request came from you, and how does it differentiate data from you vs. any other user? There are tricks web developers and frameworks employ to make it seem like the application is stateful, but those tricks are beyond the scope of this book. The key concept to remember is that even though you may feel the application is stateful, underneath the hood, the web is built on HTTP, a stateless protocol. It's what makes the web so resilient, distributed, and hard to control. It's also what makes it so difficult to secure and build on top of.
如果某協議每一個 request/response 和前一個request/response 完全是獨立的,這個協議被認為是無狀態的:非常重要需要了解HTTP是一個無狀態協議(敲黑板),HTTP 對服務器資源有影響,以及易用性的影響。
HTTP里面,服務器不需要在客戶端requests請求之間維持住信息、或者狀態。這樣的話,當客戶端一個請求沒有到達服務器,系統不需要做任何清理。
這些原因讓HTTP變成一個有彈性的協議,如果需要創建有狀態的應用,也是一個比較復雜的協議。(敲黑板,不是不能用http做有狀態的應用,只是比較復雜)
有一些技巧,讓框架開發者讓用戶看起來web 應用是有狀態的。
你需要記住的是,有狀態web應用的帽子底下,創建在HTTP 上,一個無狀態協議上。也是因為這點,web 業務非常的有彈性、分布式而且很難控制,另外也很難實現安全。
summary
This chapter covered an oversimplified interpretation of how the Internet works along with an explanation of a few key terms. You also learned about statelessness and how it impacts web applications. We'll take a closer look at what an address such as http://www.google.com is and what it's made up of in the next chapter.
翻譯:本章包含了一些基本的理解 inernet 怎么工作,你也了解到了無狀態 的含義,以及他對 web 應用的影響。
現在視頻業務越來越流行了,播放器也比較多,作為前端工程師如何打造一個屬于自己的播放器呢?最快最有效的方式是基于開源播放器深度定制,至于選擇哪個開源播放器仁者見仁智者見智,可以參考開源播放器列表(https://www.awesomes.cn/subject/videos)選擇適合自己業務的播放器。
我們的播放器選擇了排名第一的video.js播放器,截至目前該播放器在Github擁有13,991 star, 4,059 fork,流行程度可見一斑。為了讓大家更多的了解它,我們細數下優點:
免費開源
這個意味著什么就不多說了,附上項目地址(https://github.com/videojs/video.js)
兼容主流瀏覽器
在國內的前端開發環境往往需要支持到低級版本的IE瀏覽器,然后隨著Flash的退化,很多公司沒有配備Flash開發工程師,video.js提供了流暢的Flash播放器,而且在UI層面做到了和video的效果,實屬難得,比如全屏。
UI自定義
不管開源項目在UI方面做的如何漂亮,對于各具特色的業務來說都要自定義UI,一個方便簡單的自定義方式顯得格外重要,更何況它還自帶了編譯工具,只能用一個”贊“字形容。具體怎么實現的,這里先簡單描述下是使用JavaScript(es6)構建對象,通過Less編寫樣式規則,最后借助Grunt編譯。
靈活插件機制
video.js提供一個插件定義的接口,使插件開發簡單易行。而且社區論壇也提供了一些好用的插件供開發者使用。附插件列表
比較完善的文檔
完善的文檔對于一個穩定的開源項目是多么的重要,video.js提供了教程、API文檔、插件、示例、論壇等。官方地址
項目熱度
開源作者對項目的維護比較積極,提出的問題也能很快給予響應。開發者在使用過程中出現問題算是有一定保障。
書歸正傳,要想更自由的駕馭video.js,必然要了解內部原理。本文的宗旨就是通過核心代碼演示講解源碼運行機制,如果有興趣,不要離開,我們馬上開始了……
由于源碼量較大,很多同學不知道從何入手,我們先來說下它的組織結構。
其中control-bar,menu,popup,slider,tech,tracks,utils是目錄,其他是文件。video.js是個非常優秀的面向對象的典型,所有的UI都是通過JavaScript對象組織實現的。
video.js是個入口文件,看源碼可以從這個文件開始。
setup.js處理播放器的配置安裝即data-setup屬性。
poster-image.js處理播放器貼片。
plugins.js實現了插件機制。
player.js構造了播放器類也是video.js的核心。
modal-dialog.js處理彈層相關。
media-error.js定義了各種錯誤描述,如果想理解video.js對各語言的支持,這個文件是必看的,它是橋梁。
loading-spinner.js實現了播放器加載的標志,如果不喜歡默認加載圖標在這里修改吧。
fullscreen-api.js實現各個瀏覽器的全屏方案。
extend.js是對node 繼承 and babel's 繼承的整合。
event-target.js 是event類和原生事件的兼容處理。
error-display.js 主要處理展示錯誤的樣式設置。
component.js 是video.js框架中最重要的類,是所有類的基類,也是實現組件化的基石。
close-button.js 是對關閉按鈕的封裝,功能比較單一。
clickable-component.js 如果想實現一個支持點擊事件和鍵盤事件具備交互功能的組件可以繼承該類,它幫你做了細致的處理。
button.js 如果想實現一個按鈕了解下這個類是必要的。
big-play-button.js 這個按鈕是視頻還未播放時顯示的按鈕,官方將此按鈕放置在播放器左上角。
utils目錄顧名思義是一些常用的功能性類和函數。
tracks目錄處理的是音軌、字幕之類的功能。
tech目錄也是非常核心的類,包括對video封裝、flash的支持。
slider目錄主要是UI層面可拖動組件的實現,如進度條,音量條都是繼承的此類。
popup目錄包含了對彈層相關的類。
menu目錄包含了對菜單UI的實現。
control-bar目錄是非常核心的UI類的集合了,播放器下方的控制器都在此目錄中。
通過對組織結構的描述,大家可以,想了解video.js的哪一部分內容可以快速入手。如果還想更深入的了解如何正確使用這些類,請繼續閱讀繼承關系一節。
video.js是JavaScript面向對象實現很經典的案例,你一定會好奇在頁面上一個DOM節點加上data-setup屬性簡單配置就能生成一個復雜的播放器,然而在代碼中看不到對應的HTML”模板“。其實這都要歸功于”繼承“關系以及作者巧妙的構思。
在組織結構一節有提到,所有類的基類都是Component類,在基類中有個createEl方法這個就是JavaScript對象和DOM進行關聯的方法。在具體的類中也可以重寫該方法自定義DOM內容,然后父類和子類的DOM關系也因JavaScript對象的繼承關系被組織起來。
為了方便大家查閱video.js所有的繼承關系,整理了兩個圖表,一個是完整版,一個是核心版。
完整版
核心板
video.js源碼代碼量比較大,我們要了解它的運行機制,首先確定它的主線是video.js文件的videojs方法,videojs方法調用player.js的Player類,Player繼承component.js文件的Component類,最后播放器成功運行。
我們來看下videojs方法的代碼、Player的構造函數、Component的構造函數,通過對代碼的講解基本整個運行機制就有了基本的了解,注意里面用到的所有方法和其他類對象參照組織結構一節細細閱讀就可以掌握更多的運行細節。
videojs方法
Player的構造函數
Component的構造函數
這里通過主線把基本的流程演示一下,輪廓出來了,更多細節還請繼續閱讀。
一個完善和強大的框架都會繼承插件運行功能,給更多的開發者參與開發的機會進而實現框架功能的補充和延伸。我們來看下video.js的插件是如何運作的。
插件的定義
如果之前用過video.js插件的同學或者看過插件源碼,一定有看到有這句話videojs.plugin=pluginName
,我們來看下源碼:
不難看出,原理就是將插件(函數)掛載到Player對象的原型上,接下來看下是怎么執行的。
插件的運行
在Player的構造函數里判斷是否有插件這個配置,如果有則遍歷執行。
在繼承關系一節中有提到video.js的所有DOM生成都不是采用的傳統模板的方式,都是通過JavaScript對象的繼承關系來實現的。
在Component基類中有個createEl方法,在這里可以使用DOM類生成DOM實例。每個UI類都會有一個el屬性,會在實例化的時候自動生成,源代碼在Component的構造函數中:
每個UI類有一個children屬性,用于添加子類,子類有可能扔具有children屬性,以此類推,播放器的DOM結構就是通過這樣的JavaScript對象結構實現的。
在Player的構造函數里有一句代碼this.initChildren();
啟動了UI的實例化。這個方法是在Component基類中定義的,我們來看下:
通過這段代碼不難看出大概的意思是通過initChildren獲取children屬性,然后遍歷通過addChild將子類實例化,實例化的過程會自動重復上述過程從而達到了”繼承“的效果。不得不為作者的構思點贊。如果你要問并沒看到DOM是怎么關聯起來的,請繼續看addChild方法的源碼:
這段代碼的大意就是提取子類的名稱,然后獲取類并實例化,最后通過最關鍵的一句話this.contentEl().insertBefore(component.el(), refNode);完成了父類和子類的DOM關聯。相信inserBefore大家并不陌生吧,原生的DOM操作方法。
至此,video.js的精華部分都描述完了,不知道大家是否有收獲。這里簡單的總結一些閱讀video.js框架源碼的心得:
找準播放器實現的主線流程,方便我們有條理的閱讀代碼
了解框架代碼的組織結構,有的放矢的研究相關功能的代碼
理解類與類的繼承關系,方便自己構造插件或者修改源碼的時候知道從哪個類繼承
理解播放器的運行原理,有利于基于Component構造一個新類的實現
理解插件的運行機制,學會自己構造插件還是有必要的
理解UI的實現原理,就知道自己如何為播放器添加視覺層面的東西了
看看我的源碼解讀吧,能幫一點是一點,哈哈
*請認真填寫需求信息,我們會在24小時內與您取得聯系。