1
當我嘗試從我的Android應用程序上傳不同格式(包括.mp4和.3gp文件)到Facebook的視頻時,我在我的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();
}
同樣的問題太多:http://stackoverflow.com/questions/15522857/sharing-video-on-facebook-fails我盯着認爲這是Facebook方面的一個錯誤。 – MonsieurDart 2013-03-20 21:32:09