[TIMOB-25020] Android: requestThumbnailImagesAtTimes causes a crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-08-23T09:41:53.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.2.0 |
Components | n/a |
Labels | android, regression |
Reporter | Zakhar Zhuravlev |
Assignee | Yordan Banev |
Created | 2017-07-16T13:29:34.000+0000 |
Updated | 2018-02-12T16:39:27.000+0000 |
Description
*index.js:*
var button = Ti.UI.createButton({
title: "record"
});
button.addEventListener('click', recordVideo);
$.win.add(button);
$.win.open();
function recordVideo() {
var permissionsToRequest = [];
var audioPermission = "android.permission.RECORD_AUDIO";
var hasAudioPerm = Ti.Android.hasPermission(audioPermission);
if (!hasAudioPerm) {
permissionsToRequest.push(audioPermission);
}
var cameraPermission = "android.permission.CAMERA";
var hasCameraPerm = Ti.Android.hasPermission(cameraPermission);
if (!hasCameraPerm) {
permissionsToRequest.push(cameraPermission);
}
var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
var hasStoragePerm = Ti.Android.hasPermission(storagePermission);
if (!hasStoragePerm) {
permissionsToRequest.push(storagePermission);
}
if(permissionsToRequest.length > 0) {
Ti.Android.requestPermissions(permissionsToRequest, function (e) {
if (e.success) {
showCamera();
}
});
} else {
showCamera();
}
}
function showCamera() {
Ti.Media.showCamera({
autohide: false,
animated: false,
allowEditing: false,
success:function(event) {
var movie = Titanium.Media.createVideoPlayer({
url:event.media.nativePath,
backgroundColor:'#111',
mediaControlStyle: Titanium.Media.VIDEO_CONTROL_EMBEDDED,
scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
width:300,
height:300,
});
$.win.add(movie);
movie.addEventListener('durationavailable', function() {
movie.requestThumbnailImagesAtTimes([1], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function(response) {
Ti.API.info("Thumbnail callback called, success = " + response.success);
console.log(response);
if(response.success) {
}
});
});
},
cancel:function() {
console.log("cancel");
},
error:function(error) {
console.log("error");
console.log(error);
},
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
});
}
I'm getting this exception:
[WARN] W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference
[WARN] W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.init(TitaniumBlob.java:84)
[WARN] W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.<init>(TitaniumBlob.java:33)
[WARN] W/System.err: at ti.modules.titanium.media.VideoPlayerProxy.requestThumbnailImagesAtTimes(VideoPlayerProxy.java:722)
[WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[WARN] W/System.err: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872)
[WARN] W/System.err: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095)
[WARN] W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:360)
[WARN] W/System.err: at ti.modules.titanium.media.VideoPlayerProxy.handleMessage(VideoPlayerProxy.java:395)
[WARN] W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
[WARN] W/System.err: at android.os.Looper.loop(Looper.java:148)
[WARN] W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
PR: https://github.com/appcelerator/titanium_mobile/pull/9245
[~ybanev] Master is merged, waiting for 6_2_X back-port.
6_2_X: https://github.com/appcelerator/titanium_mobile/pull/9347
Verified fix in SDK Version: 6.2.0.v20170824074531 and SDK Version: 7.0.0.v20170823165814 Test and other information can be found at: Master: https://github.com/appcelerator/titanium_mobile/pull/9245 6_2_X: https://github.com/appcelerator/titanium_mobile/pull/9347
This bug has returned on SDK 7.0.1.GA. I'm receiving the same error when trying to create a thumbnail from a videoPlayer on android. It is working on iOS.
[~inzori] I am not able to reproduce the problem. Would be able to provide a code sample/project which does and information about the device you are using?
Hi,
Hi, this is the code in index.js: function doClick(e) { var auxVideoPlayer = Ti.Media.createVideoPlayer({ autoplay: false, url: 'http://ve-ep.ember.ltd/assets/media/qa/samplevideo-1280x720-5mb.mp4', height: 200, width: 300, scalingMode: Ti.Media.VIDEO_SCALING_RESIZE_ASPECT_FILL }); $.videoWrapper.add(auxVideoPlayer); auxVideoPlayer.requestThumbnailImagesAtTimes([0], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function (e) { console.log('requested video thumbnail'); console.log(e); if (e.success) { var image = Ti.UI.createImageView({ top: 0, height: 200, width: 300, image: e.image }); svView.add(image); } //auxVideoPlayer = null; //$.videoWrapper.removeAllChildren(); }); $.imageContainer.add(svView); } $.index.open(); Index.tss: ".container": { backgroundColor:"white", layout: 'vertical' } "Label": { width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", top: 10 } "#label": { font: { fontSize: 12 } } "#imageContainer": { top: 10, touchEnabled: false, } "#videoWrapper": { visible: true, top: 10, height: Ti.UI.SIZE, width: Ti.UI.SIZE } Index.xml
Sorry for the bad code sent. This is the correct index.js. Works on iOS but not android. function doClick(e) { var svView = Ti.UI.createView({ top: 0, height: 200, width: 300 }); var auxVideoPlayer = Ti.Media.createVideoPlayer({ autoplay: false, url: 'http://ve-ep.ember.ltd/assets/media/qa/samplevideo-1280x720-5mb.mp4', height: 200, width: 300, scalingMode: Ti.Media.VIDEO_SCALING_RESIZE_ASPECT_FILL }); $.videoWrapper.add(auxVideoPlayer); auxVideoPlayer.requestThumbnailImagesAtTimes([0], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function (e) { console.log('requested video thumbnail'); console.log(e); if (e.success) { var image = Ti.UI.createImageView({ top: 0, height: 200, width: 300, image: e.image }); svView.add(image); } //auxVideoPlayer = null; //$.videoWrapper.removeAllChildren(); }); $.imageContainer.add(svView); } $.index.open();
Thank you for the sample. I was able to reproduce the issue.