[TIMOB-7623] iOS: VideoPlayer.requestThumbnailImagesAtTimes only calls callback once.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-07-06T02:44:06.000+0000 |
Affected Version/s | Release 1.8.1 |
Fix Version/s | Sprint 2012-05, Release 2.0.0 |
Components | iOS |
Labels | module_media, parity, qe-testadded, release-note |
Reporter | Arthur Evans |
Assignee | Vishal Duggal |
Created | 2012-02-10T17:16:39.000+0000 |
Updated | 2012-07-09T11:54:11.000+0000 |
Description
The method is invoked like this:
myMovie.requestThumbnailImagesAtTimes(times, option, callback)
This method is supposed to provide a series of thumbnails. For each time offset in the "times" array, it's supposed to generate a thumbnail and invoke the callback. Looking at the code, it looks like the callback is being discarded after the first use.
Test case: the following code should retrieve multiple thumbnails, and display them in the scrollview at the bottom. But in practice, only the first thumbnail is retrieved.
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create base UI tab and root window
//
var vidWin = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff'
});
var activeMovie = Titanium.Media.createVideoPlayer({
top : 0,
backgroundColor: 'red',
height : 300,
width : 300,
borderRadius : 20,
borderWidth : 2,
borderColor : 'blue',
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_EMBEDDED,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL
});
if(Ti.Platform.name == 'iPhone OS') {
activeMovie.addEventListener('durationAvailable', function(evt) {
Ti.API.info("Requesting thumbnails now.");
var duration = activeMovie.duration/1000.0;
activeMovie.requestThumbnailImagesAtTimes([0, duration / 2, duration], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function(response) {
Ti.API.info("Thumbnail callback called, success = " + response.success);
if(response.success) {
var ratio = scrollView.size.height / response.image.height;
var imgView = Titanium.UI.createImageView({
width : (response.image.width * ratio),
height : (response.image.height * ratio),
image : response.image
});
scrollView.add(imgView);
}
});
});
}
//activeMovie.url = contentURL;
activeMovie.url = 'movie.mp4';
vidWin.add(activeMovie);
var scrollView = Ti.UI.createScrollView({
width : '100%',
height : '30%',
contentWidth : 'auto',
contentHeight : 'auto',
layout : 'horizontal',
scrollType : 'horizontal',
bottom : 0,
});
//view.add(imgView);
vidWin.add(scrollView);
vidWin.open();
Updating example to use correct duration
Additional bug: - the app crashes if the callback is omitted although the doc indicates the param is optional, - the VideoPlayer doesn't dispatch the 'thumbnail' event. Notes: - a breakpoint in the obj-c code at the beginning of 'handleThumbnailImageRequestFinishNotification' shows that all the frames are generated, but the callback is released upon first reception.
Here's a patch, but changing the API slightly: all the thumbnails are returned as one event. https://gist.github.com/1917875
Pull pending #1537.
To test circular retain leakage, use the following:
Pull request #1537 approved.
Closing bug. Verified fix on: SDK build: 2.0.0.v20120315170247 Titanium Studio, build: 2.0.0.201203142055 xcode: 4.2 Device: iphone 4s (5.0.1)
Reopening to update labels