You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Raghav (JIRA)" <ji...@apache.org> on 2015/11/16 23:17:11 UTC

[jira] [Updated] (CB-9780) Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.

     [ https://issues.apache.org/jira/browse/CB-9780?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raghav updated CB-9780:
-----------------------
    Labels: Browser  (was: )

> Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.
> --------------------------------------------------------------------------------------------
>
>                 Key: CB-9780
>                 URL: https://issues.apache.org/jira/browse/CB-9780
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Browser, Plugin Camera
>            Reporter: Prathik S
>            Assignee: Tim Barham
>              Labels: Browser
>
> I am using the below code to click picture on click of a button i call handleMediaDialog() with options
> {code:javascript}
>         function optionsForType(type) {
>             var source;
>             switch (type) {
>                 case 0:
>                 source = Camera.PictureSourceType.CAMERA;
>                 break;
>                 case 1:
>                 source = Camera.PictureSourceType.PHOTOLIBRARY;
>                 break;
>             }
>             return {
>                 destinationType: Camera.DestinationType.FILE_URI,
>                 sourceType: source,
>                 allowEdit: false,
>                 encodingType: Camera.EncodingType.JPEG,
>                 popoverOptions: CameraPopoverOptions,
>                 saveToPhotoAlbum: false
>             };
>         }
>         function handleMediaDialog(type) {
>             return $q(function(resolve, reject) {
>                 var options = optionsForType(type);
>                 Camera.getPicture(options).then(function(imageUrl) {
>                     //convert url to where file is saved
>                     if (imageUrl.substring(0,21)=="content://com.android") {
>                         photo_split=imageUrl.split("%3A");
>                         imageUrl="content://media/external/images/media/"+photo_split[1];
>                     }
>                     // if image doesnt has extention like in case of whatsapp we add jpg
>                     var name = imageUrl.substr(imageUrl.lastIndexOf('/') + 1);
>                     if(name.indexOf('.') === -1) {
>                         name = name + ".jpg";
>                     }
>                     //convert content:// to file:///
>                     var newName = makeid() + name;
>                     $cordovaFileTransfer.download(imageUrl, cordova.file.dataDirectory + newName, {}, true).then(
>                         function(fileEntry) {
>                             //FileService.storeImage(fileEntry.nativeURL);
>                             resolve(fileEntry.nativeURL);
>                         }, function (error) {
>                             reject(error);
>                         }
>                     );
>                 });
>             })
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org