【发布时间】:2019-01-22 02:11:10
【问题描述】:
我正在努力使用 react 360 在手机上播放音频。通过阅读各种文档,我了解到为了在手机上播放音频,我需要制定一个 html 实体来创建用户相互作用。一旦用户通过单击按钮进行交互,音频应该能够在移动设备上播放。好像不是这样的。
在我的index.html 文件中,我有以下代码:
<html>
<head>
<title>ExampleVR</title>
<style>body { margin: 0; }</style>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</head>
<body>
<!-- Attachment point for your app -->
<div id="container">
<button id="enter" onclick="enterApp();">
Click to Enter VR
</button>
</div>
<script src="./client.bundle?platform=vr"></script>
<script>
// Initialize the React 360 application
function enterApp() {
React360.init(
'index.bundle?platform=vr&dev=true',
document.getElementById('container'),
{
assetRoot: 'static_assets/',
}
);
}
</script>
</body>
</html>
如您所见,我创建了一个 html 按钮,单击该按钮会加载我的 React 360 代码。但是,当我在手机中单击VrButton 时,它仍然无法播放。我已按照文档中的建议进行操作,它适用于桌面上的所有浏览器,但移动设备除外。有谁知道如何解决这个问题?
【问题讨论】:
-
我对 React360 如何播放音频一无所知,但我认为它使用 Web Audio API。从您发布的代码来看,它可能无法正常工作,因为它以某种方式异步启动音频播放,这不符合“从用户操作激活”的要求。您可以在此处了解有关解锁 Web 音频的更多信息:paulbakaus.com/tutorials/html5/web-audio-on-ios
-
还有一件事:你检查过你 iPhone 上的静音开关了吗?
标签: reactjs react-native web-audio-api virtual-reality react-360