Synchronised videos stored in NSDocumentDirectory

Vincent

Vincent

said
over 2 years ago

Hello,

I use the lastest javascript iOS SDK of Wikitude and I have an issue to load videos that have been dowloaded and stored in the NSDocumentDirectory path (like /var/mobile/Containers/Data/Application/7F7BFD0E-5435-4D14-B86C-FC20CDC1ED83/Documents/video_w43.mp4). I create an Trackable2DObject with a VideoDrawable with this path. The event onEnterFieldOfVision is called when I scan the image but no video appears. I have no problems with videos stored in the bundle app like « asset/video ».

Thank you for your help,

Best regards, Vincent CALLEC bookBeo

A

Andreas Schacherbauer

said
over 2 years ago

Hi Vincent, How do you get the URL for the video? I guess you use some NSFileManager API, but which exactly? You might use something to get a file URL. After you retrieved the URL, how do you pass it over to JS?

Best regards,

Andreas

Edit: Did you implement the onError callback for the AR.VideoDrawable?

V

Vincent

said
over 2 years ago

Hi Andreas,

Thank you for your answer.

I get the URL through a REST API. I get the video informations with a JSON object. The video is downloaded is NSURLConnection and saved in that way :

I implemented the onError callback, this is the message I got : "Unknown URL Error (' AVFoundationErrorDomain--11800) - ('file:///var/mobile/Containers/Data/Application/xxx/Documents/video.mp4')')"

Sometimes it's works sometimes (rarely) it doesn't for the same video.

Best regards, Vincent

A

Andreas Schacherbauer

said
over 2 years ago

Hi Vincent, I did a quick google search for the error code and it seems that this is a generic 'something went wrong' error. Are you sure that the file is already written when you try to access it? They also mention to use NSURL instead of NSStrings for the path representation.

Best regards,

Andreas

V

Vincent

said
over 2 years ago

Hi,

Yes the file is written because the method "fileExistsAtPath" returns true.

I have tried to use NSURL instead of NSStrings for the path representation but the problem remains.

Best regards, Vincent

A

Andreas Schacherbauer

said
over 2 years ago

Hi Vencent, From the snippet you send earlier it looks like you don't update your internal logic once the write operation is done in the background. The call to videoContent.filename = videoFileName; does not wait for the write operation to be finished. It might be that there are other issues, but from what I know so far this the only potential code section that might cause problems. I'm not sure if `fileExistsAtPath` guarantees that the file is also readable. I also don't know where you call this method.

Best regards,

Andreas

V

Vincent

said
over 2 years ago

Hi Andreas,

I have found the issue, it was a problem during the download of several videos concurrently with NSURLConnection.