Giter Club home page Giter Club logo

Comments (50)

kailashanath avatar kailashanath commented on June 23, 2024 2

Tried to deploy music controls in ionic 1 using the side menu starter template.installed the plugin and added this code the controller, works on android devices and ios simulator, but nothing is happening on IOS device. I also included the controller.js file here

controllers.js.txt

` $cordovaMusicControls.create({
track : 'My Music', // optional, default : ''
artist : 'Live Stream',
cover : "",
isPlaying : false, // optional, default : true
dismissable : true, // optional, default : false
// hide previous/next/close buttons:
hasPrev : false, // show previous button, optional, default: true
hasNext : false, // show next button, optional, default: true
hasClose : true, // show close button, optional, default: false
}, onSuccess, onFailure);

function events(action) {
  console.log(action);
  switch(action) {
    case 'music-controls-pause':
    $cordovaMusicControls.updateIsPlaying(false);
      console.log("pausing it");
    break;
    case 'music-controls-play':
      console.log("playing it");
      $cordovaMusicControls.updateIsPlaying(true);
    break;
    case 'music-controls-destroy':
      break;
    // Headset events (Android only)
    // Do something
      break;
    case 'music-controls-headset-plugged':
    // Do something
      break;
    default:
      break;
  }
}


// Register callback
$cordovaMusicControls.subscribe().subscribe(events);

// Start listening for events
// The plugin will run the events function each time an event is fired
$cordovaMusicControls.listen();
$cordovaMusicControls.updateIsPlaying(false);`

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024 2

@0505gonzalez Thank you for your example. Your project work on my computer.
As a result I worked some time to find out what is the difference and why it is not working.

It seems the plugin cordova-plugin-background-mode is the reason it does not work.
I had it on my project but it is not in yours.

If you just add this plugin to your project and rebuild, you will see it does not work anymore on your example. It is maybe some kind of conflict or anything.

Tell me if you can not reproduce this

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024 1

I'm using https://ionicframework.com/docs/v2/native/mediaplugin/ to play the audio, in my case a timeout is not required. This plugin does not override the data displayed in controls

from cordova-music-controls-plugin.

Mushaqdeen-J avatar Mushaqdeen-J commented on June 23, 2024 1

Hi I am using Phonegap, this plugin works in Android but not working on iPhone or iPad. Is there anything additional plugin I have to install to make works in iOS and iPad. Please help me.

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024 1

Sorry guys been pretty busy, I'll give this a try soon.

from cordova-music-controls-plugin.

aliendb avatar aliendb commented on June 23, 2024 1

As you mentioned in comment earlier @soramister (testing example from @0505gonzalez), this plugin works if background audio plugin is not used. I used a different background plugin, a simple implementation, with same results.

In the background plugin try removing the AVAudio​Session​Category​Option​Mix​With​Others option. This worked for me. Not sure if it will for all iOS versions or plugin combinations.

Example code: https://github.com/aliendb/iosbgaudio/blob/master/BackgroundAudio.m

from cordova-music-controls-plugin.

aliendb avatar aliendb commented on June 23, 2024 1

@soramister -
I did some checking and saw that in the plugin.xml from the plugin you are using, (katzer/cordova-plugin-background-mode), there is no onload set with ios-package, so I added in an onload and saw that it worked to help with the background audio playing while the app is running in the background.

Changed from:

<feature name="BackgroundMode"> <param name="ios-package" value="APPBackgroundMode" /> </feature>

and modified it to

<feature name="BackgroundMode"> <param name="ios-package" value="APPBackgroundMode" onload="true" /> <param name="onload" value="true" /> </feature>

To confirm also, this was done along with removing the AVAudio​Session​Category​Option​Mix​With​Others option in APPBackgroundMode.m so that cordova-music-controls-plugin can work with the background plugin.
from
[session setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:NULL];
to
[session setCategory:AVAudioSessionCategoryPlayback error:NULL];


from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

Hey guys, seems like the npm repository (which cordova and ionic cli tools use to install plugins) is not yet updated. I've asked @homerours to release the latest.

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

@GerardoLSJ Seems you got it working on emulator, make sure you start playing audio, this will switch music controls context over to your app. Let me know iOS version on your device and I will take a look as well.

from cordova-music-controls-plugin.

kailashanath avatar kailashanath commented on June 23, 2024

@0505gonzalez Thanks for the fast response, I have checked it on the devices running IOS 9.3.2 and 10.2 and both of them are not showing any music controls

from cordova-music-controls-plugin.

GerardoLSJ avatar GerardoLSJ commented on June 23, 2024
               my_media.play();

		MusicControls.create(notificationData, function(success){
			console.log('SUCCESS SHOW: '+success);
		},function(error){
			console.log('ERROR SHOW: '+error);
		});

}`

I know there is sound before the MusicControl.Create(), but I'm not sure if this is the best aproximation, the emulator is running 10.1, my device is running 10.0.2

I try using a setTimeout() in case there was a delay of the "media.play()" but nothing happen

from cordova-music-controls-plugin.

GerardoLSJ avatar GerardoLSJ commented on June 23, 2024

I update my template: https://github.com/GerardoLSJ/cordova-download-template-to-private-directory

I was getting the audio from an interal location with the plugin Media.

I change to an html5 audio tag

var audio = document.getElementById("myAudio"); audio.play();

And It seems to work
img_0140

from cordova-music-controls-plugin.

kailashanath avatar kailashanath commented on June 23, 2024

@GerardoLSJ are you able to change the title in the music control? As far as i know, this music control is automatically generated from the html 5 audio element, that is why there is no title and the url is showing. It is not created by the music control plugin.

from cordova-music-controls-plugin.

GerardoLSJ avatar GerardoLSJ commented on June 23, 2024

On the init it appears the title and album that I give it, after I push pause appears the URL, I'm going to try to modify this.
I have to give it a little "SetTimeout" (800ms) I think it override the information from the HTML5 tag or something, once I click something it returns to the normal "url"

img_0141
img_0143

from cordova-music-controls-plugin.

re2005 avatar re2005 commented on June 23, 2024

@GerardoLSJ thanks for the plugin.

I'm experiencing the same issue you have described above.

And it works on iOS simulator but unfortunately not on my device.

I've tried add to the config.xml some parameters but still didn't work

<feature name="BackgroundAudio"> <param name="ios-package" value="BackgroundAudio" /> <param name="onload" value="true" /> </feature>

Cheers

from cordova-music-controls-plugin.

ghenry22 avatar ghenry22 commented on June 23, 2024

https://github.com/shi11/RemoteControls

this plugin still works well for music controls on iOS. It might serve as a good reference.

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

Any update on this issue?

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

@soramister @GerardoLSJ Do you guys have sample code I can try out? I'm not able to reproduce

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

I'd be glad to help if I can repro the problem

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

I created a repository with a blank application here:
https://github.com/soramister/TestMusicControls

It contains just a play/pause button. If you play the music on the simulator, the plugin works, but not in a real iOS device.

from cordova-music-controls-plugin.

GerardoLSJ avatar GerardoLSJ commented on June 23, 2024

https://github.com/GerardoLSJ/cordova-download-template-to-private-directory

This one is in Phonegap/Cordova plain, I download a song from the internet show up an "alert" and then once I push "Play" button in the simulator appears but in device dont'

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

Any updates?

from cordova-music-controls-plugin.

brainrepo avatar brainrepo commented on June 23, 2024

Thanks for the plugin! I am using it on ionic2 application but I have the same problem! In the simulator works well but not in device :(

from cordova-music-controls-plugin.

ramoncarreras avatar ramoncarreras commented on June 23, 2024

Yes, same problem here. Using ionic2 too.

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

@0505gonzalez Have you been able to reproduce the problem with the code I posted?

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

+1 help please

from cordova-music-controls-plugin.

erikpolder avatar erikpolder commented on June 23, 2024

+1 Works in simulator but not on device.

Device ios 10.2.1
Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.0
ios-deploy version: 1.9.1
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.9.5
Xcode version: Xcode 8.2.1 Build version 8C1002

Any further settings then Inter-App Audio and Background Modes required in Xcode that we are missing maybe?

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

@soramister do you have the background audio capability enabled on your project?

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

@soramister I tried your example and was able to reproduce. However, I haven't gotten to the bottom of the issue in your repo. I rebuilt the example from scratch and was able to get it working on a physical device properly. Here's an example. https://github.com/0505gonzalez/music-controls-example

Can someone try and let me know if it works for you? And @soramister let me know if you find out why your example does not work properly, I did not have much time to inspect carefully.

from cordova-music-controls-plugin.

erikpolder avatar erikpolder commented on June 23, 2024

Suddenly it start working for me as well. I did platform rm ios. Removed all plugins. Installed all plugins. Added the ios platform. Reinstalled my certificates from Apple. Updated the xcode project with the suggested settings as Xcode suggested. Enabled the Capabilities. After that running the app on device everything worked as it should. Before all this I tried the steps one by one without luck. Unfortunately I can not tell exactly what the problem was.

from cordova-music-controls-plugin.

ramoncarreras avatar ramoncarreras commented on June 23, 2024

Removed ios platform and all plugins. Re-installed ios platform and all plugins with no luck. I'm still facing same issue. Works in the simulator but not in a real device.

@epolder what capabilities did you enabled in xcode?

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

+1 no found..

from cordova-music-controls-plugin.

erikpolder avatar erikpolder commented on June 23, 2024

Inter-App Audio and Background Audio. I do not know i Background Audio is needed. I did also see in my provision profile that Inter Audio was enabled on my certificate att developer.apple.com

from cordova-music-controls-plugin.

0505gonzalez avatar 0505gonzalez commented on June 23, 2024

@ramoncarreras have you tried my example?

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

https://developer.apple.com/account/ios/identifier/bundle

captura de pantalla 2017-02-22 a las 12 01 11

testing..

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

no found :(

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

If I remove cordova-plugin-background-mode the problem is that the app closes when it blocks the cell

:(

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

help please

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

@0505gonzalez Did you have time to take a look at my previous message?
The fact the plugin is not working on iOS devices is really blocking for me...

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

@aliendb I tried your solution to remove the AVAudio​Session​Category​Option​Mix​With​Others option.
Unfortunately it does not work.

If you edit directly the official background audio plugin, can you reproduce your fix?

from cordova-music-controls-plugin.

gbelmm avatar gbelmm commented on June 23, 2024

@aliendb perfect solution !!!!!

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

@aliendb
THANK YOU!
Your solution is working.

Could you send your fix as a pull request to katzer/cordova-plugin-background-mode plugin? I can do it myself if you do not have time for it.

Thanks again!

from cordova-music-controls-plugin.

aliendb avatar aliendb commented on June 23, 2024

Thanks guys for confirming that the solution works.
@soramister as I'm not using katzer/cordova-plugin-background-mode plugin in my project at the moment, it will be great if you can make the pull request. thanks.

from cordova-music-controls-plugin.

soramister avatar soramister commented on June 23, 2024

I created the pull request here:
katzer/cordova-plugin-background-mode#274

from cordova-music-controls-plugin.

ghenry22 avatar ghenry22 commented on June 23, 2024

Actually there should be no need for an on-load, you just set the plugin as enabled in your app code once device ready fires.

Note that the background-mode plugin continuously loops a sound in the background at volume 0 in order to try and "look" like it is playing background audio to keep alive apps that do not really need background audio.

If you actually have an audio app then you don't need the plugin to do this as you will be playing real audio in the background. In it's default state the background-mode plugin breaks the play/pause button the remote controls as it is always playing so play/pause never toggles.

If you are actually running an audio app make the following changes:
in the APPBackgroundMode.m file, in the configureAudioPlayer method change number of loops to be 1 instead of -1. This means it plays it's one silent sound to kick everything off but then relies on your app to play real background audio from then on.

audioPlayer.numberOfLoops = 1

You should still do the audioSessionCategory change above as well but it's less relevant when you are no longer constantly looping audio.

from cordova-music-controls-plugin.

al404 avatar al404 commented on June 23, 2024

sorry but still getting the same issue and I'm not really sure what is the fix

I enable Inter-App Audio in my app

I use

MusicControls.create({
track : 'RPS',
artist : 'RPS',
cover : 'nocover.jpg',
isPlaying : true,
dismissable : true,
hasPrev : false,
hasNext : false,
hasClose : true,
album : 'RPS',
ticker : 'RPS'
});

MusicControls.subscribe(events);
MusicControls.listen();

when user hit PLAY

MusicControls.destroy();

when user hit PAUSE

i did not understand if i have to edit plugin files, right know it doesn't work in background

from cordova-music-controls-plugin.

fdambrosio avatar fdambrosio commented on June 23, 2024

I have same problem, I'm using Ionic3 and Videogular2.
I've activated Inter-App Audio but I see the music controls on Simulator, there's not in the IOS device

from cordova-music-controls-plugin.

tanvishah-syn avatar tanvishah-syn commented on June 23, 2024

Same here. I tried all the solutions mentioned above, however, am unable to get it working on iOS device. Works on android though. Am using ionic 3 and html5 audio player.

from cordova-music-controls-plugin.

tbergeron avatar tbergeron commented on June 23, 2024

Anyone found a solution yet?

from cordova-music-controls-plugin.

tbergeron avatar tbergeron commented on June 23, 2024

Is this working for anybody AT ALL?

from cordova-music-controls-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.