Audio playing method bypassing automatic playing limitation of browser and processing terminal

By instantiating the MQTT client in the VUE project and using the crawler library to locate audio tags, combined with the command line playback tool, bypassing the browser's automatic playback restriction, the problem of browser restricting automatic playback is solved, and the audio is automatically played, improving user experience and business stability.

CN120406892APending Publication Date: 2025-08-01GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510334653.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The existing browsers restrict the automatic playback function of audio and video, which leads to some web projects being unable to push audio and video in time, affecting the normal operation of the business and user experience. Especially in the large-screen display information, users are prone to missing important notifications.

Method used

By instantiating the MQTT client after the VUE project is initialized, configuring the MQTT server connection parameters, using the crawler library to locate audio tags, creating worker processes, and using command line playback tools such as ffplay, bypassing the browser's automatic playback restrictions, and realizing automatic audio playback.

Benefits of technology

It realizes automatic playback of audio without active user interaction, ensures the stability of message notification function, improves user experience, adapts to multiple operating systems, and expands application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120406892A_ABST
    Figure CN120406892A_ABST
Patent Text Reader

Abstract

The invention discloses an audio playing method bypassing automatic playing limitation of a browser. The audio playing method comprises the following steps: step 1, instantiating an MQTT client; 2, judging whether the MQTT client receives a target instruction or not, and continuing if the MQTT client receives the target instruction; step 3, selecting all target audio resources based on the target audio resource information; step 4, establishing a corresponding working process for each audio file in the target audio resource, thereby establishing working processes with the same number as the audio files; and 5, creating a command line playing tool capable of playing audios, and playing each audio file in the target audio resource in sequence until all audios are played. According to the invention, automatic playing limitation of a browser can be bypassed, and automatic audio playing can still be realized without active interaction of a user, so that the stability of a message notification function required by a service is ensured, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of browser audio playback, and particularly to an audio playback method and a processing terminal for bypassing browser automatic playback restrictions. Background Art

[0002] Many web projects rely on browsers to run. For example, a certain web project needs to play audio (such as music or language notification information, etc.), so this audio needs to run on the browser. However, many existing browsers limit the automatic playback function of audio and video, that is, the corresponding audio and video will only play after the user actively clicks to play manually. After the browser closes the automatic playback function permission, the normal operation of some web projects will be affected. For example, taking the message notification service scenario as an example, the project often uses MQ (message queue) and webSocket technologies to push new messages in the background to the front end. When the browser is strictly restricted by automatic playback, the background messages cannot be automatically pushed in time, resulting in the inability of audio and video to play automatically, which will interfere with and affect the normal operation of the business. Especially for large-screen display information, it is difficult for users to interact in time like ordinary devices (computer displays). Once the user misses the first interaction, all subsequent important notifications will have no prompt sound because the audio cannot be played automatically, affecting the user experience and hindering the normal progress of the business. Therefore, a technology is needed that can still perform normal audio and video playback on the browser by bypassing the automatic playback function permission after the browser closes the automatic playback function permission. Summary of the Invention

[0003] Aiming at the deficiencies of the prior art, the purpose of the present invention is to provide an audio playback method and a processing terminal for bypassing browser automatic playback restrictions, which can solve the problems described in the background art.

[0004] The technical solution for achieving the purpose of the present invention is: an audio playback method for bypassing browser automatic playback restrictions, including the following steps:

[0005] Step 1: After the initialization of the VUE project is completed and the page is successfully loaded, instantiate the MQTT client and configure the corresponding MQTT server connection parameters in the system environment;

[0006] Step 2: Determine whether the MQTT client receives a target instruction, where the target instruction includes information about the target audio resource to be played. If so, continue to execute Step 3; if not, continue to receive MQTT information;

[0007] Step 3: Based on the target audio resource information, select all target audio resources;

[0008] Step 4: Create a corresponding worker process for each audio file in the target audio resource, thus creating the same number of worker processes as the number of audio files;

[0009] Step 5: Create a command-line playback tool for playable audio and play each audio file in the target audio resource in sequence until all the audio is played.

[0010] Further, in Step 1, use the lifecycle hook function in the VUE component to instantiate the MQTT client.

[0011] Further, in Step 1, when the system environment is the Windows operating system, the configured MQTT server connection parameters include host and port.

[0012] Further, in Step 3, call the crawler library of Node.js and traverse all DOM structures in the page through the crawler library to accurately locate the src attribute within all audio tags, thereby selecting the target audio resource.

[0013] Further, in Step 5, create a command-line playback tool through the child_process module of Node.js, where the ffplay command component is used as the command-line playback tool for playable audio.

[0014] Further, after Step 5, it also includes

[0015] Step 6: Detect the completion status of all processes and the completion status of audio playback. If both are completed, end the processing.

[0016] Further, the specific implementation process of detecting the completion status of all processes includes:

[0017] Define a function in the main process. The function returns a new Promise instance. Use the forEach method to traverse each incoming worker process, and add an exit event listener to each worker process.

[0018] When a certain process triggers the exit event, it means that the process has ended, and the defined variable is incremented by 1. If the value of the current variable is the same as the number of processes, it means that all processes are completed.

[0019] Further, the specific implementation process of detecting the completion status of all audio playback includes:

[0020] Maintain a variable as a counter. Increment the count of the counter when each audio playback is completed. When the count of the counter is equal to the number of audio files, it means that all audio has been played, and execute the tmp.dir command to delete the temporary folder.

[0021] A processing terminal, comprising:

[0022] A memory for storing program instructions;

[0023] A processor for running the program instructions to execute the steps of the audio playback method for bypassing the browser's automatic playback limit.

[0024] Advantages of the present invention: The present invention can bypass the browser's automatic playback limit and still achieve automatic audio playback without the need for user active interaction (such as manually clicking the play button), thereby ensuring the stability of the message notification function required by the service, improving the user experience, and without relying on specific browser versions and operating systems, being easy to adapt to mainstream systems, expanding application scenarios, and facilitating subsequent iterations. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic flowchart for implementing the image focusing evaluation method;

[0026] Figure 2 It is a schematic structural diagram of a processing terminal. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The following further describes the present invention in conjunction with the accompanying drawings and specific implementation schemes:

[0028] As Figure 1 shown, an audio playback method for bypassing the browser's automatic playback limit includes the following steps:

[0029] Step 1: After the initialization of the VUE project is completed and the page is successfully loaded, instantiate the MQTT client and configure the corresponding MQTT server connection parameters in the system environment.

[0030] In this step, the lifecycle hook function in the VUE component can be used to instantiate the MQTT client. The MQTT client is used to receive MQTT information such as messages and instructions from the MQTT server.

[0031] The configured MQTT server connection parameters are adapted to the corresponding system environment. For example, if the system environment is the Windows operating system, the configured MQTT server connection parameters include parameters such as host and port to enable the message listening channel to be opened, so as to be able to receive MQTT information from the MQTT server.

[0032] Step 2: Determine whether the MQTT client has received a target instruction. The target instruction includes the target audio resource information to be played. If so, proceed to step 3; if not, continue to receive MQTT information.

[0033] Step 3: Select all target audio resources based on the target audio resource information.

[0034] In this step, call the crawler library of Node.js and traverse all DOM structures in the page through the crawler library to accurately locate the src attributes within all <audio> tags. The <audio> tag is also the audio tag, thereby selecting the target audio resources.

[0035] The main code for accurately locating the src attributes within all <audio> tags is as follows:

[0036] const { data} = await axios.get(url);

[0037] const $ = cheerio.load(data); const audioSources = [];

[0038] $('audio').each((i, elem) => { const src = $(elem).attr('src'); if (src)

[0039] { audioSources.push(src);}});

[0040] Step 4: Create a corresponding worker process for each audio file in the target audio resources, thereby creating the same number of worker processes as the number of audio files.

[0041] In this step, use the child_process module of Node.js to create child processes, and each child process serves as the worker process.

[0042] Step 5: Create a command-line playback tool for playing audio. The command-line playback tool is an executable command-line program module. After creating the command-line playback tool, play each audio file in the target audio resources in sequence until all the audio is played.

[0043] In this step, the command-line playback tool can be created through the child_process module of Node.js. For example, create an ffplay command component as the command-line playback tool for playing audio.

[0044] Use the exec function introduced by the child_process module of Node.js. The exec function is used to execute external commands in the script shell. The external command can be the ffplay command, thereby achieving the playback of the current audio.

[0045] For the audio to be played, all the audio to be played corresponding to the remaining processes is written into a local temporary file in an audio source pipeline manner through the node-tmp library to be stored in the local buffer for subsequent audio playback. Through the pipeline mechanism, each audio is transported to a pointer within the temporary file.

[0046] Step 6: Detect the completion status of all processes and the completion status of audio playback. If both are completed, end the processing.

[0047] Define a function in the main process. The function returns a new Promise instance. Use the forEach method to iterate through each of the incoming worker processes, and add an exit event listener to each worker process. When a certain process triggers the exit event, it means that the process has ended, and the defined variable is incremented by 1. If the value of the current variable is the same as the number of processes, it means that all processes are completed.

[0048] For checking whether all audio has been played, a variable can be maintained as a counter. When each audio is played to completion, the count of the counter is incremented. When the count of the counter is equal to the number of audio files, it means that all audio has been played, and then execute the tmp.dir command to delete the temporary folder.

[0049] The present invention can bypass the automatic playback limit of the browser and still be able to achieve automatic audio playback without the user's active interaction (such as manually clicking the play button), thereby ensuring the stability of the message notification function required by the service, improving the user experience, and without relying on specific browser versions and operating systems, being easily adaptable to mainstream systems, expanding the application scenarios, and being conducive to subsequent iterations.

[0050] As Figure 2 shown, the present invention also provides a processing terminal 100, which includes:

[0051] A memory 101 for storing program instructions;

[0052] A processor 102 for running the program instructions to execute the steps of the audio playback method for bypassing the automatic playback limit of the browser.

[0053] The embodiments disclosed in this specification are only an illustration of the unilateral features of the present invention. The protection scope of the present invention is not limited to this embodiment, and any other functionally equivalent embodiments fall within the protection scope of the present invention. For those skilled in the art, various corresponding changes and deformations can be made according to the technical solutions and concepts described above, and all these changes and deformations should fall within the protection scope of the claims of the present invention.

Claims

1. An audio playback method for bypassing the automatic playback restriction of a browser, characterized in that, It includes the following steps: Step 1: After the initialization of the VUE project is completed and the page is successfully loaded, instantiate the MQTT client and configure the corresponding MQTT server connection parameters in the system environment; Step 2: Determine whether the MQTT client receives a target instruction. The target instruction includes the information of the target audio resource to be played. If so, continue to execute Step 3. If not, continue to receive MQTT messages; Step 3: Select all target audio resources based on the target audio resource information; Step 4: Create a corresponding working process for each audio file in the target audio resources, so as to create the same number of working processes as the number of audio files; Step 5: Create a command-line playback tool that can play audio and play each audio file in the target audio resources in sequence until all the audio is played; 2. The audio playback method for bypassing the browser's automatic playback restriction according to claim 1, wherein In Step 1, use the lifecycle hook function in the VUE component to instantiate the MQTT client.

3. The audio playback method for bypassing the automatic playback restriction of a browser according to claim 1, characterized in that In Step 1, when the system environment is the Windows operating system, the configured MQTT server connection parameters include host and port.

4. The audio playback method for bypassing the browser's automatic playback restriction according to claim 1, wherein In Step 3, call the crawler library of Node.js and traverse all DOM structures in the page through the crawler library to accurately locate the src attributes in all audio tags, so as to select the target audio resources.

5. The audio playing method for bypassing the automatic playing limit of a browser according to claim 1, wherein In Step 5, create a command-line playback tool through the child_process module of Node.js. Among them, the ffplay command component is used as the command-line playback tool that can play audio.

6. The audio playing method for bypassing the automatic playing limit of a browser according to claim 1 or 5, characterized in that After Step 5, it also includes: Step 6: Detect the completion of all processes and the completion of audio playback. If both are completed, end the processing.

7. The audio playing method for bypassing the automatic playing limit of a browser according to claim 6, wherein The specific implementation process of detecting the completion of all processes includes: Define a function in the main process. The function returns a new Promise instance. Use the forEach method to traverse each incoming working process and add an exit event listener to each working process. When a certain process triggers the exit event, it means that the process ends, and the defined variable is incremented by 1. If the value of the current variable is the same as the number of processes, it means that all processes are completed.

8. The audio playing method for bypassing the automatic playing limit of a browser according to claim 6, wherein The specific implementation process of detecting the completion of all audio playback includes: Maintain a variable as a counter. Increase the count of the counter when each audio playback is completed. When the count of the counter is equal to the number of audio files, it means that all audio playback is completed, and execute the tmp.dir command to delete the temporary folder.

9. A processing terminal, characterized in that, It includes: A memory for storing program instructions; A processor for running the program instructions to execute the steps of the audio playback method for bypassing the browser's automatic playback restriction as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Edge computing techniques for presence point optimization for transport layer congestion control and extension-based advanced quality of service notification

    CN114402640A

  • Robot control method, device, server and system and storage medium

    CN116319729A

  • Automatic audio playing method and device of WeChat browser and medium

    CN117931117A