小程序
小游戏
企业微信
微信支付
扫描小程序码分享
复现场景:小程序webview的页面中有个audio音频元素正在播放,点击按钮使livePusher和livePlayer一起渲染后,该音频元素暂停播放
说明:单独使用livePusher或者livePlayer不会导致音频暂停播放
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
export default class AudioLive extends Component<any, any> {
export
default
class AudioLive extends Component<any, any> {
constructor(props){
super
(props)
this
.state = {
livePlay:
false
,
pusher:
null
}
handleClick() {
console.log(
'开始推拉流'
)
.setState({
true
pusher: {
url:
'rtmp://...' // 有效地址
})
render() {
const enowPlayUrl =
'http://...:8081'
return
(
<WebView
className=
'audio-live-page-1'
src={enowPlayUrl}
>
<CoverView className=
"cover"
'btn'
<Button type=
"default"
size=
'mini'
"cover-button"
onClick={
.handleClick}>推拉流</Button>
</CoverView>
{
.state.livePlay &&
<LivePlayer
src={
"rtmp://58.200.131.2:1935/livetv/gdtv"
mode=
'live'
autoplay
id={`live-video`}
className={`live-video`}
muted={
orientation=
'vertical'
objectFit=
'contain'
backgroundMute
minCache={0.2}
maxCache={0.8}
onStateChange={() => {}}
</LivePlayer>
.state.pusher &&
<LivePusher
url={
.state.pusher.url}
"RTC"
aspect=
"9:16"
"camera"
onError={() => {}}
onNetstatus={() => {}}
backgroundMute={
maxBitrate={500}
minBitrate={200}
waitingImage=
"https://webdemo.agora.io/away.png"
waitingImageHash={
''
autopush={
enableCamera={
autoFocus={
orientation={
beauty={3}
whiteness={2}
zoom={
/>
</WebView>
);
// webview内嵌页面html
<!DOCTYPE html>
<
html
head
meta
charset
=
"utf-8"
name
"viewport"
content
"width=device-width"
title
>Audio</
</
body
div
audio
controls
"controls"
volume=“0.1”
src
""
></
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
export
default
class AudioLive extends Component<any, any> {
constructor(props){
super
(props)
this
.state = {
livePlay:
false
,
pusher:
null
}
}
handleClick() {
console.log(
'开始推拉流'
)
this
.setState({
livePlay:
true
,
pusher: {
url:
'rtmp://...' // 有效地址
}
})
}
render() {
const enowPlayUrl =
'http://...:8081'
return
(
<WebView
className=
'audio-live-page-1'
src={enowPlayUrl}
>
<CoverView className=
"cover"
>
<CoverView className=
'btn'
>
<Button type=
"default"
size=
'mini'
className=
"cover-button"
onClick={
this
.handleClick}>推拉流</Button>
</CoverView>
</CoverView>
{
this
.state.livePlay &&
<LivePlayer
src={
"rtmp://58.200.131.2:1935/livetv/gdtv"
}
mode=
'live'
autoplay
id={`live-video`}
className={`live-video`}
muted={
false
}
orientation=
'vertical'
objectFit=
'contain'
backgroundMute
minCache={0.2}
maxCache={0.8}
onStateChange={() => {}}
>
</LivePlayer>
}
{
this
.state.pusher &&
<LivePusher
url={
this
.state.pusher.url}
mode=
"RTC"
aspect=
"9:16"
className=
"camera"
onStateChange={() => {}}
onError={() => {}}
onNetstatus={() => {}}
backgroundMute={
true
}
muted={
false
}
maxBitrate={500}
minBitrate={200}
waitingImage=
"https://webdemo.agora.io/away.png"
waitingImageHash={
''
}
autopush={
true
}
enableCamera={
false
}
autoFocus={
true
}
orientation={
'vertical'
}
beauty={3}
whiteness={2}
zoom={
false
}
/>
}
</WebView>
);
}
}
// webview内嵌页面html
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
>
<
title
>Audio</
title
>
</
head
>
<
body
>
<
div
>
<
audio
controls
=
"controls"
volume=“0.1”
src
=
""
></
audio
>
</
div
>
</
body
>
</
html
>