How to stream youtube video in corona.

I repeated the test using my video that I copied to system.DocumentsDirectory and it played. So I tried your video and it did not initially play on my iPhone 6 (iOS 9.1). But there was an error on the console log.

You’re accessing an http:// address. In iOS 9, Apple has locked down access to non-secure websites. Are you building for IOS and is your device running iOS 9 or later?

If so please read:  https://coronalabs.com/blog/2015/09/17/about-app-transport-security-ats/

Rob

great pointer! I tried:

NSAppTransportSecurity =              {                 NSExceptionDomains =                  {                        ["onestopdesktop.com/] =                      {                         NSIncludesSubdomains = true,                         NSExceptionRequiresForwardSecrecy = false,                     },                 }, },

and more specifically:

NSAppTransportSecurity =              {                 NSExceptionDomains =                  {                        ["onestopdesktop.com/images/DANGER.mov“] =                      {                         NSIncludesSubdomains = true,                         NSExceptionRequiresForwardSecrecy = false,                     },                 }, },

and finally, the not recommended one that actually worked:

{ NSAppTransportSecurity =          {             NSAllowsArbitraryLoads = true          }, },

did I do something wrong with the first two approaches?

in addition, I added this to try and access youtube videos which didn’t work. one forum participant said it worked for him:

LSApplicationQueriesSchemes =              { "youtube"                        },

thanks again!

The domain name should just be the domain name, no other parts of the URL, for instance

["onestopdesktop.com/] =

should be

["onestopdesktop.com] =

But as long as you’re working.

Rob

this indeed worked! thanks!

NSAppTransportSecurity =          {             NSExceptionDomains =             {                ["onestopdesktop.com"] =                {                   NSIncludesSubdomains = true,                   NSThirdPartyExceptionAllowsInsecureHTTPLoads = true                },             },          },

what about the youtube issue? should we be able to access those videos through the newVideo player?

Youtube does a streaming protocol that we do not support. We have to have a physical file to download. The only way to show youtube videos is to use a native.newWebView().

You can vote for the feature request here:

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5486487–plugin-support-streaming-video-i-e-from-an-ip

It doesn’t have a lot of votes (I’m surprised actually). So the more votes the better.

Rob

dropped my max votes there! thanks for your help in this matter, Rob!

it was truly frustrating to not be able to see any other videos but Corona’s no matter which approach or sample code I tried! yes, to answer your earlier question, I am on 9.1 on an iPhone6.

tried webView. so far so good. need to figure out how to tweak the view, but it does play them! 

this provided a perfect YouTube view of one of my favorite video series:

local webView = native.newWebView( display.contentCenterX, 230, 570, 480 )

webView:request( “https://www.youtube.com/watch?v=F8OtE60T8yU” )