native.newVideo on android

I heard that one of the latest daily builds added support for native.newVideo for Android. 

I created a simple program to test this. On my Nexus 7 the video plays fine. On my Evo 4G LTE the video does not play.  Anyone have any ideas?

Chris Rennie

 Here’s my code> 

url=“http://65.51.67.254:1935/mango_vod/mp4:GilliGiechi_1280.mp4/playlist.m3u8

mediaPlay=display.newText(“Media Play”, 30, 100, native.systemFont, 20)

videoPlay=display.newText(“Video Play”, 30, 200, native.systemFont, 20)

function mediaListener(e)

    function onComplete()

       end

    mediaPlay.text=“Media Playing?”

    media.playVideo(url, media.RemoteSource , true, onComplete)

end

function videoListener(e)

     videoPlay.text=“Video playing?”

     local video = native.newVideo( 0, 0, display.contentWidth, display.contentHeight )

local function videoL( event )

    print( "Event phase: " … event.phase )

   if event.errorCode then

        native.showAlert( “Error!”, event.errorMessage, { “OK” } )

    end

end

video:load( url, media.RemoteSource  )

video:addEventListener( “video”, videoL )

video:play()

end

mediaPlay:addEventListener(“tap”, mediaListener)

videoPlay:addEventListener(“tap”, videoListener)

The video you are trying to play is not one of the supported formats.  The list of supported formats are listed here: http://developer.android.com/guide/appendix/media-formats.html

Supported or not it plays on my Nexus 7 using the native.newVideo() api.  The video also plays fine on both devices when using media.playVideo() api .  Does media.playVideo() support more file formats than native.newVideo()?  

 My sample app tests both media.playVideo() and native.newVideo() api calls. 

 media.playVideo works on both my Nexus 7 and my EVO 4G LTE

 native.newVideo works on my Nexus 7 but not on my EVO 4G LTE

If you replace the url in your code with the sample code located in SampleCode/Media/NewVideo it will work.  I have just confirmed it on my nexus 7.

I confirmed the URL I had worked on the Nexus 7 so i’m not sure your post is that helpful

If it was a Android file format issue media.playVideo and native.newVideo would both reject the video. As I have stated;  media.playVideo() has absolutely no problem playing the above mentioned offending url and file format. I only have problems when I use native.newVideo()

The NewVideo sample code uses native.newVideo to play the video, which I have done.

I opened up the sample code and replaced the URL with the URL of the video I am trying to play.  Works great on my Nexus 7 but fails to load on my EVO 4G LTE.  One more reason to love the Nexus 7. Considering my app is aimed at tablets this shouldn’t be too big of an issue for us.  Besides the company that hired me really only wanted an Ipad app. It was through my use of Corona as a cross-plaform dev tool that I was able to convince them it wouldn’t be that much more work to release an Android version. 

Just an fyi for anyone having trouble somewhere around build 1229 or so using native newVideo() on Android, there appears to be a problem accessing the system.TemporaryDirectory to play videos (where you may be storing your downloaded videos / content).

The code I was using to play the downloaded video files worked on iOS, but not with native.newVideo on droid…

To get my downloaded vids to play from the temp directory on android, I used the following code

[lua]

    this.video = native.newVideo( this.PicRect.x, this.PicRect.y, this.PicRect.width, this.PicRect.height )
            
    print(" x,y == “, this.video.x, this.video.y)    
    print(” w,h == ", this.video.width, this.video.height)   
                                                     
–    this.video:load( fileName, system.TemporaryDirectory)                                 – This does NOT work on Droid as of build 1229

    this.video:load( system.pathForFile( fileName, system.TemporaryDirectory) )   – This plays the video just dandy on Droid

[/lua]

mpappas, thank you! I have been fighting against this problem for some hours until I have found your post.

The video you are trying to play is not one of the supported formats.  The list of supported formats are listed here: http://developer.android.com/guide/appendix/media-formats.html

Supported or not it plays on my Nexus 7 using the native.newVideo() api.  The video also plays fine on both devices when using media.playVideo() api .  Does media.playVideo() support more file formats than native.newVideo()?  

 My sample app tests both media.playVideo() and native.newVideo() api calls. 

 media.playVideo works on both my Nexus 7 and my EVO 4G LTE

 native.newVideo works on my Nexus 7 but not on my EVO 4G LTE

If you replace the url in your code with the sample code located in SampleCode/Media/NewVideo it will work.  I have just confirmed it on my nexus 7.

I confirmed the URL I had worked on the Nexus 7 so i’m not sure your post is that helpful

If it was a Android file format issue media.playVideo and native.newVideo would both reject the video. As I have stated;  media.playVideo() has absolutely no problem playing the above mentioned offending url and file format. I only have problems when I use native.newVideo()

The NewVideo sample code uses native.newVideo to play the video, which I have done.

I opened up the sample code and replaced the URL with the URL of the video I am trying to play.  Works great on my Nexus 7 but fails to load on my EVO 4G LTE.  One more reason to love the Nexus 7. Considering my app is aimed at tablets this shouldn’t be too big of an issue for us.  Besides the company that hired me really only wanted an Ipad app. It was through my use of Corona as a cross-plaform dev tool that I was able to convince them it wouldn’t be that much more work to release an Android version. 

Just an fyi for anyone having trouble somewhere around build 1229 or so using native newVideo() on Android, there appears to be a problem accessing the system.TemporaryDirectory to play videos (where you may be storing your downloaded videos / content).

The code I was using to play the downloaded video files worked on iOS, but not with native.newVideo on droid…

To get my downloaded vids to play from the temp directory on android, I used the following code

[lua]

    this.video = native.newVideo( this.PicRect.x, this.PicRect.y, this.PicRect.width, this.PicRect.height )
            
    print(" x,y == “, this.video.x, this.video.y)    
    print(” w,h == ", this.video.width, this.video.height)   
                                                     
–    this.video:load( fileName, system.TemporaryDirectory)                                 – This does NOT work on Droid as of build 1229

    this.video:load( system.pathForFile( fileName, system.TemporaryDirectory) )   – This plays the video just dandy on Droid

[/lua]

mpappas, thank you! I have been fighting against this problem for some hours until I have found your post.

This is still an issue with Build 2014.2189 (2014.3.6) … you need to send the full path, not {filename,baseDir}

This is still an issue with Build 2014.2189 (2014.3.6) … you need to send the full path, not {filename,baseDir}