Posted on by
NOTE: This tutorial is outdated and has been replaced by the Native UI guide. Please refer to this guide for details and usage examples.

Posted by . Thanks for reading...

35 Responses to “Using the New Native Web and Video API’s”

  1. nml

    It would be great if there is a way to view the videos using native.newVideo() in the simulator. Is there any? Will this be posible soon?

    thanks

    Reply
  2. Bryan Rieger

    Any chance we might see the option to turn webview bounces off when required?

    i.e.: [[webView.subviews objectAtIndex:0] setBounces:NO]; // ObjC

    Perhaps something more in-line with the existing native.WebPopUp?

    local options = { baseUrl=system.DocumentsDirectory, urlRequest=listener }
    local webView = native.newWebView( 0, 0, 320, 250, options )

    This would be really useful where you want the webview to act more like a scrollable view where upon reaching top/bottom/etc it would simply stop. It would also avoid having folks try to disable it using:

    document.ontouchmove = function(event){
    event.preventDefault();
    }

    …and other such less than ideal hacks.

    Reply
  3. Bryan Rieger

    heh, the ‘local options…’ above probably should have been something more like:

    local options = { baseUrl=system.DocumentsDirectory, urlRequest=listener, bounces=false }

    Reply
  4. Chris

    Now we can finally make more complex eBooks and even publish services like WoodWing does. :)

    Next thing should be to use native.newVideo to load the Camera (or just make native.newCamera), where we could finally put out own images in front of it (for Augmented Reality).

    Anyways, good job on that :)

    Reply
  5. FREDERIC

    will the newWebView will have –before the end of february– listener function options.urlRequest that will intercept all urlRequest events like the web popup ?

    For a project I need both : moving the webView AND intercept request … This would be great…

    Reply
  6. Jonathan Beebe

    @FREDERIC: You can specify a listener for WebViews and intercept the url via event.url (see the example in the post for information on using WebViews with a listener).

    Reply
  7. Perry

    I have a form in a webpopup/webview. Once I submit the form, can the submit button also simultaneously close the webpopup/webview?

    Thanks!

    Reply
    • Jonathan Beebe

      @Perry: You can have the submit button take you to a specific URL such as “corona:close”, and then you can detect that url (via event.url) in the webview’s listener function and then close the webView once it detects that URL. There is an example of this in the Web Popup samplecode, but you’d have to port the syntax to be compatible with WebViews of course.

      Reply
  8. Marc

    Thanks jonathan for the blog post.
    But will those articles ever have a home in the docs, like agreed by David (Cto)?

    Reply
  9. Mohammed

    Thanks Jonathan.

    Please can you explain how to implemnt a back button functionality?

    Reply
  10. Flavio

    Hi all,

    Great news!

    Just a simple question, any possible way to overlap a png during video playback. I’ve tried, but seems that video always stay at the top of display objects.

    Thanks.

    Reply
  11. Brent Sorrentino

    @Can
    Until a possible “onComplete” listener feature is added for newVideo(), perhaps just run a standard timer in conjunction with the video. You can even get the video’s overall time using the provided read-only parameter. The timer would, of course, need to be paused/restarted and skipped ahead if you performed these actions to the video, but this is fairly easy with the recently added (few months back) timer APIs “timer.pause” and “timer.resume”. It’s possible that the video and timer ending won’t mesh up to the exact millisecond, but it should be undiscernable to the user.

    I’m just excited that we can now use videos almost as “cutscenes” with text or other elements outside the video content area… even custom buttons and things to manage the video! OK, maybe not other display objects overlaying the video (haven’t actually tried this yet, maybe it IS possible?). Nonetheless, great work and many thanks Ansca!

    Brent Sorrentino
    Ignis Design

    Reply
  12. Dominic

    Are event listeners working with native.newVideo() ?

    I have tried adding one as the 5th parameter native.newVideo(x,y,w,h, listener) and also with addEventListener( “touch”, listener )

    Events don’t seem to be triggered and being device only hard to debug.

    I have tested the listener code by substituting native.newVideo, with display.NewRect( ) and the code works OK

    Reply
  13. Flavio

    Hi all,

    Me again, sorry about this, but I would like to know if there is any way to overlay other display objects on top of the video playback, for instance: buttons

    Thanks!

    Reply
  14. Dominic

    Can anyone confirm that this locks up the vide playback after playing the same clip 4 times??? even locks up the full screen video player too…

    Could be something in my code but never had the same issue using the fullscreen video player i.e.

    media.playVideo( name ,system.DocumentsDirectory, false, onComplete )

    if this is a known bug then let me know

    Reply
  15. nml

    @Dominic. Hello. I have the same problem, 4 clips and the fifth never plays. Hope someone knows how to solve it.

    Reply
  16. Tkfore21

    Right now, newWebView doesn’t work on devices. 90%-95% of the time it crashes my app. Hopefully they will get working on this as this API is being promoted as a feature.

    Reply
  17. derek

    I’ve seen this question a few times…any way to put a button over the video object?? Also, I’ve tried adding a video object to “scrollView” but doesn’t seem to work…is it possible to drag the video object?
    Thanks.

    Reply
  18. Bader

    Daily build # 736 includes new options for newVideo() function but no document yet :(

    We need new example of both newWebView() and newVideo() includes all option and metiods.

    Regards,
    Bader

    Reply
  19. derek

    Anybody have an idea how to add the phase listener to a video object? As Bader said, the new build says it supports it but no documentation. I assumed this:
    video:addEventListener( “video”, whatever)
    but doesn’t work.

    Reply
  20. Andrew

    According to the native.newVideo() documentation, it supports Android in addition to iOS. I just want to confirm if that is indeed true? I tried running some test on my Android phone, but it just shows a blank black screen. The same code runs on iOS.

    I have been having a hard time figuring out if the problem is that it’s not supported on Android, or incompatible video format on the Android.

    Thx!

    Reply
  21. Jay

    Any idea when this will work in the simulator? Is that high on your priority list? Thanks!

    Reply
  22. derek

    I’ve gotten the video listener to work but it only fires once. If i play a video and listen for the “ended” event, it works the first time, but when I play the video a second time the listener isn’t triggered. Is this a known issue?

    Reply
  23. Max

    what about native videocontrols (play, pause, back, forth) in native.newVideo? any chance to use them like in media.playVideo().

    Reply
  24. davey

    Is there an example of the webView listener stuff in action. Both the HTML/JS and the listener that does something in corona (like show an alert or something).

    @Jonathan Beebe mentions the syntax needs to change and I was just wondering if there was a full example like the one for webPopup. I have been tying to get it to do something and have so far not been able to get the new webview to listen for my form submits like I was able to do with webPopup.

    Reply
  25. Hitendra

    I developed app in 2012 when Adobe supportes flash for ice cream sandwich Android OS but now when Adobe stopped support for Android Jelly bean . My App would not run my game on samsung note 2 with jelly bean, is there any work around for this i tried both webpopups and webviews

    Reply

Leave a Reply

  • (Will Not Be Published)