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

iOS: Ti.Media.switchCamera() fails to switch camera.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 5.4.0, Release 5.5.0
    • Fix Version/s: Release 6.0.0
    • Component/s: iOS
    • Environment:
    • Story Points:
      3
    • Sprint:
      2016 Sprint 20 SDK

      Description

      Titanium.Media.switchCamera() fails to load the front-facing camera.

      Steps to Reproduce:
      1.Run Code

      var win = Ti.UI.createWindow({
          layout: "vertical"
      });
      win.open();
       
      var button = Ti.UI.createButton({
          title: "Camera",
          top: 20,
          width: 200,
          height: 200
      });
       
      button.addEventListener("click", takePics);
       
      win.add(button);
       
      var view = Ti.UI.createView();
       
      var take = Ti.UI.createView({
       
          bottom: 20,
          backgroundColor: "white",
          width: 70,
          height: 70,
          borderRadius: 35
       
      });
       
      var switchCamera = Ti.UI.createButton({
       
          top: 30,
          title: "Switch",
          right: 30,
          backgroundColor: "red",
          width: 50,
          height: 50,
          borderRadius: 25
       
      });
       
      // Add to the parent view.
      view.add(take);
      view.add(switchCamera);
       
      function takePics() {
          Ti.Media.showCamera({
              success: function(e) {
                  Ti.API.info(e.media);
       
              },
              error: function(e) {
                  alert(e);
              },
              autohide: false,
              overlay: view,
              saveToPhotoGallery: true,
              mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
              showControls: false
          });
       
      }
       
      take.addEventListener('click', function(e) {
          Ti.Media.takePicture();
      });
       
      //var value = true;
      switchCamera.addEventListener('click', function() {
      	Ti.API.info("Switch camera!");
          if (Ti.Media.camera == Ti.Media.CAMERA_FRONT) {
              Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
          } else {
              Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
          }
      });
      

      2. Click 'Switch' button for test.

      Expected Result:

      The front (facing the user, showing their face on the screen) camera should load.

      Actual Result:

      The back camera loads only.

      Note: It works on 5.3.1.GA version.

      Thanks.

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              morahman Motiur Rahman
              Reviewer:
              Chee Kiat Ng (Inactive)
              Tester:
              Josh Longton
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code