[ 
https://issues.apache.org/jira/browse/CB-14103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16519265#comment-16519265
 ] 

Ken Naito commented on CB-14103:
--------------------------------

Where is mp3 file?
My mp3 file is www/res/jazz.mp3.
It looks like working.

I use 'silent' push.  i.e. 'content-available=1'.
The active (foreground) application plays mp3 when receiving the push 
notification.
Even if the device is locked, the application plays mp3 when receiving the push 
notification.

My environment is
{code}
Installed platforms:
  ios 4.5.4
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-push 2.2.3 "PushPlugin"
{code}
My node version is 9.5.0.
iOS version is 11.4.

The part of my codes is
{code}
push.on('notification', (data) => {
    var additionalData = data["additionalData"];
    playAudio();
    ...
};

var media = null;

function playAudio () {
  if (media != null) {
    alert("Busy !");
    return;
  }
  var successCallback = function () { console.log("success"); alert('success'); 
};
  var failureCallback = function () { console.log("failure"); alert('failure'); 
};
  var statusChange = function (statusCode) {
    if (statusCode == Media.MEDIA_STOPPED) {
      media.release();
      media = null;
    }
  };
  var mediaFile = "res/jazz_funk_01.mp3";
  media = new Media(mediaFile, successCallback, failureCallback, statusChange);
  media.play();
}

function stopAudio () {
  if (media != null) {
    media.stop();
  }
}
{code}


> Audio not playing when play() called from push notification on ios devices 
> with closed app
> ------------------------------------------------------------------------------------------
>
>                 Key: CB-14103
>                 URL: https://issues.apache.org/jira/browse/CB-14103
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-media
>    Affects Versions: [email protected]
>         Environment: cli packages: 
> (/Users/eugene/.npm-global/lib/node_modules)
>  
>     @ionic/cli-utils  : 1.19.2
>     ionic (Ionic CLI) : 3.20.0
>  
> global packages:
>  
>     cordova (Cordova CLI) : 8.0.0 
>  
> local packages:
>  
>     @ionic/app-scripts : 3.1.8
>     Cordova Platforms  : ios 4.5.4
>     Ionic Framework    : ionic-angular 3.9.2
>  
> System:
>  
>     Android SDK Tools : 26.1.1
>     ios-deploy        : 1.9.2 
>     Node              : v9.6.1
>     npm               : 5.8.0 
>     OS                : macOS High Sierra
>     Xcode             : Xcode 9.3 Build version 9E145 
>  
> Environment Variables:
>  
>     ANDROID_HOME : /Users/eugene/Library/Android/sdk
>            Reporter: Eugene Snihovsky
>            Priority: Major
>
> # When I call `media.play()` manually from app - audio play works.
>  # When I call `media.play()` from push notification (app is in background) - 
> audio play works.
>  # When I call `media.play()` from push notification (app is not in 
> background and device is not locked) - audio play not works and I receive 
> data in error callback `\{"message":"","code":4}` (see it in Xcode device 
> logs)
>  # When I call `media.play()` from push notification (app is not in 
> background and device is locked) - audio play not works and I receive data in 
> error callback `\{"message":"","code":4}` (see it in Xcode device logs)
> I use real device iPad with ios 10.3.3
>  
> cordova-plugin-media 5.0.2 with KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE = true
>  
> phonegap-plugin-push 2.2.2
>  
> cordova-plugin-background-mode from master (also try to enable background on 
> push notification receive before start audio)
>  
> Is there any chance to make it work?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to