2022 年使用 YouTube player sdk
on 2022-08-02
前言
距離上次使用 YouTube Player API 已經是 2014 年的事了
不知不覺也過了超久了
剛好最近公司有相關的需求需要在 App 中能夠播放 YouTube 的影片
原本想說 App 應該和我沒關係了
所以這次準備躺平(誤
結果還是被牽扯進來了…
2022 年當前如何使用 YouTube player SDK
沒想到不看還好, 一看就準備 GG
一開始把文件丟給 Android 和 iOS
Android 那邊說無法用
我當下????
文件都寫得好好的, 為何說無法用
和 Android 一起討論了一下, 才確認了一件事
原來 Android 為了統一 libary, 在 2018 年開始推行 Androidx 要取代 android.support
最大的改變是 namespace 的變動, 雖然官方有工具可以對第三方 lib 做轉換, 但也會是一個大換血, 而且對比較老舊的套件還會需要處理 activity 和 fragment 的處理, 因為現今大多的 Android 都以 fragment 實作 UI 了
所以 Android 開發表示兩手一攤
所以只能接下來用 iframe player 處理了
之後我這邊又再次和 iOS 確認了一下
因為依照文件說明 iOS 的 player 底層還是用 webview 封裝起來的, 所以應該沒問題才對
然後 iOS 很高興的表示, 既然 Android 都要用 webview 搞了, 那 iOS 也一起用吧
真的是很感謝 client 端幫我創造工作機會…
到了 2022 API 發生了許多變動
因為當年的 prototype code 還留著, 所以秒完成
但還是要看一下文件看看有什麼變動
一看下去才發現真的變動一卡車東西
也讚嘆 Google 真的是很認真在維護與更新文件
都有變動紀錄
主要是這幾年也因為在瀏覽器上因應對 video 的支援做蠻多播放邏輯的變動
部分是因為 YouTube 的服務策略做變動
以前 YouTube player 可以魔改到 YouTube 自己都認不出來(可以關掉超多顯示資訊, 完全客製化控制項)
現在已經無法了…
像是左上的影片標題, 右上的選單功能, 右下的 YouTube logo 現在都無法隱藏了…
還好現在播放一段時間後會自動隱藏這些資訊
串接 webview 特有的問題
有些問題是在 webview 上特有的問題
幾乎都是 Android 的問題
就 Android 的問題最多 XD
這裡記錄一下
- 處理自動播放的問題
礙於瀏覽器政策, 得是靜音才能自動播放, 或是要有使用者互動才能自動播放
我們採用的方式, 是靜音自動播放, 也避免使用者一開始被影片聲音嚇到
- Android 的播放器會因為滑動行為被判定長壓啟動選單
因為會是個 feed 列表呈現影片, 滑動到畫面內就會播放畫面中的影片
所以有遇到個問題是頁面在滑動時手指停留在播放器中會誤判長壓造成啟動播放器選單
解決方式還是老樣子在 webview 的 player 上面蓋一層透明遮罩, 自己客製控制 UI
- 在 Android 當影片在播放時使用 Youtube SDK API 取消靜音會有無法播放影片問題
這問題追了一下, 確認和 iframe player api 還有 JS 無關後, 就換個思路想會不會是 webview 有啥限制(因為在 browser 都正常)
下了幾個關鍵字丟給 Google 後查到 webview 有個 setMediaPlaybackRequiresUserGesture
的設定
webView.getSettings().setMediaPlaybackRequiresUserGesture(false)
設定成 false 的意思是在 webview 不用有任何互動就可以自動播放
想說會不會有關聯, 所以請 Android 開發那邊設定
結果就解決這問題了
Refer - Auto play video in webview
- 全螢幕的功能
iOS 的全螢幕會給系統的播放器
Android 的全螢幕功能會受限於 webview 的大小
所以這部分的差別也得注意
SEO - 增強 Youtube video SEO
on 2019-12-23
Intro
最近因為公司的需求開始研究這潭深水
剛好看到一篇文章介紹的還不錯
雖然已經是 2016 的文章
但它寫的一些觀點我覺得現在還是適用
雖然這文章有在業配服務 XD
稍微整理記錄一下
英文的片段都是原文
中文會是我的總結
就當作一個紀錄吧
Video Information
Video Content
- 以解決需求為優先
- 產品介紹
- 教程
- 知識分享
Video Length
While aggregated clicks are still counted, the amount of engagement on your videos play a huge role like the likes, dislikes, comments, watch time, shares, views on other sites, engagement on other sites. This required YouTubers to create better videos with more engaging content in order to rank higher.
- 點擊
- like
- dislike
- 評論
- 觀看時間
- 分享到其他地方(影片的擴散)
Make your videos at least at least 2 minutes in length; it’ll be really good if it’s 10 but don’t compromise the quality for Watch Time. If your viewers are engaged in your video for a longer duration, your videos will rank better. But if you’re just stretching your videos for this, you won’t be able to keep a user on your video and they won’t rank well.
- 最少兩分鐘
- 十分鐘非常好
Video Name
- Select finished video file that you will upload. Rename the file Video Title.
- And then right click on the file and select “Get Info/Properties”.
- Then go to “Details”.
- Add some tags related to the content.
- Under “Title” or “Name & Extension”, name the file which includes your top 2 keywords.
- Write a short description of your video in “Comments”
先編輯好影片檔案 meta 在上傳
Description
- Make it at least 200 words.
- Use synonyms for your keywords.
- Don’t stuff keywords or you won’t rank.
- Write a different description for each video. Or it’ll go down as duplicated content.
- Write out the video transcript using some software.
Make Playlists
Customise Thumbnails
Take advantage of Social Media
Search engine optimisation (SEO) has 3 facets:
- On-page SEO– As in how your website is structured, image tags, keyword density, tags, etc.
- Off-page SEO– Other domains that link back to your website.
- Relevance– As in how many people found it helpful. This is measured by Social media engagement, like how many people liked it, shared it, etc. Make this process easier by syncing your YouTube account with your social media accounts, and post your videos on your profile and relevant pages.
Make Your Channel Page Pretty
YouTube sees a channel without a profile picture, header, description and links as spam. It is an additional ranking hack, adds a pop to your channel, and can show what your videos are about.
- Add links to all your social media accounts.
- Add a nice and relevant channel image and banner.
- Write a long description in the about section (include synonym keywords).
- Subscribe to similar channels.
Share Links
For beginners trying to understand SEO, stick with low competition/long tail keywords.
The hacks laid out above will rank any low competitive or long tail keyword. If you want to rank your video for added competitive terms you have to embed the HTML on other sites and build links to your video.
But make a few high-quality links steadily instead of spamming all at once. You can use link sources such as:
- Private blog networks (PBN)
- Other blogging sites like WordPress, Blogger, Tumblr
- Social bookmarks
- Guest posts
- Your own site
- Comment links on relevant places
- Pinterest pins
利用其他 social mdeia 或管道增強曝光
TAGS
Tags aren’t the most important, but they help a lot. They help YouTube and Google learn what your video is about. Targeted tags not only help you rank for your target keyword but get you to you show up more often as a related video in the sidebar area of YouTube. When someone’s watching a video with a similar tag as your video then you’re added to the sidebar.
下 tag 會幫助你顯示在其他相似 tag 的 video 旁邊的側邊欄
Types of Tags:
Tags are another important way to get ranking in youtube search, here are few tips to put tags in your video-
-
List Specific Tags first: These are one-word keywords that represent the topic at hand. If YouTube gives you pre-filled suggestions that are essentially what you want, then use those, but also use the same words in a generic way.
-
List Generic Tags: These are words like how-to, tutorial, and vlog. YouTube offers suggestions, so use them.
-
Also, Long-Tail Tags: These are multiple-word tags. You can just copy the title and use it as a tag, leaving out conjunctions and prepositions (such as “of,” “in,” “and,” etc.), because YouTube ignores these words.
-
Don’t miss the Misspellings: Derral misspells words on purpose because people search for these words. For eg. Some tags like these: “Ellen Show” and also “elen show” , “ellen degeneres” and “ellen degenrous”
先是重要的特殊專門的 tag
再來是一般的 tag
再來是長尾的 tag
最後加上一些容易拼錯的 tag
More Dos and Dont’s:
-
You can only use 500 characters in your tags.
-
Don’t use misleading tags as this process will end up working against you in the search algorithm.
-
YouTube uses the meta information to do a quick assessment of your video, then it ignores your meta data. However, when the meta data is updated, it can help you in search after a few weeks when YouTube inventories the data again.
-
If you use repetitive keywords across all your videos, they will have a higher likelihood of referring to each other in the suggested videos column on the right of the page. Setting default tags from settings can make that process easier.
最後也附上原文
有興趣也可以去看一下
Refer - How To Rank Your YouTube Video On The First Page Of Google Search Results
Refer - How To Use YouTube Tags To Rank Higher In Search Results
補充
Call-To-Action
在影片中添加外部連結
已引導使用者去社群或者是產品連結等等
或者是引導到下一步或相關影片
8 Types of CTAs you Should Be Using in Your YouTube Channel
Tools
Tube Buddy or vidIQ
玩了一下
Tube Buddy 個人蠻喜歡的
它有個不錯的功能是會給建議的 tags
但是它應該是從 title 找出相關的 tag
測了一下還蠻實用的
行銷面
15 Inspiring YouTube Video Ideas to Build Your Brand
這篇文章說明了可以用哪些方式來建立你的品牌
可以針對要行銷的方式來決定影片用哪種方式拍攝
發現一個 Youtube 影片的搜尋結果很有趣
Google 會自動把內容擷取出來
有點類似 How to 的 video 結果