Retrieving recorded media (videos/photos)

时间:2018-03-25 19:48:54

标签: c# file-io xamarin.ios

I'm having trouble retrieving videos that I have recorded from my app on my iPhone.

The purpose of this is to upload this recorded video to Amazon Web Service's cloud (store it in a bucket).

However I seem to only be have directory access capabilities instead of the actual files. I don't know if this is a permissions issue or if there's a specific class that allows me to retrieve recorded videos.

This snippet of code saves the video:

var options = new PHAssetResourceCreationOptions {};
var changeRequest = PHAssetCreationRequest.CreationRequestForAsset ();
changeRequest.AddResource (PHAssetResourceType.Video, outputFileUrl, options);

The path from the outputFileUrl, which saves to the iPhone's temp folder, is how I was going about trying to retrieve the file to upload but to no success.

Can someone help me with this?

I have an toggle Record Event that gets the file like this:

// Start recording to a temporary file.
MovieFileOutput.StartRecordingToOutputFile (new NSUrl(GetTmpFilePath ("mov"), false), this);

This is the definition for GetTmpFilePath():

static string GetTmpFilePath (string extension)
{
    // Start recording to a temporary file.
    string outputFileName = NSProcessInfo.ProcessInfo.GloballyUniqueString;
    string tmpDir = Path.GetTempPath();
    string outputFilePath = Path.Combine (tmpDir, outputFileName);
    return Path.ChangeExtension (outputFilePath, extension);
}

outputFileUrl is a NSUrl and is the result of this, it is a parameter to the method that uses this in the "AddResource" above.

0 个答案:

没有答案