Skip to content

Commit

Permalink
fix: local audio play
Browse files Browse the repository at this point in the history
  • Loading branch information
QinZhen001 committed Oct 8, 2023
1 parent 9b71f84 commit 352207c
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 22 deletions.
16 changes: 12 additions & 4 deletions vue/api-examples/src/components/AgoraVideoPlayer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div :style="style">
<div v-if="text" :style="{ marginTop: '10px', marginBottom: '10px' }">{{ text }}</div>
<div ref="videoRef" :style="{ width, height }" />
</div>
</div>
</template>


Expand Down Expand Up @@ -30,6 +30,10 @@ const props = defineProps({
type: Object,
default: {}
},
isLocal: {
type: Boolean,
default: false
},
text: {
type: [String, Number],
default: ''
Expand All @@ -48,12 +52,14 @@ const props = defineProps({
},
})
const { videoTrack, audioTrack, config } = props
const { videoTrack, audioTrack, config, isLocal } = props
onMounted(() => {
videoTrack?.play(videoRef.value, config)
audioTrack?.play()
if (!isLocal) {
audioTrack?.play()
}
})
watch(() => props.videoTrack, track => {
Expand All @@ -64,7 +70,9 @@ watch(() => props.videoTrack, track => {
watch(() => props.audioTrack, (track) => {
track?.play()
if (!isLocal) {
track?.play()
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/advanced/basicMute/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/advanced/dualStream/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div v-if="joined" class="mt-10">
<div class="text">Click Remote User Video Player Change Stream Type</div>
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<NetworkTestDialog ref="networkTestRef" :options="finOptions"></NetworkTestDialog>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/basicLive/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
4 changes: 2 additions & 2 deletions vue/api-examples/src/pages/basic/basicVideoCall/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack" :isLocal="true"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
<AgoraVideoPlayer v-for="item in remoteUsers" :key="item.uid" :videoTrack="item.videoTrack"
:audioTrack="item.audioTrack" :text="item.uid">
</AgoraVideoPlayer>
</div>
</div>
</div>
</template>

<script setup>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/basicVoiceCall/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/cloudProxy/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/screenshot/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :videoTrack="videoTrack" :audioTrack="audioTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :videoTrack="videoTrack" :audioTrack="audioTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/selfCapturing/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :videoTrack="customVideoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :videoTrack="customVideoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/selfRendering/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="audioTrack" :videoTrack="videoTrack"></AgoraVideoPlayer>
<div :style="{ marginTop: '10px', display: 'inline-block', border: '2px dashed red' }">
<video ref="mirrorPlayerRef" playsInline="" muted="" :style="{
width: '480p',
Expand Down
2 changes: 1 addition & 1 deletion vue/api-examples/src/pages/basic/shareTheScreen/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div v-if="joined" class="mt-10">
<div class="text">Local User</div>
<AgoraVideoPlayer :audioTrack="screenAudioTrack || audioTrack" :videoTrack="screenVideoTrack"></AgoraVideoPlayer>
<AgoraVideoPlayer :isLocal="true" :audioTrack="screenAudioTrack || audioTrack" :videoTrack="screenVideoTrack"></AgoraVideoPlayer>
</div>
<div v-if="Object.keys(remoteUsers).length">
<div class="text">Remote Users</div>
Expand Down

0 comments on commit 352207c

Please sign in to comment.