[TIMOB-25638] iOS: Callback of requestThumbnailImagesAtTimes is not fired
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Resolved |
| Resolution | Cannot Reproduce |
| Resolution Date | 2018-01-10T14:44:30.000+0000 |
| Affected Version/s | Release 7.0.0 |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | video |
| Reporter | Mohamad Alhajj |
| Assignee | Vijay Singh |
| Created | 2017-12-28T16:03:50.000+0000 |
| Updated | 2018-01-10T14:45:18.000+0000 |
Description
I'm trying to get video thumbnail using the below snippet code, but requestThumbnailImagesAtTimes doesn't call the callback at all on iOS, while it works on android.
requestThumbnailImagesAtTimes, is used on a local video, I tried bot to set the URL, or media but doesn't seem to work.
function openIOSVideoGallery() {
Titanium.Media.openPhotoGallery({
success: function (e) {
if (e.success && e.mediaType == Titanium.Media.MEDIA_TYPE_VIDEO)
getVideoThumbnail(e.media).then(function (success) {
//On Thumbnail Success
}).catch(function (error) {
//On Thumbnail Error
});
},
cancel: function (e) {
console.log(e);
},
error: function (e) {
console.log(e);
},
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO]
});
}
function getVideoThumbnail(video) {
return new Promise(function (resolve, reject) {
Titanium.Media.createVideoPlayer({
height: dpToPixel(100),
url: video.nativePath,
scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FILL,
width: dpToPixel(100)
}).requestThumbnailImagesAtTimes([0], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function (e) {
if (e.success) {
resolve({
thumbnail: e.image,
media: video
});
} else {
reject({
error: e.error,
media: video
});
}
});
});
}
[~malhajj] I think your attached test-case belongs to a different ticket? I moved it to TIMOB for further investigation.
Hi Hans, Yes your right you can remove the attached test case, since it belongs to another ticket. Thanks, Sent from JIRA Mobile
Example test-case:
Weirdly, it calls the callback as expected but then errors when trying to set an image to display the result. Probably [~vijaysingh] will know some more insights here!/** * This file is used to validate iOS test-cases. It is ran using the Xcode * project in titanium_mobile/iphone/iphone/Titanium.xcodeproj. * * Change the below code to fit your use-case. By default, it included a button * to trigger a log that is displayed in the Xcode console. */ var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var btn = Ti.UI.createButton({ title: 'Select Video + Generate Thumbnail' }); btn.addEventListener('click', selectVideo); win.add(btn); win.open(); function selectVideo() { Titanium.Media.openPhotoGallery({ success: function(e) { if (e.mediaType == Titanium.Media.MEDIA_TYPE_VIDEO) { getVideoThumbnail(e.media, function(_e) { if (e.error) { alert('Error: ' + e.error); } else { win.add(Ti.UI.createImageView({ image: e.thumbnail })); } }); } }, cancel: function(e) { console.log(e); }, error: function(e) { console.log(e); }, mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO] }); } function getVideoThumbnail(video, cb) { var player = Titanium.Media.createVideoPlayer({ height: 100, url: video.nativePath, scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FILL, width: 100 }) player.requestThumbnailImagesAtTimes([0], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function(e) { if (e.success) { cb({ thumbnail: e.image, media: video }); } else { cb({ error: e.error, media: video }); } }); }[~hknoechel] [~malhajj] The test case, which [~hknoechel] has attached, has a typo inside selectVideo() function. Rather e.thumbnail it should be _e.thumbnail. Please find the updated section inside selectVideo() function -
Now it will work fine. Let me know if you are facing any other issue. Thanks!getVideoThumbnail(e.media, function(_e) { if (_e.error) { alert('Error: ' + _e.error); } else { win.add(Ti.UI.createImageView({ image: _e.thumbnail })); } });Ohhh, of course, you are right! Holiday is still in my head. [~malhajj] Let us know your feedback!
[~vijaysingh] May this be a kroll-thread issue? [~malhajj] Please give us some feedback, thanks!
[~hknoechel] I have verified on kroll-thread also. Its working fine. Let's wait for [~malhajj]'s feedback.
[~malhajj] One more ping. We are not able to reproduce it and all test-cases pass. Please let us know by end of the day or we need to resolve it as
Cannot Reproducefor now. *EDIT*: Resolving asCannot Reproducedue to our test results and no activity.