Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24347] Android: Fix URI handling for TiThumbnailRetriever #8830

Merged
merged 3 commits into from
Mar 3, 2017

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Feb 10, 2017

  • Fix handling of external URIs in TiThumbnailRetriever
  • Resolve path before parsing in requestThumbnailImagesAtTimes()
  • Add getNativePath() into TitaniumBlob
TEST CASE
  • Download BigBuckBunny_320x180.mp4 and place into your project Resources folder
  • Also download on device (Downloads folder), so it appears in your Gallery
var win = Ti.UI.createWindow({
		title: 'TIMOB-24347',
		backgroundColor: 'white',
		layout: 'vertical'
	}),
	bar = Ti.UI.createView({
		backgroundColor: 'gray',
		height: Ti.UI.SIZE,
		layout: 'horizontal',
		bottom: '10dp'
	}),
	bar_intent = Ti.UI.createButton({
		title: 'INTENT',
		width: '50%'
	}),
	bar_url = Ti.UI.createButton({
		title: 'URL',
		width: '50%'
	}),
	vp = Ti.Media.createVideoPlayer({
		backgroundColor: 'black',
		width: '320dp',
		height: '180dp',
		bottom: '10dp',
		mediaControlStyle: Ti.Media.VIDEO_CONTROL_DEFAULT,
		scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT,
		autoplay: false
	}),
	img = Ti.UI.createImageView({
	    backgroundColor: 'gray',
	    width: '320dp',
		height: '180dp',
		bottom: '10dp'
	}),
	slider = Ti.UI.createSlider({
	    backgroundColor: 'gray',
		min: 0,
		max: 100,
		width: '100%',
		visible: false
	}),
	updatingThumbnail = false;

bar_intent.addEventListener("click", function() {
	var intent = Ti.Android.createIntent({
		action: Ti.Android.ACTION_PICK,
		type: "video/*"
	});
	intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
	win.getActivity().startActivityForResult(intent, function(e) {
	    if (e.intent != null) {
            vp.url = e.intent.data;
		}
	});
});

bar_url.addEventListener("click", function() {
	vp.url = 'BigBuckBunny_320x180.mp4';
});

vp.addEventListener("durationavailable", function(e) {
	slider.max = Math.floor(e.duration / 1000);
	slider.show();
});

slider.addEventListener('change', function(e) {
	if (vp && e.value > 0 && !updatingThumbnail) {
	    updatingThumbnail = true;
		vp.requestThumbnailImagesAtTimes([e.value], Ti.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function(response) {
			img.image = response.image;
			updatingThumbnail = false;
		});
	}
});

bar.add(bar_intent);
bar.add(bar_url);
win.add(bar);

win.add(vp);
win.add(img);
win.add(slider);

win.open();

JIRA Ticket

Copy link
Contributor

@antw12 antw12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Using the test case to verify code changes here are the findings:

  1. The import for TitaniumBlob didnt not automatically appear when pulling code from PR, please double check as i cannot find it in the PR
    relates to file:VideoPlayerProxy.java

however after testing with that change, i can confirm that it works

@antw12
Copy link
Contributor

antw12 commented Feb 28, 2017

URL is perfectly working although getting issues with the intent, when click on intent it says theres nothing on the device not sure why as it worked the last time i tested it

Copy link
Contributor

@antw12 antw12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intent does not work please look at comment for issue

@garymathews
Copy link
Contributor Author

@antw12 You may have deleted the video from your gallery, download any H.264 MP4 video and try?

Copy link
Contributor

@longton95 longton95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR passed.

Tested using the test case above and added the permissions for a 6.0+ devices, It now works as expected, spoke to @antw12 about his issue and it is working now.

ENV

SDK Version : Local 6.1.0
Mac OS Version : 10.12.3
Appc CLI : 6.1.0
Appc NPM : 4.2.9-1
Node : v4.6.0
Device: Nexus 5x(6.0.1) Pixel XL(7.1.1)
Emulator: (6.0), (4.4.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants