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

Android: requestThumbnailImagesAtTimes() does not work with remote content

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.3.0
    • Component/s: Android
    • Labels:
      None
    • Story Points:
      5
    • Sprint:
      2018 Sprint 06 SDK, 2018 Sprint 07 SDK, 2018 Sprint 08 SDK, 2018 Sprint 09 SDK

      Description

      Requesting a thumb from a video payer that has a remote video loaded results in a crash.

      Test case:

      var win = Ti.UI.createWindow({layout:'vertical'}),
          buttonCamera = Ti.UI.createButton({title: "Camera"}),
          buttonGallery = Ti.UI.createButton({title: "Gallery"}),
          buttonLocalURL = Ti.UI.createButton({title: "Local"}),
          buttonRemoteURL = Ti.UI.createButton({title: "Remote"}),
          buttonLayout = Ti.UI.createView({bottom: 20, layout:'horizontal'}),
          slider = Ti.UI.createSlider({top: 30, backgroundColor: 'gray', min: 0, max: 100, width: '100%', touchEnabled: false, enabled: false}),
          videoPlayer = Ti.Media.createVideoPlayer({top: 20, height:'30%', autoplay: false}),
          imageView = Ti.UI.createImageView({top: 20, height:'30%'}),
          updatingThumbnail = false;
       
      buttonLayout.add([buttonCamera, buttonGallery, buttonLocalURL, buttonRemoteURL]);
      win.add(videoPlayer);
      win.add(imageView);
      win.add(slider);
      win.add(buttonLayout);
      win.open();
       
      slider.addEventListener('change', function(e) {
          if (videoPlayer && e.value > 0 && !updatingThumbnail) {
              updatingThumbnail = true;
              videoPlayer.requestThumbnailImagesAtTimes([e.value], Ti.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, function(response) {
                  imageView.image = response.image;
                  updatingThumbnail = false;
              });
          }
      });
       
      videoPlayer.addEventListener('durationavailable', function() {
          enableGetThumbSlider();
      });
       
      buttonCamera.addEventListener('click', recordVideo);
       
      function recordVideo() {
          disableGetThumbSlider();
          var permissionsToRequest = [];
          var cameraPermission = "android.permission.CAMERA";
          var hasCameraPerm = Ti.Android.hasPermission(cameraPermission);
          if (!hasCameraPerm) {
              permissionsToRequest.push(cameraPermission);
          }
       
          var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
          var hasStoragePerm = Ti.Android.hasPermission(storagePermission);
          if (!hasStoragePerm) {
              permissionsToRequest.push(storagePermission);
          }
       
          if(permissionsToRequest.length > 0) {
              Ti.Android.requestPermissions(permissionsToRequest, function (e) {
                  if (e.success) {
                      showCamera();
                  }
              });
          } else {
              showCamera();
          }
      }
       
      function showCamera() {
          Ti.Media.showCamera({
              autohide: false,
              animated: false,
              allowEditing: false,
              success:function(event) {
                  videoPlayer.url = event.media.nativePath;
              },
              cancel:function() {
                  console.log("cancel");
              },
              error:function(error) {
                  console.log("error");
                  console.log(error);
              },
              mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
          });
      }
       
      buttonLocalURL.addEventListener("click", function() {
          disableGetThumbSlider();
          videoPlayer.url = 'BigBuckBunny_320x180.mp4';
      });
       
      buttonRemoteURL.addEventListener("click", function() {
          disableGetThumbSlider();
          videoPlayer.url = 'http://ve-ep.ember.ltd/assets/media/qa/samplevideo-1280x720-5mb.mp4';
      });
       
      buttonGallery.addEventListener("click", function() {
          disableGetThumbSlider();
          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) {
                  videoPlayer.url = e.intent.data;
              }
          });
      });
       
      function disableGetThumbSlider() {
          slider.touchEnabled = false;
          slider.enabled = false;
      }
       
      function enableGetThumbSlider() {
          slider.touchEnabled = true;
          slider.enabled = true;
      }
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ybanev Yordan Banev
                Reporter:
                ybanev Yordan Banev
                Reviewer:
                Gary Mathews
                Tester:
                Samir Mohammed
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-6172
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code