My application is an Air app that uses the Starling engine and plays streamed videos.
As Starling doesn't support Video playback well, I decided to go the native way and written an ANE for video playback.
I launch a new Activity with a VideoView to display the videos and, on newer Androids (tested API level 19 and 18) when MediaController.show() is called, the app crashes. I have no useful stack trace, as the Android bit is compiled as native extension. On older devices (tested on API level 15 and 9) the MediaController works just fine.
I also tried to replace the MediaController with a play/pause ImageView, and again, it works fine on older devices, whereas on newer devices it plays once with the image shown, second time without showing the image (object is still created and child of layout) and the third time the app crashes altogether.
On newer devices, if I remove the ImageView the app doesn't crash, as well as if I leave the ImageView attached, and don't call the requestWindowFeature(Window.FEATURE_NO_TITLE).
This is the code that works on older devices (using MediaController):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this works proven with Android API Level 15 and lower. On Kitkat and 4.3 it blows up (18 and above)
if(Build.VERSION.SDK_INT <= 15)
requestWindowFeature(Window.FEATURE_NO_TITLE);
int resourceId = PlayVideoFunction.ctx.getResourceId("layout.main");
setContentView(resourceId);
Log.d("NativeExtension", "OnCreate " + this.toString());
Log.d("NativeExtension", "On Resume");
String url = getIntent().getStringExtra("url");
Log.d("NativeExtension", "url " + url);
int videoViewId = PlayVideoFunction.ctx.getResourceId("id.videoView");
videoView = (VideoView) findViewById(videoViewId);
videoView.setVideoURI(Uri.parse(url));
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
videoView.setOnPreparedListener(this);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
videoView.setMediaController(mediaController);
}
Has anyone had any similar issues related to native extensions? My guess is, that it has to do something with Window object in Android and Air/Starling. Apart from that, I'm lost.
EDIT: Posting the logcat here (too many characters to paste) http://pastebin.com/tnuEgWFA