React-native-track-player: [ IOS ] Remote buttons not activated

Created on 13 Nov 2017  路  29Comments  路  Source: react-native-kit/react-native-track-player

ss

Ios remote buttons are disabled.

My option code:

TrackPlayer.setupPlayer({}).then(()=>{
TrackPlayer.updateOptions({
capabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
TrackPlayer.CAPABILITY_STOP,
TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
TrackPlayer.CAPABILITY_SEEK_TO],
stopWithApp: true });
});

Bug iOS

Most helpful comment

Here's my solution:

In RNTrackPlayer.swift, inside the method 'update' modify these lines as follows:

let enablePause = true // capabilities.contains(.pause)
let enablePlay = true // capabilities.contains(.play)
let enablePlayNext = true // capabilities.contains(.next)
let enablePlayPrevious = true // capabilities.contains(.previous)

You can directly modify your react-native-track-player in node_module and run 'react-native link'. Until a better fix is merged, this would do the job.

All 29 comments

Can someone help me ?

TrackPlayer.CAPABILITY_SEEK_TO is not supported on iOS at the moment. However, it should still accept the ones that are valid -- so it's a bug. I will work on a fix however for now you can remove it for iOS devices and I believe it should work.

This has been fixed in a0b4eb9e9c012cc05a4ed10cca28d4c04495c4f8, so feel free to use that as well or the fix I suggested above. Thanks for reporting the bug! 馃槃

Hello, I removed TrackPlayer.CAPABILITY_SEEK_TO but still disabled on my iPad.

Can you give me well done test demo?

Buttons for ios are disabled for me as well. If I don't pass any capabilities, they are enabled but not working.

@dcvz I think this issue should be reopened. Buttons are disabled if you set any capabilities and if you don't set any capabilites, the buttons do not send any events.

Could it possibly be due to the fact that all of TrackPlayer's properties are null?
After calling TrackPlayer.setupPlayer() and console logging the object after the promise, I am seeing this. Not entirely sure, but wondering if this has something to do with the issues of the remote player.
screen shot 2017-12-18 at 1 45 29 pm

@dcvz @Guichaguri iOS react-native version 0.49+ is spitting out an issue with constantsToExport() being overridden. I believe this is the issue why iOS's constants are being set to null/undefined. Not sure what the fix is as i'm not very familiar with swift, however I think addressing that would solve this and many other issues you're bound to have opened by users.

Everything works fine in android so this is clearly an iOS specific issue.

+1 Having similar problem

@dcvz @Guichaguri I think the problem is in this code.
image

the capabilities array is empty if we are trying to set capabilities from updateOptions. capabilities is empty so the remaining variable like enableStop or enablePause is set to false and after that it is passed to toggleRemoteHandler which set that remote button to false. This is why we are unable to see the remote button when we are setting capabilities in updateOptions of the package.

@ankitsinghania94 the problem you mention has already been fixed upstream, we just haven't pushed an update to npm. Try pulling directly from the repository and your issue should be fixed :) We will push an update to npm soon.

As for the other reports: I will look into it today.

@dcvz Can you tell me on which commit it is fixed?

@dcvz I'm having this issue on master and dev is not building so where should we be pulling from?

Ditto @dcvz -- can't use dev because it doesn't build; iOS buttons not working :(

Any update on this issue? got the same problem here, the music controls is disabled.

Here's my solution:

In RNTrackPlayer.swift, inside the method 'update' modify these lines as follows:

let enablePause = true // capabilities.contains(.pause)
let enablePlay = true // capabilities.contains(.play)
let enablePlayNext = true // capabilities.contains(.next)
let enablePlayPrevious = true // capabilities.contains(.previous)

You can directly modify your react-native-track-player in node_module and run 'react-native link'. Until a better fix is merged, this would do the job.

Has this problem already solved?
I bumped this library to latest version(0.23). But remote buttons aren't still deactivated.
By solve that, I've got to apply a @SatoshiInoue solution likewise.

I have the same issue. I patched the RNTrackPlayer.swift file but that doesn't fix it. I'm not sure it's really being rebuilt. React-native link says the library is already linked. What did you do to get a recompile?

I just confirmed that it is being rebuilt. If I leave a syntax error in the RNTrackPlayer.swift file then I get a compile error, so it must be working, but the remote controls still don't work. Other than that this lib is great!

I still wasn't able to make the quick fix work, but when I switched to the dev branch everything works fine. Is it time to cut a new release?

SatoshiInoue fix is working for me concerning play/pause, thanks ;)

However, for CAPABILITY_SEEK_TO, if I put enableSkipForward and enableSkipBackward to true nothing is happenning when I drag the slider in the lockscreen.

Any idea how to fix that?

I also had the same problem and applied this fix. I don't currently have the time to make a pull request. Perhaps end of next week

        let rawCapabilites = options["capabilities"]
        var capabilities = [String]()

        if (rawCapabilites != nil)
        {
            let castedCapabilities = rawCapabilites as! [Any]
            capabilities = castedCapabilities.flatMap { $0 as? String }
        }

        let enableStop = capabilities.contains("stop")
        let enablePause = capabilities.contains("pause")
        let enablePlay = capabilities.contains("play")
        let enablePlayNext = capabilities.contains("next")
        let enablePlayPrevious = capabilities.contains("previous")
        let enableSkipForward = capabilities.contains("jumpForward")
        let enableSkipBackward = capabilities.contains("jumpBackward")

works with no capabilities passed and with capabilities that contain random stuff that is invalid, like null for CAPABILITY_SEEK_TO

I'm on version 0.25 and still have this problem. I would rather not do the swift file quick-fix and pushing the node_module to our project repository.

UPDATE:
Nevermind, somehow my background capabilities where disabled again. Also I passed the options to the setupPlayer method, which is not accepting capabilities. However, couldn't it make sense to pass the capabilities while setting up the player?

@brenwell I tried your fix and it's working for me perfectly. I went ahead and created a PR based on just that fix, since your fork seemed to have some unrelated android changes applied to them.

PR is here: #295

This has been fixed in the commit just above and will be part of our 1.0.0 release going out today or tomorrow.

I have setup the example demo from repo and have installed 1.0.0, but still not seeing the control on lock screen. any suggestion please? Following is my package.json

{
"name": "DemoProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"mobx": "^4.1.1",
"mobx-react": "^5.0.0",
"react": "16.6.1",
"react-native": "0.57.7",
"react-native-track-player": "github:react-native-kit/react-native-track-player#dev",
"react-navigation": "^1.5.9"
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/runtime": "^7.1.2",
"@types/react": "^16.4.14",
"@types/react-native": "^0.57.0",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.50.0",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}

@mbhuiayan You shouldn't have to point to github:react-native-kit/react-native-track-player#dev anymore you should just be able to pull from 1.0.0.

Regardless can you post your source code on how you setup the player and what capabilities you set for it.

It works; its just that controller only shows up on simulator version 10.3.1 or lower in case it helps anyone.

I am using the link http://103.253.47.173:8000/;stream/1 as one of the stream in the example demo. I am seeing an weird behavior. Once I click on play and lock the screen I don鈥檛 see the lock screen controller. I only see the lock screen contoller on second attempt; like unlock the screen; stop, play and lock screen again. This is only happening with the link http://103.253.47.173:8000/;stream/1. Does anyone have any idea?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiocosta88 picture fabiocosta88  路  3Comments

amed picture amed  路  4Comments

moduval picture moduval  路  3Comments

sagargheewala picture sagargheewala  路  3Comments

KalebPortillo picture KalebPortillo  路  4Comments