Resizing and Controlling media.playVideo()

You will be able to reference it outside of that function but not immediately, not until after the call back function happens.

Rob

Could you please explain to me how to do that?

local downloadedImage = nil

local function touchHandler( event )

      if event.phase == “moved” then

           if downloadedImage then

               downloadedImage.x = event.x

               – technically speaking, event.target would be better than downloadedImage

           end

      end

      return true

end

local function networkListener( event )

     …

     downloadedImage = event.target

     downloadedImage:addEventListener(“touch”, touchHandler)

     …

end

display.loadRemoteImage(…)

This is a basic example of where you can reference an object outside of the download function.

Rob

Is that Still not possible today? 

Yes, this is still true.

Rob

So what is the best way of displaying a video? A webview of youtube? I need users to be able to access movie trailers…

What is the best way to display a video?  Well that’s tough to answer.   Where is the video?  What format is it in?  Is it coming from a streaming service or do you have the entire video file?

Corona SDK’s built in video features are designed to work where you get a physical file.  That is, I can play a video from a web server if I’m getting a .mp4 file.  But if it’s a streaming service like YouTube, you don’t download a file you use a player to just stream data you will throw away when done.  Corona SDK doesn’t have facilities to access data from that kind of service.

You can look at the code in our Business App Sample ( where we get a list of YouTube videos and then play the video in a webView.

Rob

Thanks a lot for your quick answer, I will look in to that! 

I might just download the videos and host them myself…

One more problem: I do not understand why I get this error:“Attempt to index local ‘image’ (a nil value)”

local image = display.loadRemoteImage( “http://2.bp.blogspot.com/-LDaA7cP9MmA/Tddgg2e-HcI/AAAAAAAABoQ/xHH5Wau_V00/s1600/hello.png”, “GET”, networkListener, “helloCopy.png”, system.TemporaryDirectory, display.contentCenterX, display.contentCenterY)
image.x = -100 + image.x

Is there another way to move the image?

display.loadRemoteImage() doesn’t return a display object like the other API calls.  Instead it will call your “networkListener” function when the image finishes downloading.  At that point, the display object will be in “event.target” and you can move it inside the listener.  At the point you call display.loadRemoteImage() it returns immediately and image doesn’t exist at that point.

Rob

Is there any way to create a normal display object from the loaded image? Sorry if this is a stupid question, I am learning to use corona…

local image

local function networkListener( event )

     – you should of course test to make sure you really downloaded the image her, I’m not going to include that code.

     image = event.target

     image.x = -100 + image.x

end

display.loadRemoteImage( “http://2.bp.blogspot.com/-LDaA7cP9MmA/Tddgg2e-HcI/AAAAAAAABoQ/xHH5Wau_V00/s1600/hello.png”, “GET”, networkListener, “helloCopy.png”, system.TemporaryDirectory, display.contentCenterX, display.contentCenterY)

Yes but I still will not be able to acess the image out of the networkListenerfunction right?

You will be able to reference it outside of that function but not immediately, not until after the call back function happens.

Rob

Could you please explain to me how to do that?

local downloadedImage = nil

local function touchHandler( event )

      if event.phase == “moved” then

           if downloadedImage then

               downloadedImage.x = event.x

               – technically speaking, event.target would be better than downloadedImage

           end

      end

      return true

end

local function networkListener( event )

     …

     downloadedImage = event.target

     downloadedImage:addEventListener(“touch”, touchHandler)

     …

end

display.loadRemoteImage(…)

This is a basic example of where you can reference an object outside of the download function.

Rob

Google is rejecting our Apps because we open the Youtube videos in a webview. They say we have to use the Youtube API. Here you have the complete message:

This is a notification that your application submission, has been
rejected. If this submission was an update to an existing app, the version
published prior to this update is still available on Google Play.

Please address the issue described below, then submit an update with your
changes.

REASON FOR REJECTION:Violation of the Prohibited Actions provision of the
Content Policy.

After a regular review, we have determined that your app enables
background playing of YouTube videos, which is a violation of the YouTube

API Terms of Service :

“Your API Client will not, and You will not encourage or create
functionality for Your users or other third parties to: (8) separate,
isolate, or modify the audio or video components of any YouTube
audiovisual content made available through the YouTube API;”

All submission rejections are tracked. Repeated rejections due to policy
violations will result in app suspension, at which point this app will
count as a strike against the good standing of your developer account and
no longer be available on Google Play.

This notification also serves as notice for other apps in your catalog.
You can avoid future submission rejections and/or app suspensions by
immediately ensuring that no other apps in your catalog are in violation
of (but not limited to) the above policy. Before publishing applications,
please ensure your apps’ compliance with the Developer Distribution
Agreement and Content Policy.

If you feel we have made this determination in error, you can visit this
Google Play Help Center article.

The Google Play Team

Does any of you know a workaround to show youtube videos inside an App? 

Hi there,

Havent used video in a while in an app and just wondering if anything has changed as regards playing video but it causes the user to leave the app because it plays on the devices native player. Is there any way around this? I want to play a small clip of video, the app will be on both iOs and Android and the video will be stored within the apps assets so it doesnt need to be pulled from a server or anything.

Whats the best solution?

Thanks

native.newVideo() allows you to set a width and height.  Have you tried that?  It may still suspend Android Apps though.

Rob

Google is rejecting our Apps because we open the Youtube videos in a webview. They say we have to use the Youtube API. Here you have the complete message:

This is a notification that your application submission, has been
rejected. If this submission was an update to an existing app, the version
published prior to this update is still available on Google Play.

Please address the issue described below, then submit an update with your
changes.

REASON FOR REJECTION:Violation of the Prohibited Actions provision of the
Content Policy.

After a regular review, we have determined that your app enables
background playing of YouTube videos, which is a violation of the YouTube

API Terms of Service :

“Your API Client will not, and You will not encourage or create
functionality for Your users or other third parties to: (8) separate,
isolate, or modify the audio or video components of any YouTube
audiovisual content made available through the YouTube API;”

All submission rejections are tracked. Repeated rejections due to policy
violations will result in app suspension, at which point this app will
count as a strike against the good standing of your developer account and
no longer be available on Google Play.

This notification also serves as notice for other apps in your catalog.
You can avoid future submission rejections and/or app suspensions by
immediately ensuring that no other apps in your catalog are in violation
of (but not limited to) the above policy. Before publishing applications,
please ensure your apps’ compliance with the Developer Distribution
Agreement and Content Policy.

If you feel we have made this determination in error, you can visit this
Google Play Help Center article.

The Google Play Team

Does any of you know a workaround to show youtube videos inside an App? 

it’s a shame there isn’t an in-app video player, because switching to a native player, or viewing youtube means that the user has left your app, and that is bad for app store stats, am i right?