question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Audio will be silently on playAsync() immediately after stopAsync()

See original GitHub issue

Environment

in iOS target.

Environment: OS: macOS Sierra 10.12.6 Node: 8.2.1 Yarn: 0.27.5 npm: 5.3.0 Watchman: 4.7.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) expo: ^25.0.0 => 25.0.0 react: 16.2.0 => 16.2.0 react-native: https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz => 0.52.0

Steps to Reproduce

  1. Audio.setAudioModeAsync() on componentDidMount()
Audio.setAudioModeAsync({
  allowsRecordingIOS: false,
  interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
  playsInSilentModeIOS: true,
  shouldDuckAndroid: true,
  interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
});
  1. Press play button
  • if not loaded audio, load from uri playbackObject.loadAsync({uri:xxx})
  • play audio playbackObject.playAsync()
  1. One more press the play button
  • stop audio playbackObject.stopAsync()
  • play audio playbackObject.playAsync()

Expected Behavior

Sound also appears in silent mode

Actual Behavior

It is silently.

But, below is ok.

  1. Audio.setAudioModeAsync() on componentDidMount()
  2. Press play button
  3. Press stop button
  4. Press play button

or

  1. Audio.setAudioModeAsync() on componentDidMount()
  2. Press play button1
  3. Press play button2

Reproducible Demo

https://snack.expo.io/SJdn1jzuM

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
sjchmielacommented, Mar 15, 2018

Thank you for trying all that!

From what you wrote I suspect the problem occurs due to resetting of the Audio Mode. Working on a fix for that!

1reaction
watanabeyucommented, Mar 1, 2018

Hi @terribleben ,I try setPositionAsync(0) before playAsync, sounds appear! Thanks!

await this.playbackObject.stopAsync();
await this.playbackObject.setPositionAsync(0)
await this.playbackObject.playAsync();

But stopAsync() should be equivalent to setStatusAsync({ shouldPlay: false, positionMillis: 0 }), why needs setPositionAsync(0) ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AV - Expo Documentation
A boolean describing if the media just played to completion at the time that this status was received. When the media plays to...
Read more >
expo - could not stop the previous audio when playing another ...
useRef(new Audio.Sound());. Audio stop function. const stop = async () => { await sound.current.stopAsync(); await sound.current.
Read more >
react-native-audio-fexoplayer - npm
React Native module for playing sound clips on Android using Google ExoPlayer. Latest version: 1.0.1, last published: 4 years ago.
Read more >
How To Create An Audio/Video Recording App With React ...
After reading this article, you should have all the necessary knowledge to create video/audio recording functionality with React Native.
Read more >
npm - Snyk
To help you get started, we've selected a few expo-av.Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS examples ... _applyMode = async () => { try { await Audio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found