1***@qq.com
1***@qq.com
  • 发布:2023-11-21 22:46
  • 更新:2023-11-22 11:59
  • 阅读:206

【报Bug】vue3模式下uni.createLivePlayerContext is not a function

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win11

HBuilderX类型: 正式

HBuilderX版本号: 3.8.12

手机系统: Android

手机系统版本号: Android 11

手机厂商: 小米

手机机型: 小米10

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

<template>
<view class="content">
<view class="player-content">

        <live-player id="livePlayer" ref='livePlayer' class="live-player" catchtouchmove :src="sourceUrl" autoplay  
            background-mute sound-mode="speaker" mode='RTC' @statechange="statechange" @click="handleControlbar">  
            <view class="player-tool" style="bottom:-60rpx">  
                <view class="tools">  
                    ghjgj  
                </view>  
            </view>  
        </live-player>  

    </view>  
</view>  

</template>

<script setup>
import {
ref
} from "vue"

uni.createLivePlayerContext("livePlayer")  

</script>

<style lang="scss" scoped>
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;

    .player-content {  
        position: relative;  
        width: 100%;  
        height: 450rpx;  
        display: flex;  
        background-size: 100% 100%;  

        .live-player {  
            width: 100%;  
            height: 100%;  
            position: relative;  
        }  
    }  
}  

//播放器弹出工具  
.player-tool {  
    width: 100%;  
    height: 60rpx;  
    background-image: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);  
    display: flex;  
    align-items: center;  
    justify-content: space-between;  
    position: absolute;  
    left: 0;  
    padding: 0 45rpx;  
    transition: all 0.3s;  

    .tools {  
        height: 100%;  
        width: auto;  
        display: flex;  
        align-items: center;  

        .full-screen {  
            height: 100%;  
            display: flex;  
            align-items: center;  
            justify-content: center;  

            .iconfont {  
                color: #fff;  
                font-weight: bold;  

            }  
        }  

        .cruise {  
            display: flex;  
            align-items: center;  
            justify-content: center;  
            margin-left: 25rpx;  

            .iconfont {  
                color: #E45A3E;  
                font-size: 45rpx;  
            }  
        }  
    }  

}  

</style>

预期结果:

<template>
<view class="content">
<view class="player-content">

        <live-player id="livePlayer" ref='livePlayer' class="live-player" catchtouchmove :src="sourceUrl" autoplay  
            background-mute sound-mode="speaker" mode='RTC' @statechange="statechange" @click="handleControlbar">  
            <view class="player-tool" style="bottom:-60rpx">  
                <view class="tools">  
                    ghjgj  
                </view>  
            </view>  
        </live-player>  

    </view>  
</view>  

</template>

<script setup>
import {
ref
} from "vue"

uni.createLivePlayerContext("livePlayer")  

</script>

<style lang="scss" scoped>
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;

    .player-content {  
        position: relative;  
        width: 100%;  
        height: 450rpx;  
        display: flex;  
        background-size: 100% 100%;  

        .live-player {  
            width: 100%;  
            height: 100%;  
            position: relative;  
        }  
    }  
}  

//播放器弹出工具  
.player-tool {  
    width: 100%;  
    height: 60rpx;  
    background-image: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);  
    display: flex;  
    align-items: center;  
    justify-content: space-between;  
    position: absolute;  
    left: 0;  
    padding: 0 45rpx;  
    transition: all 0.3s;  

    .tools {  
        height: 100%;  
        width: auto;  
        display: flex;  
        align-items: center;  

        .full-screen {  
            height: 100%;  
            display: flex;  
            align-items: center;  
            justify-content: center;  

            .iconfont {  
                color: #fff;  
                font-weight: bold;  

            }  
        }  

        .cruise {  
            display: flex;  
            align-items: center;  
            justify-content: center;  
            margin-left: 25rpx;  

            .iconfont {  
                color: #E45A3E;  
                font-size: 45rpx;  
            }  
        }  
    }  

}  

</style>

实际结果:

<template>
<view class="content">
<view class="player-content">

        <live-player id="livePlayer" ref='livePlayer' class="live-player" catchtouchmove :src="sourceUrl" autoplay  
            background-mute sound-mode="speaker" mode='RTC' @statechange="statechange" @click="handleControlbar">  
            <view class="player-tool" style="bottom:-60rpx">  
                <view class="tools">  
                    ghjgj  
                </view>  
            </view>  
        </live-player>  

    </view>  
</view>  

</template>

<script setup>
import {
ref
} from "vue"

uni.createLivePlayerContext("livePlayer")  

</script>

<style lang="scss" scoped>
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;

    .player-content {  
        position: relative;  
        width: 100%;  
        height: 450rpx;  
        display: flex;  
        background-size: 100% 100%;  

        .live-player {  
            width: 100%;  
            height: 100%;  
            position: relative;  
        }  
    }  
}  

//播放器弹出工具  
.player-tool {  
    width: 100%;  
    height: 60rpx;  
    background-image: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);  
    display: flex;  
    align-items: center;  
    justify-content: space-between;  
    position: absolute;  
    left: 0;  
    padding: 0 45rpx;  
    transition: all 0.3s;  

    .tools {  
        height: 100%;  
        width: auto;  
        display: flex;  
        align-items: center;  

        .full-screen {  
            height: 100%;  
            display: flex;  
            align-items: center;  
            justify-content: center;  

            .iconfont {  
                color: #fff;  
                font-weight: bold;  

            }  
        }  

        .cruise {  
            display: flex;  
            align-items: center;  
            justify-content: center;  
            margin-left: 25rpx;  

            .iconfont {  
                color: #E45A3E;  
                font-size: 45rpx;  
            }  
        }  
    }  

}  

</style>

bug描述:

vue3模式下uni.createLivePlayerContext is not a function

2023-11-21 22:46 负责人:无 分享
已邀请:
套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

刚测试了下,微信小程序没问题

<live-player  
            id="liveplayer"  
            src="https://domain/pull_stream"  
            mode="live"  
            :autoplay="true"  
            orientation="vertical"  
            object-fit="fillCrop"  
            @statechange="statechange"  
            @error="error"  
        >  
        </live-player>
fgffffff(){  
                let player = uni.createLivePlayerContext('liveplayer', this);  
                console.log('aaaa',player);  

            },  
YUANRJ

YUANRJ

app端不支持,参考文档

要回复问题请先登录注册