The app I made cancels the sound of other apps

Asked

Viewed 54 times

1

I made an app for android, which in short is a feed of videos and images. When I open my app and some video is paused or executed, the sound of other apps is also paused (Music, radio). I’ve looked for some solutions: https://github.com/react-native-community/react-native-video/issues/152 but none of the solutions I found could solve my problem.

Man package.json.

There is something in the android configuration that I can solve this, how to block the restrictions of the app pause third aps?

{
  "name": "myapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.2.1",
    "axios": "^0.18.0",
    "moment": "^2.24.0",
    "react": "16.8.3",
    "react-native": "^0.59.8",
    "react-native-elements": "^1.1.0",
    "react-native-image-crop-picker": "^0.23.1",
    "react-native-img-cache": "^1.6.0",
    "react-native-inviewport": "^1.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-linear-gradient": "^2.5.4",
    "react-native-platform-touchable": "^1.1.1",
    "react-native-popup-menu": "^0.15.5",
    "react-native-progress": "^3.6.0",
    "react-native-simple-radio-button": "^2.7.3",
    "react-native-svg": "^9.4.0",
    "react-native-timeago": "^0.4.0",
    "react-native-vector-icons": "^6.4.2",
    "react-native-video": "^4.4.1",
    "react-native-video-player": "^0.10.0",
    "react-navigation": "2.18.0",
    "rn-fetch-blob": "^0.10.15",
    "slugify": "^1.3.4"
  },
  "devDependencies": {
    "@babel/core": "7.3.4",
    "@babel/runtime": "^7.3.4",
    "babel-jest": "24.4.0",
    "jest": "24.4.0",
    "metro-react-native-babel-preset": "0.53.0",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "assets/fonts/BalooTammudu"
    ]
  }
}

1 answer

0


I ended up figuring out how to solve my problem, but I don’t think it’s a 100% effective solution. I reread the question github post and apparently the props disableFocus does not work, the default value of the variable is coming back. I do not know how far this will go, but when commenting on this function in the file ReactExoplayerView.java and always return true disables Focus from videos. However, I believe that all App videos will be without Focus.

private boolean requestAudioFocus() {
    // if (disableFocus) {
    //     return true;
    // }
    // int result = audioManager.requestAudioFocus(this,
    //         AudioManager.STREAM_MUSIC,
    //         AudioManager.AUDIOFOCUS_GAIN);
    // return result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
    return true;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.