Comments (16)
I have the same issue here on iOS:
`
this.musicControls.subscribe().subscribe(action => {
function events(action) {
const message = JSON.parse(action).message;
switch(message) {
case 'music-controls-pause':
this.pause();
break;
case 'music-controls-play':
this.play();
break;
default:
break;
}
}
});
`
When the phone is locked and I click in pause
nothing happens, any thoughts?
from cordova-music-controls-plugin.
I solved it, it turns out I needed to add this lines after each event
MusicControls.updateIsPlaying(false/true); //toggles between play and pause
MusicControls.listen(); //continue to listen to events (only for one action/click until you call it again)
and you need to add this also after creation - MusicControls.listen();
It's working great for me..
from cordova-music-controls-plugin.
I already have the: MusicControls.listen(); but not working at all.
The cover, track, artist, ticker and all works fine, just the action of Pause (or Play) that I do not receive the callback in my actions to pause the song.
from cordova-music-controls-plugin.
@nadav12 can you post your code?
from cordova-music-controls-plugin.
here's a link I operated an angular function on each event
hope this helps
from cordova-music-controls-plugin.
Did you figured this out? I've done some big changes in the project and some the events are'nt called
from cordova-music-controls-plugin.
Not yet @nadav12
from cordova-music-controls-plugin.
I have the same problem, play/pause event does not work using Ionic Native Music Controls and this plugin. I'm testing it with 1.4.1 plugin version (2.0 doesn't show buttons on IOS) , Ionic3, XCode 9 and iOS Simulator with 10.3 & 11.0, and an iPhone real Device with iOS 11.0. Play/Pause control event isn't fired.
this.currentFile.play();
this.myControls.destroy();
this.myControls.create({
track : 'Example',
artist : 'Example A',
cover : '',
isPlaying : true,
dismissable : true,
hasPrev : false,
hasNext : false,
hasClose : true,
album : '',
duration : 0,
elapsed : 0,
ticker : 'Now playing "example"'
});
this.myControls.subscribe().subscribe(action => {
function events(action) {
const message = JSON.parse(action).message;
switch(message) {
case 'music-controls-next':
console.log('music-controls-next');
break;
case 'music-controls-previous':
// Do something
break;
case 'music-controls-pause':
console.log('music-controls-pause');
this.controlAudio('pause');
break;
case 'music-controls-play':
console.log('music-controls-play');
this.controlAudio('play');
break;
case 'music-controls-destroy':
// Do something
break;
// External controls (iOS only)
case 'music-controls-toggle-play-pause' :
console.log('music-controls-toggle-play-pause');
break;
case 'music-controls-seek-to':
// Do something
break;
case 'music-controls-skip-forward':
// Do something
break;
case 'music-controls-skip-backward':
// Do something
break;
case 'music-controls-media-button' :
// Do something
break;
case 'music-controls-headset-unplugged':
// Do something
break;
case 'music-controls-headset-plugged':
// Do something
break;
default:
break;
}
}
});
this.myControls.listen();
this.myControls.updateIsPlaying(true);
from cordova-music-controls-plugin.
Try this:
this.myControls.subscribe().subscribe(action => {
const message = JSON.parse(action).message;
switch(message) {
case 'music-controls-next':
console.log('music-controls-next');
break;
case 'music-controls-previous':
// Do something
break;
case 'music-controls-pause':
console.log('music-controls-pause');
this.controlAudio('pause');
break;
case 'music-controls-play':
console.log('music-controls-play');
this.controlAudio('play');
break;
case 'music-controls-destroy':
// Do something
break;
// External controls (iOS only)
case 'music-controls-toggle-play-pause' :
console.log('music-controls-toggle-play-pause');
break;
case 'music-controls-seek-to':
// Do something
break;
case 'music-controls-skip-forward':
// Do something
break;
case 'music-controls-skip-backward':
// Do something
break;
case 'music-controls-media-button' :
// Do something
break;
case 'music-controls-headset-unplugged':
// Do something
break;
case 'music-controls-headset-plugged':
// Do something
break;
default:
break;
}
});
from cordova-music-controls-plugin.
@edotassi thanks, using your code on Device iOS 11 and on Simulator iOS9.3 when I click pause/play I get only this error in XCode9's console:
Error in Success callbackId: MusicControls1369790364 : SyntaxError: JSON Parse error: Unexpected identifier "music"
from cordova-music-controls-plugin.
I’ve created a minimal ionic blank app from ionic starter, with Media stream (works) and Music Controls (not works), it’s available on github for testing :
https://github.com/fdambrosio/ionic-media-controls
from cordova-music-controls-plugin.
I've found the error in the Docs:
the string with the 'message' is the same 'action' parameter, so
if I write:
this.myControls.subscribe().subscribe(action => {
switch(action) {
.......
it works O_O
from cordova-music-controls-plugin.
I have to use 1.4.1 release, 2.x / 2.1.1 too is not working, play/pause event are not fired
from cordova-music-controls-plugin.
versions prior to 2.0.0 you need to use switch(action). Versions after 2.0.0 require you to parse.JSON first then switch.
I have submitted a PR to ionic native to update some errors in the documentation.
Version 2.1.4 (installed from the github repo as NPM is not currently updated) should work fine. I am using it with latest ionic-native with no issues. I don't use the play-pause-toggle. Just the play and pause events. My play and pause handlers in my app already deal with toggling anyway. I also never need to call the updateIsPlaying method personally.
from cordova-music-controls-plugin.
thanks @ghenry22 , I've tested 2.1.4 and it's working, but I need to do :
npm remove cordova-plugin-music-controls
npm install https://github.com/homerours/cordova-music-controls-plugin --save
ionic cordova plugin rm cordova-plugin-music-controls
ionic cordova plugin add https://github.com/homerours/cordova-music-controls-plugin
otherwise all buttons was not clickable
from cordova-music-controls-plugin.
Yeah, only @homerours currently has access to publish to NPM. @homerours, could you give access to publish to NPM to @ghenry22 and/or I?
from cordova-music-controls-plugin.
Related Issues (20)
- Not running HOT 3
- Music control external controls stop working
- updateIsPlaying won't work and ios controls continuously pops up as "playing" HOT 1
- Plugin didn't work on iOS 11.4 HOT 5
- Plugin is responding to headphones buttons but when i press the volume up and volume down button. It would only increase the device volume but doesn't fire an event HOT 6
- Ionic 4 cordova-plugin-music-controls breaks build HOT 14
- Ionic Webview 2.4.0 removes WKSuspendInBackground HOT 2
- Not being able to include in new projects HOT 1
- Build failed: Task :app:compileDebugJavaWithJavac FAILED HOT 15
- Run in Background HOT 13
- iOS - Invalid Callback ID HOT 8
- iOS does not work HOT 5
- Music controls don't work HOT 2
- Ionic - Issue installation
- The song is constantly stuck! Need help! HOT 2
- Plugin crashes on iOS 13 HOT 12
- Controls are not firing HOT 2
- musicControl.destroy doesnt close the control in IOS HOT 2
- Does not work on iOS; HOT 9
- User kill app, notification not. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-music-controls-plugin.