-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Fix some phones unable to play audio #2728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -523,7 +523,10 @@ onMounted(() => { | |
| let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}') | ||
| form_data.value = userFormData | ||
| } | ||
| window.speechSynthesis.cancel() | ||
| if (window.speechSynthesis) { | ||
| window.speechSynthesis.cancel() | ||
| } | ||
|
|
||
| window.sendMessage = sendMessage | ||
| bus.on('on:transcribing', (status: boolean) => { | ||
| transcribing.value = status | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippet provided is almost correct, with only one minor improvement. The Optimization Suggestion:Add an early return after checking if Here's the updated code: @@ -523,7 +523,10 @@ onMounted(() => {
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
form_data.value = userFormData
}
+ if (window.speechSynthesis) {
window.speechSynthesis.cancel() // Ensure this happens safely
- }
+ window.sendMessage = sendMessage;
+ bus.on('on:transcribing', (status: boolean) => {
+ transcribing.value = status;
+ });
}This change ensures that the rest of the function can proceed without relying implicitly on the presence of |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several issues and suggestions with the provided code:
Multiple Instances of Audio Elements: The line
<audio ref="audioPlayer" v-for="item in audioList" ...>generates multiple audio elements on each render, which is inefficient and could lead to performance problems.Conditional Rendering: Ensure that only one instance of
div ref="audioCiontainer"is used unless you need dynamic rendering based on some condition.Speech Synthesis vs HTML Audio Element: The logic is inconsistent between handling SpeechSynthesisUtterance and HTMLAudioElement instances. This leads to redundant checks and can be streamlined.
Error Handling: There's no error handling when creating a new
HTMLAudioElement, which should usedocument.createElement('audio')instead of assigning it directly to a ref using Vue.js syntax.State Management: The
statusListmanagement seems scattered around different methods without consistent usage guidelines. Consider consolidating state management for better readability and maintainability.Method Names and Signatures: Method names like
pauseand logic inside them might not work as expected because they don't handle certain states correctly (e.g.,PLAY_INTand other enum values).Code Style: There are minor style improvements that could enhance readability and consistency throughout the file.
Here are cleaned-up version recommendations:
Please adapt the above changes according to your project structure and requirements.