Ich versuche, mit folgendem Code ein Video auf Facebook hochzuladen
public void uploadVideosFacebook(String videoPath)
{
byte[] data = null;
String dataMsg = "Your video description here.";
String dataName="Mobile.wmv";
Bundle param;
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(API);
InputStream is = null;
try {
is = new FileInputStream(videoPath);
data = readBytes(is);
param = new Bundle();
param.putString("message", dataMsg);
param.putString("filename", dataName);
param.putByteArray("video", data);
mAsyncRunner.request("me/videos", param, "POST", new fbRequestListener(), null);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
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();
}
public class fbRequestListener implements RequestListener {
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+response);
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
}
Aber ich erhalte folgende Fehlermeldung als Antwort {"error":{"type": "OAuthException", "message":"(#352) Video file format is not supported"}}
Kann mir jemand weiterhelfen? Vielen Dank im Voraus für Ihre Hilfe.