[TIMOB-28246] Android: Ti.Media.previewImage() fails to display in-memory blobs as of 9.1.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Unresolved |
Affected Version/s | Release 9.1.0 |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | android, blob, media, preview, regression |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-11-19T03:28:18.000+0000 |
Updated | 2020-11-20T23:36:23.000+0000 |
Description
*Summary:*
The [Ti.Media.previewImage()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-previewImage) method fails to display in-memory blobs (ie: blobs not referencing a file) as of Titanium 9.1.0.
*Steps to reproduce:*
Build and run the below on Android.
Tap on the "Preview" button. (Will try to display screenshot of app.)
Notice it fails to display image.
var window = Ti.UI.createWindow();
var button = Ti.UI.createButton({ title: "Preview" });
button.addEventListener("click", function(e) {
window.toImage(function(imageBlob) {
if (!imageBlob) {
return;
}
Ti.Media.previewImage({
image: imageBlob,
success: function(e) {
Ti.API.info("@@@ Successfully displayed preview.");
},
error: function(e) {
Ti.API.error("@@@ Failed to display preview");
},
});
});
});
window.add(button);
window.open();
*Work-Around:*
Save the blob to file and preview the file instead.
var window = Ti.UI.createWindow();
var button = Ti.UI.createButton({ title: "Preview" });
button.addEventListener("click", function(e) {
window.toImage(function(imageBlob) {
if (!imageBlob) {
return;
}
// Write the blob to file.
var targetFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "image.png");
targetFile.write(imageBlob, false);
imageBlob = targetFile.read();
// Preview the above file.
Ti.Media.previewImage({
image: imageBlob,
success: function(e) {
Ti.API.info("@@@ Successfully displayed preview.");
},
error: function(e) {
Ti.API.error("@@@ Failed to display preview");
},
});
});
});
window.add(button);
window.open();
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12271
FR Passed
merged to master and 9_3_X for 9.3.0 target.
Fixed minor regression within
TiFileHelper
class'deployFromAssets()
anddeployFromZip()
methods. Note that nobody uses these methods. It is dead code... but "could" potentially be used in the future. PR (master): https://github.com/appcelerator/titanium_mobile/pull/12281