Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Error on iOS updatePlayback State #346

Open
2 of 4 tasks
leomiranda-tc opened this issue Sep 30, 2020 · 3 comments
Open
2 of 4 tasks

Error on iOS updatePlayback State #346

leomiranda-tc opened this issue Sep 30, 2020 · 3 comments

Comments

@leomiranda-tc
Copy link

Description

  1. Sample code (provide repo url or sample code)
    This command line only works on android.
MusicControl.updatePlayback({ state: MusicControl.STATE_PLAYING })
  1. Platform ?

    • iOS
    • Android
  1. Device
  • Simulator
  • Real device
@bradfloodx
Copy link
Collaborator

Hi @leomiranda-tc I'm using this in production and it does work. Can you elaborate? What version of react native? etc.

@leomiranda-tc
Copy link
Author

If you want, i can share my repository with you @bradleyflood.

But the details is bellow:

  • react-native: 0.63.2;
  • The lib is use to control react-native-video by the redux;

That's the code part:

import MusicControl from 'react-native-music-control';
import actionsVideo from '../store/actions/index';
import { useDispatch } from 'react-redux'
import {
  Platform,
} from 'react-native';

const MusicControls = () => {

  const dispatch = useDispatch()

  const config = () => {
    // Basic Controls
    MusicControl.enableControl('play', true)
    MusicControl.enableControl('pause', true)
    MusicControl.enableBackgroundMode(true);
    MusicControl.handleAudioInterruptions(true);

    // Controls events
    MusicControl.on('pause', ()=> {
      dispatch(actionsVideo.pausedChange(true))
      MusicControl.updatePlayback({ state: MusicControl.STATE_PAUSED })
    })

    MusicControl.on('play', ()=> {
      dispatch(actionsVideo.pausedChange(false))
      MusicControl.updatePlayback({ state: MusicControl.STATE_PLAYING })
    })
  }

  const close = () => {
    MusicControl.resetNowPlaying()
  }
  
  const set = (title) => {
    MusicControl.setNowPlaying({
      title: title,
      artwork: require('../assets/tc-logo.png'),
    })
    
    MusicControl.updatePlayback({ state: MusicControl.STATE_PLAYING })
  }

  return {config, close, set}

}

export default MusicControls; 

@parthya
Copy link

parthya commented Oct 29, 2020

"react": "16.8.6",
"react-native": "0.60.0",
"react-native-music-control": "^1.2.1",

Similar issue on iOS. For us, it is not that it doesn't work at all. But MusicControl.updatePlayback() works some of the time and doesn't other times.

Is there a way to get current state of the playback?

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

No branches or pull requests

3 participants