当我尝试从我的Android应用程序上传不同格式的视频(包括.mp4和.3gp文件)到facebook时,我在我的脸书帐户中收到通知,说“你的视频无法处理。请访问视频帮助页面了解常见问题'。请帮帮我。 postToWall功能将视频发布到Facebook。
private void postToWall(String accessToken) {
String dataPath = "/mnt/sdcard/DCIM/Camera/video-2013-04-11-04-30-05.mp4";
InputStream is = null;
byte[] data = null;
try {
is = new FileInputStream(dataPath);
data = readBytes(is);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
params.putString("filename", "Video_02.mp4");
params.putByteArray("video", data);
params.putString("contentType", "video/quicktime");
params.putString("message", "video message");
mAsyncRunner.request("me/videos", params, "POST", new PostRequestListener(), null);
}
public byte[] readBytes(InputStream inputStream) throws IOException {
// This dynamically extends to take the bytes you read.
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
// This is storage overwritten on each iteration with bytes.
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
// We need to know how may bytes were read to write them to the byteBuffer.
int len = 0;
while ((len = inputStream.read(buffer)) != -1) {
byteBuffer.write(buffer, 0, len);
}
// And then we can return your byte array.
return byteBuffer.toByteArray();
}
答案 0 :(得分:2)
这似乎是Facebook API或SDK的一个新的已知错误(今天的第一份报告)。
您可以在此处备份错误报告: http://developers.facebook.com/bugs/543903808965945