Can't embed certain YouTube videos, iframe displays "the video contains content from WMG. it is restricted from playback on certain sites" -


i'm building instant youtube client in clojurescript , reagent, it's live @ http://instatube.net/ when try play music videos, displays error "the video contains content x. restricted playback on sites", yet same video plays fine on local server, iframe sends same referer , origin headers in both cases, works when embed video here https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default don't understand issue is, iframe reagent component

[:iframe {:class "embed-responsive-item"           :allow-full-screen "allowfullscreen"           :frame-border 0           :auto-play 1           :src (str "https://www.youtube.com/embed/" (if (nil? videoid)            "sw-bu6keeuw" videoid) "?autoplay=1&enablejsapi=1")}]] 

and ajax request i'm sending youtube search api v3 using cljs-ajax

(fn [term]   (ajax/get     "https://www.googleapis.com/youtube/v3/search"     {:params {:q term               :maxresults 5               :part "snippet"               :type "video,playlist"               :key youtube_api_key}     :handler handle-youtube-resonse     :response-format (ajax/json-response-format {:keywords? true})     :headers {:referer "https://www.youtube.com/"               :x-spf-referer "https://www.youtube.com/"})) 

related error encountered in so post.

certain videos have domain-level whitelist or blacklist applied them. done @ discretion of content owner.

if there whitelist or blacklist, , domain of embedding site can't determined (perhaps because of there not being real referring domain in case of native application), default behavior block playback.

this blog post has bit more detail well: http://youtube-eng.blogspot.co.uk/2011/12/understanding-playback-restrictions_28.html

another answer has point, if trying request blacklisted video app , not web page, error message below:

"this video contains content ___. restricted playback on sites." 

you incorrectly blacklisted. check this answer in post to fix this.

you need supply youtube api request origin.

in request header youtube video, set referer to domain in intend making call from, (for ex. domain of app's corresponding website). if don't have domain, write other domain, , might work too.

  • for android (java), can see example here.
  • for ios, look above
  • for react native, can use origin prop on component domain (origin mentioned in docs doesn't tell it).
  • here example of same issue in browser when extension blocked referer header being sent measure.

note:this answer works v3 api of youtube.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -