Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateCallback error #129

Open
rowanvi opened this issue Jun 26, 2018 · 2 comments
Open

UpdateCallback error #129

rowanvi opened this issue Jun 26, 2018 · 2 comments

Comments

@rowanvi
Copy link

rowanvi commented Jun 26, 2018

Hi,

I'm creating an application using cordova vue JS together with VueX.
I installed this plugin and everything is working fine, however I was trying to add the play and pause function. In my code i do the following i my VueX storage.

` async createNativeAudioWidget({dispatch, state, commit}){
//Destory old one
MusicControls.destroy();

  //Create the widget
  MusicControls.create({
    track       : podcastInformation.title,    // optional, default : ''
    artist      : 'Fonodio',           // optional, default : ''
    cover       : podcastInformation.image,    // optional, default : nothing
    isPlaying   : true,             // 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  : false,   // show close button, optional, default: false

    // iOS only, optional
    album       : '',     // optional, default: ''
    // duration : podcastInformation.duration, // optional, default: 0
    duration : 0, // optional, default: 0
    elapsed : 0, // optional, default: 0
    hasSkipForward : false, //optional, default: false. true value overrides hasNext.
    hasSkipBackward : false, //optional, default: false. true value overrides hasPrev.
    skipForwardInterval : 15, //optional. default: 0.
    skipBackwardInterval : 15, //optional. default: 0.
    hasScrubbing : false, //optional. default to false. Enable scrubbing from control center progress bar 

    // Android only, optional
    // text displayed in the status bar when the notification (and the ticker) are updated
    ticker    : 'Now playing ' +  podcastInformation.title,
  });

  //Create events for listening
  MusicControls.subscribe(this.musicControlEvent);
  MusicControls.listen();
},
async musicControlEvent({dispatch, state}, action){
  const message = JSON.parse(action).message;
  switch(message) {
    case 'music-controls-pause':
      dispatch('pauseAudio');
      break;
    case 'music-controls-play':
      dispatch('playAudio');
      break;
    default:
      break;
    }
},`

I'm first destroying the old created musiccontrol, create a new one and after that i set the listener.
You also see my switch case which needs to be called when we press on the native button.

When i'm testing this code I'm getting the following error:
TypeError: musicControls.updateCallback is not a function. (In 'musicControls.updateCallback(messageFromNative)', 'musicControls.updateCallback' is undefined)

I hope someone can help me out!

@johnredeemed
Copy link

I also have this problem. Did you fix it?

@rowanvi
Copy link
Author

rowanvi commented Feb 5, 2019

I couldn't fix it in the time schedule I had for doing this job. I don't have any solution but I'm still intrested in how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants