Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-7623

iOS: VideoPlayer.requestThumbnailImagesAtTimes only calls callback once.

    Details

      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();
      

        Attachments

          Activity

            People

            • Assignee:
              vduggal Vishal Duggal (Inactive)
              Reporter:
              aevans Arthur Evans
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code