12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <view class="plv-mp-demo-page">
- <player
- bind:onLiveStorageProgress="onLiveStorageProgress"
- bind:onLiveStatusChange="onLiveStatusChange"
- bind:refreshStatus="onRefreshStatus"
- ref="player"
- class="plv-mp-demo-player"
- :videoOption="videoOption"
- />
- </view>
- </template>
- <script>
- import plv from '../static/polyv-sdk/index';
- export default {
- data() {
- return {
- videoOption:{
- mode: 'live',
- uid: 'egsxlptzdq',
- cid: '2553128',
- openId: 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ',
- isAutoChange: false,
- forceVideo: false,
- },
- detail: {},
- };
- },
- mounted() {},
- methods: {
- setLiveOption(status) {
- const { userId, channelId, recordFileSimpleModel, playbackEnabled } = this.detail;
- const playRecordFile = playbackEnabled && recordFileSimpleModel && status === 'end';
-
- this.videoOption = {
- mode: 'live',
- uid: userId,
- cid: channelId,
- isAutoChange: false,
- forceVideo: false,
- vodsrc: playRecordFile ? recordFileSimpleModel.mp4 || recordFileSimpleModel.m3u8 : '',
- liveMode: playRecordFile ? 2 : 1,
- }
- },
- onLiveStorageProgress(res) {
- console.log(1)
- console.log(res)
- },
- onLiveStatusChange() {
- console.log(2)
- },
- onRefreshStatus() {
- console.log(3)
- },
- },
- onLoad(options) {
- options.mode = 'live';
- options.forceVideo = false;
- options.channelId = '2553128'; // 频道ID
- options.openId = 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ'; // 用户openId
- // userName: ''; // 用户名
- // avatarUrl: ''; // 用户头像
- options.userId = 'egsxlptzdq' // 2.0.0及以上版本的demo需要使用 userId 设置学员唯一id
- plv.init(options)
- .then((res) => {
- console.log(res)
- // this.detail = detail
- // // 设置mode为live的videoOption
- // // this.setLiveOption();
-
- // if (detail.isPPT) {
- // chat.on(chat.events.SLICESTART, () => {
- // // 开始直播
- // });
- // } else {
- // plv.api.getOrdinaryLiveStatus(detail.stream);
- // }
- });
-
- console.log(this.$refs.player)
-
- },
- onUnload() {
- plv.destroy();
- }
- };
- </script>
- <style scoped lang="scss">
- .plv-mp-demo-page {
- height:500rpx;
- }
- </style>
|