Start a new topic

Synchronised videos stored in NSDocumentDirectory

Synchronised videos stored in NSDocumentDirectory


Hi Vincent,
You're welcome! THX for sharing your findings! 

Best regards,

Andreas

Hi Andreas,

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

Thank you again for your help.

Best regards,
Vincent

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

 

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

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

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 :

            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

            NSString *documentsDirectory = ;

            NSString *videoFileName = ;

            NSString *dataPath = ;

            

            NSData *dataVideo = ;

            if (dataVideo != nil) {

                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{

                    ;

                });

                

                videoContent.filename = videoFileName;

            }

 

I pass the URL to the JS with the callJavaScript method.

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

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?

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

 
Login or Signup to post a comment