But it looks like Apple Store isn’t to fond of it’s use.
Also, is there anyway to access music controls on the lock screen? The MusicControls plugin looks like it does it but only for Android and Windows, doesn’t look like there’s an iOS counterpart.
Here’s my code:
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { MediaPlugin } from 'ionic-native';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
radio: MediaPlugin;
playing: boolean;
constructor(public navCtrl: NavController, platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.radio = new MediaPlugin("http://relay.publicdomainproject.org/classical.aac.m3u");
});
}
radioPlay() {
this.radio.play();
this.playing = true;
}
radioPause() {
this.radio.pause();
this.playing = false;
}
}
I just completed an app and ran into the same problem, here is how I solved it.
To allow the audio to play in the background you to do two things. First, you need to set the background mode - audio to on within the Xcode capabilities. Second, you need your AppDelegate.m file in the platforms - classes folder to look like this.
Okay, got it to work sort of… is there a hook for the pause/play button?
My constructor looks like this:
platform.ready().then(() => {
this.radio = new MediaPlugin("http://relay.publicdomainproject.org/classical.aac.m3u");
this.radio.init.then(() => {
console.log('Playback Finished');
}, (err) => {
console.log('somthing went wrong! error code: ' + err.code + ' message: ' + err.message);
});
let artist = "Daft Punk";
let title = "One More Time";
let album = "Discovery";
let image = "path_within_documents_storage OR url_starting_with_http_or_https";
let duration = 1;
let elapsedTime = 1;
let params = [artist, title, album, image, duration, elapsedTime];
window['remoteControls'].updateMetas((success)=>{
}, (fail)=>{
}, params);
});
But still not able to see the artist/title on the lock screen, it just shows up blank.
Ah, that was it. For reference, is there anyway to not show an image or does that value always have to be filled? I tried setting it as a null or “” and it ended up giving me the same issue
For Android, I only use OGG files because I think they give the best quality for the size. If they worked on Apple I would use them there also but they don’t.
I have added https://github.com/shi11/RemoteControls plugin, everything works great BUT not the progress bar, it’s not stop when is in Pause state. How can I make it stops when music paused?
Plus, if we click pause/play audio in app, the notification area buttons don’t update. It always is in Play mode.