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

        Activity

        Hide
        vduggal Vishal Duggal (Inactive) added a comment -

        Updating example to use correct duration

        Show
        vduggal Vishal Duggal (Inactive) added a comment - Updating example to use correct duration
        Hide
        monsieurfil Philippe Elsass added a comment -

        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.
        Show
        monsieurfil Philippe Elsass added a comment - 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.
        Hide
        monsieurfil Philippe Elsass added a comment - - edited

        Here's a patch, but changing the API slightly: all the thumbnails are returned as one event.

        https://gist.github.com/1917875

        Show
        monsieurfil Philippe Elsass added a comment - - edited Here's a patch, but changing the API slightly: all the thumbnails are returned as one event. https://gist.github.com/1917875
        Hide
        vduggal Vishal Duggal (Inactive) added a comment -

        Pull pending #1537.

        Show
        vduggal Vishal Duggal (Inactive) added a comment - Pull pending #1537.
        Hide
        blainhamon Blain Hamon added a comment -

        To test circular retain leakage, use the following:

        // 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
        //
        function newWindow(){
        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,
        });
         
        var closebtn = Ti.UI.createButton({bottom:50,width:200,height:50,title:'DONE'});
        closebtn.addEventListener('click',function(){vidWin.close()});
        //view.add(imgView);
        vidWin.add(scrollView);
        vidWin.add(closebtn);
        vidWin.open();
        }
         
        var win=Ti.UI.createWindow();
        var openButton = Ti.UI.createButton({width:200,height:50,title:'open'});
        openButton.addEventListener('click',newWindow);
        win.add(openButton);
        win.open();
        

        Show
        blainhamon Blain Hamon added a comment - To test circular retain leakage, use the following: // 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 // function newWindow(){ 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, });   var closebtn = Ti.UI.createButton({bottom:50,width:200,height:50,title:'DONE'}); closebtn.addEventListener('click',function(){vidWin.close()}); //view.add(imgView); vidWin.add(scrollView); vidWin.add(closebtn); vidWin.open(); }   var win=Ti.UI.createWindow(); var openButton = Ti.UI.createButton({width:200,height:50,title:'open'}); openButton.addEventListener('click',newWindow); win.add(openButton); win.open();
        Hide
        blainhamon Blain Hamon added a comment -

        Pull request #1537 approved.

        Show
        blainhamon Blain Hamon added a comment - Pull request #1537 approved.
        Hide
        wluu Wilson Luu added a comment -

        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)

        Show
        wluu Wilson Luu added a comment - 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)
        Hide
        amittal Anshu Mittal added a comment -

        Reopening to update labels

        Show
        amittal Anshu Mittal added a comment - Reopening to update labels

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development

                Poker Sessions

                This issue is currently not assigned to any Poker Session.

                  Git Source Code