Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7188] Android: Media module methods takeScreenshot and previewImage not implemented in 1.8.0.1

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-01-23T16:47:13.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2012-02, Release 2.0.0, Release 1.8.1
ComponentsAndroid
Labelsmodule_media, qe-testadded, regression
ReporterOpie Cyrus
AssigneeBill Dawson
Created2012-01-14T15:34:33.000+0000
Updated2012-02-01T12:18:54.000+0000

Description

Ti.Media.takeScreenshot and Ti.Media.previewImage are commented out inside MediaModule.java since 1.8.0.1. We need investigate why (if any reason) and re-enable these. Documentation should be updated with the addition of these methods.

Comments

  1. Bill Dawson 2012-01-18

    Test app

    This test app exercises both takeScreenshot and previewImage. Create a new Titanium app and replace its app.js contents with the following. When you click the button it will take a screenshot then call previewImage to show the saved screenshot image.
       Titanium.UI.setBackgroundColor('#000');
       var win = Titanium.UI.createWindow({  
           title:'Test',
           backgroundColor:'#000',
       	exitOnClose: true
       });
       
       win.add(Ti.UI.createLabel({
       	backgroundColor: "blue",
       	color: "yellow",
       	text: "Hello There",
       	textAlign: "center",
       	left: "10dp", right: "10dp", top: "5dp", height: "40dp"
       }));
       
       win.add(Ti.UI.createImageView({
       	height: "43dp", width: "46dp",
       	image: "KS_nav_ui.png", top: "100dp"
       }));
       
       var btn;
       win.add(btn = Ti.UI.createButton({
       	title: "Take screenshot",
       	bottom: "5dp", height: "40dp",
       	left: "50dp", right: "50dp"
       }));
       
       function previewCallback(args) {
       	Ti.API.info("previewImage success");
       }
       
       function previewError(e) {
       	alert("previewImage failure: " + e.message);
       	Ti.API.error(e.message);
       }
       
       function screenshotCallback(image) {
       	if (!image) {
       		alert("Eeks, takeScreenshot didn't return anything.");
       		return;
       	} else {
       		var blob = image.media;
       		if (!blob) {
       			alert("Eeks, there was no useful 'media' member of the passed result dictionary.");
       			return;
       		}
       		if (Ti.Platform.osname === "android") {
       			Ti.API.info("Got an image blob back from takeScreenshot.  Gonna store it and preview it.");
       			var tempdir = Ti.Filesystem.tempDirectory;
       			var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, "temp.png");
       			if (file.exists()) {
       				file.deleteFile();
       			}
       			file.write(blob);
       			Ti.Media.previewImage({
       				success: previewCallback,
       				error: previewError,
       				image: file.read()
       			});
       		} else {
       			alert("Call to takeScreenshot successful.  Got a blob back.");
       		}
       	}
       }
       
       btn.addEventListener("click", function() {
       	Ti.Media.takeScreenshot(screenshotCallback);
       });
       
       win.open();
       
  2. Bill Dawson 2012-01-18

    Pull request ready: https://github.com/appcelerator/titanium_mobile/pull/1208
  3. Eric Merriman 2012-01-19

    Verified fixed with SDK 1.9.0.v20120119134634 on Nexus S (2.3.6) and emulator 2.3.1
  4. Wilson Luu 2012-02-01

    updated labels

JSON Source