in facebook-android-wrapper/src/com/facebook/unity/FB.java [643:689]
public static void UploadVideoToMediaLibrary(String params_str) {
Log.v(TAG, "UploadVideoToMediaLibrary(" + params_str + ")");
UnityParams unityParams = UnityParams.parse(params_str);
String caption = unityParams.getString("caption");
Uri videoUri = Uri.parse(unityParams.getString("videoUri"));
// As a convenience, convert the URI to file:// if it has no Scheme.
// this is so that Unity code can pass just the path to the local
// file.
if (videoUri.getScheme() == null) {
videoUri = videoUri.buildUpon().scheme("file").build();
}
final UnityMessage unityMessage = new UnityMessage("OnUploadVideoToMediaLibraryComplete");
if (unityParams.hasString("callback_id")) {
unityMessage.put("callback_id", unityParams.getString("callback_id"));
}
GamingVideoUploader videoUploader = new GamingVideoUploader(getUnityActivity());
try {
videoUploader.uploadToMediaLibrary(
caption,
videoUri,
new GraphRequest.OnProgressCallback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
unityMessage.sendError(response.getError().toString());
} else {
String id = response.getJSONObject().optString("video_id", null);
if (id == null) {
unityMessage.sendError("Response did not contain ImageID");
} else {
unityMessage.put("video_id", id);
unityMessage.send();
}
}
}
@Override
public void onProgress(long current, long total) {
}
}
);
} catch (FileNotFoundException e) {
unityMessage.sendError(e.toString());
}
}