Problem loading video using media.selectVideo

Dear All,

media.selectVideo does not seem to be working for me on my iPhone 5 iOS 8.1.2. 

If I specify a filename, the video loads correctly, but EVENT.url cases the app to crash.

Please see code below.

Any thoughts?

Thanks!

John

[lua]

local widget = require( “widget” )

display.setStatusBar( display.HiddenStatusBar )

local XCTR =  display.contentCenterX

local YCTR =  display.contentCenterY

local WIDTH = display.contentWidth

local HEIGHT = display.contentHeight 

local VIDEO = native.newVideo( XCTR, YCTR, WIDTH /2, HEIGHT /2 )

local function PLAY_VIDEO (EVENT)

if EVENT.completed then

VIDEO:load( EVENT.url )

VIDEO:play()

    end

end

media.selectVideo( { listener=PLAY_VIDEO } )

[/lua]

Hi John,

I suggest that you follow the example in the documentation, using media.playVideo() after selecting a video. See here:

http://docs.coronalabs.com/api/library/media/selectVideo.html

Take care,

Brent

Thanks, Brent; but I do not want the video to play in a player – I want it to play on an object. Can you help me to do that? My code seems as if it should work (it works fine if I specify the URL by giving it a filename, but not if the URL is created by media.selectVideo – some kind of path conversion needed perhaps?)

best,

John

Hi John,

So you want to play a video from some remote URL? If so, please see the example under “Remote Video” that specifies “media.RemoteSource” as the target path for the video:

http://docs.coronalabs.com/api/library/native/newVideo.html

Best regards,

Brent

No, sorry, didn’t mean to imply a remote source. I am using media.selectVideo so that I can indetiify a file in the device’s library. Media.selectVideo returns a URL, or path, to the media file selected.

What I’d like to know is why, exactly, my code does not load a video; I can’t see any error in my logic based on the documentation.

Thanks,

John

Hi John,

I understand your usage case now, so I did some testing on my side. As it turns out, you need to specify the selected video as a “RemoteSource” even though it’s technically on the device, not on a server. So, in your load call, just do this:

[lua]

VIDEO:load( event.url, media.RemoteSource )

[/lua]

That should work fine for you… at least it did for me on iOS (but I did not test on Android).

Take care,

Brent

Hi John,

I suggest that you follow the example in the documentation, using media.playVideo() after selecting a video. See here:

http://docs.coronalabs.com/api/library/media/selectVideo.html

Take care,

Brent

Thanks, Brent; but I do not want the video to play in a player – I want it to play on an object. Can you help me to do that? My code seems as if it should work (it works fine if I specify the URL by giving it a filename, but not if the URL is created by media.selectVideo – some kind of path conversion needed perhaps?)

best,

John

Hi John,

So you want to play a video from some remote URL? If so, please see the example under “Remote Video” that specifies “media.RemoteSource” as the target path for the video:

http://docs.coronalabs.com/api/library/native/newVideo.html

Best regards,

Brent

No, sorry, didn’t mean to imply a remote source. I am using media.selectVideo so that I can indetiify a file in the device’s library. Media.selectVideo returns a URL, or path, to the media file selected.

What I’d like to know is why, exactly, my code does not load a video; I can’t see any error in my logic based on the documentation.

Thanks,

John

Hi John,

I understand your usage case now, so I did some testing on my side. As it turns out, you need to specify the selected video as a “RemoteSource” even though it’s technically on the device, not on a server. So, in your load call, just do this:

[lua]

VIDEO:load( event.url, media.RemoteSource )

[/lua]

That should work fine for you… at least it did for me on iOS (but I did not test on Android).

Take care,

Brent

@bjsorrentino , @jannone
Can we copy That selected video to DocumentsDirectory ?
If Yes, then How ?
I already tried @Scott_Harrison 's docPicker plugin but it can not copy file from event.url.

Can any one has solution ?