Reputation: 23
I'm trying to create a PhoneGap plugin tp play video using VideoView. But I'm getting the following error:
setContentView is undefined for the type new Runnable.
package com.phonegap.plugins.video;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import android.widget.VideoView;
public class VideoPlayer extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
if ("playVideo".equals(action)) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
VideoView videoHolder = new VideoView(cordova.getActivity().getApplicationContext());
setContentView(videoHolder);
videoHolder.setVideoURI(Uri.parse("file:///sdcard/Android/data/Bis/v2.mp4"));
videoHolder.requestFocus();
videoHolder.start();
callbackContext.success(); // Thread-safe.
}
});
return true;
}
return false;
}
Is there any change in the way SetContentView needs to be called?
Upvotes: 0
Views: 1101
Reputation: 157487
cordova.getActivity().setContentView()
. Since inside the Runnable
the this refers to the inner class Runnable
Upvotes: 2