Tee*_*dub 6 javascript android react-native react-native-android
我有一个简单的应用程序,渲染后几秒钟即可播放声音。
一切正常,除了如果我锁定屏幕,应用程序将不会播放声音,直到我再次将其解锁。
这是我正在使用的简化版本:
import React, { Component, PropTypes } from 'react';
import { View, Text } from 'react-native';
import Sound from 'react-native-sound'; //for the bell sound
class SoundTest extends Component {
componenWillMount(){
setTimeout(this.playSound(), 5000);
}
playSound() {
let s = new Sound('bell.wav','', (e) => {
if (e) {
console.log('error', e);
} else {
console.log('duration', s.getDuration());
s.play();
}
});
}
render() {
return (
<View>
<Text>Hear some sound after a few!</Text>
</View>
)
}
}
AppRegistry.registerComponent('SoundTest', () => SoundTest);
// Works great if the screen is on / not locked
Run Code Online (Sandbox Code Playgroud)
不管屏幕是否锁定,是否都有某种播放声音的方法?
| 归档时间: |
|
| 查看次数: |
547 次 |
| 最近记录: |