How to use the react-native-sound.setCategory function in react-native-sound

To help you get started, we’ve selected a few react-native-sound examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github goodatlas / react-native-audio-record / Example / App1.js View on Github external
play = async () => {
    if (!this.state.loaded) {
      try {
        await this.load();
      } catch (error) {
        console.log(error);
      }
    }

    this.setState({ paused: false });
    Sound.setCategory('Playback');

    this.sound.play(success => {
      if (success) {
        console.log('successfully finished playing');
      } else {
        console.log('playback failed due to audio decoding errors');
      }
      this.setState({ paused: true });
      // this.sound.release();
    });
  };
github EdgeApp / edge-react-gui / src / lib / soundsMiddleware.js View on Github external
// @flow

import Sound from 'react-native-sound'

import { OPEN_AB_ALERT } from '../../src/constants/ActionConstants'
import type { Action } from '../modules/ReduxTypes.js'
import { DISPLAY_TRANSACTION_ALERT } from '../modules/UI/components/TransactionAlert/actions'

const AUDIO_RECEUVED_FILE = 'audio_received.mp3'
const AUDIO_SEND_FILE = 'audio_sent.mp3'

Sound.setCategory('Ambient')

const audioReceived = new Sound(AUDIO_RECEUVED_FILE, Sound.MAIN_BUNDLE, error => {
  if (error) console.warn(`failed to load the sound ${AUDIO_RECEUVED_FILE}`, error)
})

const audioSent = new Sound(AUDIO_SEND_FILE, Sound.MAIN_BUNDLE, error => {
  if (error) console.error(`failed to load the sound ${AUDIO_SEND_FILE}`, error)
})

const playCb = audioName => success => {
  if (success) {
    console.info(`successfully finished playing ${audioName}`)
  } else {
    console.warn(`playback ${audioName} failed due to audio decoding errors `)
  }
}
github bailabs / tailpos / src / container / SalesContainer / index.js View on Github external
// TailOrder
import {
  voidLine,
  sendOrder,
  printOrder,
  cancelOrder,
  tailOrderLine,
  changeOrderTable,
  getOrder,
  orderItemToReceiptItem,
} from "../../services/tailorder";

import { currentLanguage } from "../../translations/CurrentLanguage";
const Sound = require("react-native-sound");
Sound.setCategory("Playback");
const beep = new Sound("beep.mp3", Sound.MAIN_BUNDLE);
import translation from "../.././translations/translation";
import LocalizedStrings from "react-native-localization";
let strings = new LocalizedStrings(translation);
@inject(
  "itemStore",
  "customerStore",
  "receiptStore",
  "discountStore",
  "categoryStore",
  "paymentStore",
  "printerStore",
  "shiftStore",
  "attendantStore",
  "stateStore",
)
github zulip / zulip-mobile / src / utils / sound.js View on Github external
/* @flow strict-local */
import Sound from 'react-native-sound';
import * as logging from './logging';

if (Sound && Sound.setCategory) {
  Sound.setCategory('Ambient', true);
}

const messageSound = new Sound('zulip.mp3', Sound.MAIN_BUNDLE, (error: Error) => {
  if (error) {
    logging.error(error);
  }
});

export const playMessageSound = () => messageSound.play();
github zmxv / react-native-sound-demo / main.js View on Github external
constructor(props) {
    super(props);

    Sound.setCategory('Playback', true); // true = mixWithOthers

    // Special case for stopping
    this.stopSoundLooped = () => {
      if (!this.state.loopingSound) {
        return;
      }

      this.state.loopingSound.stop().release();
      this.setState({loopingSound: null, tests: {...this.state.tests, ['mp3 in bundle (looped)']: 'win'}});
    };

    this.state = {
      loopingSound: undefined,
      tests: {},
    };
  }
github dabit3 / appsync-lambda-ai / App.js View on Github external
import React, { Component } from 'react';
import {
  StyleSheet,
  View,
  TextInput
} from 'react-native';

import { ButtonGroup, Button } from 'react-native-elements'
import { API, graphqlOperation } from 'aws-amplify'

var Sound = require('react-native-sound')
Sound.setCategory('Playback')

import codes from './codes'
import query from './query'

const buttons = [
  'French',
  'Portugese',
  'Spanish',
  'German'
]

export default class App extends Component {
  state = {
    index: 0,
    codes,
    sentence: '',