[ios] can play in simulator, but cannot play in device.
See original GitHub issuehere is my audio component’s code, and the this.sound.play is not any output, but this.sound.isLoaded() return true,
import React, {PureComponent, Component, PropTypes} from 'react'
import Sound from 'react-native-sound'
import UrlParse from 'url-parse'
import {
View,
TouchableOpacity
} from 'react-native'
Sound.setCategory('Playback');
class Audio extends PureComponent {
static propTypes = {
uri: PropTypes.string.isRequired
};
static defaultProps = {};
constructor(props) {
super(props);
this.state = {
loading: false
}
}
componentDidMount() {
}
_onPress() {
const urlInfo = UrlParse(this.props.uri)
this.sound = new Sound(urlInfo.pathname, urlInfo.origin, error => {
if (error) {
} else {
this.sound.play(success => {
if (success) {
console.log('successfully finished playing');
} else {
console.log('playback failed due to audio decoding errors');
}
this.sound.release();
});
}
})
}
render() {
return this.props.uri ?
(
<TouchableOpacity activeOpacity={0.5} onPress={() => this._onPress()}>
<View>{this.props.children}</View>
</TouchableOpacity>
) : null
}
}
export default Audio
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Video playing on xcode simulator but not on device
1 Answer 1 ... In your iPhone you have a different file system. You can't use the same paths that you use on...
Read more >A build only device cannot be used… | Apple Developer Forums
Hi I just started recently. I am trying to run my first application whic is a single view Application iOs. Once the project...
Read more >Ios – Why doesn't ios system sound play in simulator - iTecNote
It works fine on devices but does not play in the simulator. I have created a test app that does nothing but play...
Read more >VS 2019 16.9.4 cannot connect to iOS Simulator Xcode 12.5
You could disable the remote simulator (Tools / Options / iOS Settings / uncheck “Remote Simulator to Windows”). When unchecked the simulator will...
Read more >[Answer]-Why doesn't ios system sound play in simulator?-swift
1- The original file path I was using of "/System/Library/Audio/UISounds/Tone.caf" does not work in the simulator, it is only valid on the device....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks all, it’s fixed.
@gvenk documentations is still the same. However, this is not fixing the problem. Any other ideas? I need to use only remote, not local files