Resource automatic playback method, device, equipment and storage medium
By adding audio elements to trigger automatic playback in the iOS browser page and dynamically modifying the resource address, the problem of audio or video in iOS cannot be automatically played, achieving a better user experience.
Patent Information
- Application Number
- CN202211336230.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-28
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2042-10-28
AI Technical Summary
In some operating systems such as iOS, browser pages cannot automatically play audio or video resources, and users must trigger playback manually.
By adding audio elements to the page to trigger automatic playback, and using event listeners to monitor page events, dynamically modifying the resource address of the audio element, thereby achieving the resources required for automatic playback.
Automatic playback of audio or video resources is realized in an operating system that could not be played automatically, improving the user experience, especially in learning playback or following scenarios.
Smart Images

Figure CN115695893B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the field of audio and video playback. Background Art
[0002] With the popularity of smart terminals such as smartphones, there are more and more opportunities to open the fifth generation HyperText Markup Language 5 (HTML5 or H5) pages through the browsers of social applications. On H5 pages, you can learn, listen to music, watch videos, etc. However, some operating systems, such as iOS (Apple operating system), do not allow audio to play automatically in some applications. Users must manually trigger and click to play the audio. Summary of the invention
[0003] The present invention provides a resource automatic playback method, device, equipment and storage medium.
[0004] According to one aspect of the present disclosure, a method for automatically playing a resource is provided, comprising:
[0005] When a page of a first application is opened, automatically playing a first resource according to a first element in the page, the first resource being a resource used to trigger an automatic play function of the page;
[0006] Modify the address of the first resource corresponding to the first element to the address of the second resource, where the second resource is the target resource that needs to be automatically played in the page;
[0007] The second resource is played according to the address of the second resource.
[0008] According to another aspect of the present disclosure, there is provided a resource automatic playback device, comprising:
[0009] A first playback module, configured to automatically play a first resource according to a first element in a page of a first application when the page is opened, wherein the first resource is a resource for triggering an automatic playback function of the page;
[0010] An address modification module, used for modifying the address of a first resource corresponding to the first element into an address of a second resource, where the second resource is a target resource in the page that needs to be automatically played;
[0011] The second playing module is used to play the second resource according to the address of the second resource.
[0012] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any embodiment of the present disclosure.
[0016] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to any embodiment of the present disclosure.
[0017] According to another aspect of the present disclosure, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method according to any one of the embodiments of the present disclosure is implemented.
[0018] According to an embodiment of the present disclosure, the first resource is automatically played through the first element in the page of the first application, and then the resource address corresponding to the first element is modified to the address of the second resource to be played, so that the second resource can be automatically played in the first application of the operating system that originally cannot be automatically played.
[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0021] Figure 1 is a flowchart of a method for automatically playing resources according to an embodiment of the present disclosure;
[0022] Figure 2 is a flowchart of a method for automatically playing resources according to another embodiment of the present disclosure;
[0023] Figure 3 is a flowchart of a method for automatically playing resources according to another embodiment of the present disclosure;
[0024] Figure 4 is a structural diagram of a resource automatic playback device according to an embodiment of the present disclosure;
[0025] Figure 5 is a structural diagram of a resource automatic playback device according to another embodiment of the present disclosure;
[0026] Figure 6 This is a schematic diagram of the effect of guiding a user to click to play audio in the related art;
[0027] Figure 7 is a schematic diagram of an automatic audio playback process according to an embodiment of the present disclosure;
[0028] Figure 8 is a schematic diagram of the effect of automatically playing audio according to an embodiment of the present disclosure;
[0029] Fig. 9 It is a block diagram of an electronic device used to implement the resource automatic playback method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0031] Figure 1 1 is a flow chart of a method for automatically playing resources according to an embodiment of the present disclosure. The method for automatically playing resources may include:
[0032] S101. When a page of a first application is opened, automatically play a first resource according to a first element in the page, where the first resource is a resource used to trigger an automatic play function of the page;
[0033] S102: modify the address of the first resource corresponding to the first element to the address of the second resource, where the second resource is the target resource that needs to be automatically played in the page;
[0034] S103: Play the second resource according to the address of the second resource.
[0035] In the disclosed embodiment, the method can be used in terminal devices such as smart phones, smart watches, and handheld computers. In some operating systems, the browser page of the application cannot automatically play multimedia resources such as audio and video. For example, in the iOS system, the H5 page of the WeChat browser cannot automatically play multimedia resources such as audio and video. In the page of the application of the system, an element for automatically playing resources, i.e., a first element, can be set. The first element in the embodiment of the present application can also be a first tag. The first application can be an application with certain functions installed in the terminal device. For example, an application with functions such as social, shopping, or games. When the page of the first application is opened, the first element in the page can be loaded, and the address of the first resource included in the first element can be obtained. The first resource is loaded and automatically played according to the address of the first resource. Playing the first resource can trigger subsequent automatic playback of other resources. After the first resource is played, the address of the first resource in the resource (src) attribute of the first element can be modified to require automatic playback of the second resource. Then, the second resource is loaded and automatically played according to the address of the second resource. The first resource is automatically played first through the first element in the page of the first application, and then the resource address corresponding to the first element is modified to the address of the second resource to be played, so that the second resource that can be automatically played can be realized in the first application of the operating system that cannot be automatically played. The scheme of the embodiment of the present application can be used in a variety of scenarios, such as learning playback scenarios, follow-up reading scenarios, etc. For example, in the learning playback scenario, an audio element for triggering automatic playback can be added to the page where the user wants to open his or her learning record, so that when the page is opened, the words, sentences, picture books, etc. that you have read can be automatically played. For example, in the follow-up reading scenario, an audio element for triggering automatic playback can be added to the follow-up reading page of pinyin, words, texts, etc., so that when the page is opened, the pinyin, words, texts, etc. that you have read can be automatically played.
[0036] Figure 2 1 is a flow chart of a method for automatically playing resources according to another embodiment of the present disclosure. The method of this embodiment includes one or more features of the above-mentioned method for automatically playing resources. In a possible implementation, in S101, automatically playing the first resource according to the first element in the page includes:
[0037] S201, using an event listener to listen to a target browser event of the page of the first application;
[0038] S202, obtaining the first object of the first element in the callback function of the target browser event;
[0039] S203: Call the play method of the first object to trigger automatic play of the first resource corresponding to the first element.
[0040] In an embodiment of the present disclosure, the page of the first application may be a browser page of the first application. The browser page of the first application has an event listener that can listen to browser events of the browser page of the first application. If the event listener listens to a target browser event related to the first element, the first object of the first element can be obtained in the callback function of the target browser event. Then, the play method of the first object is called to automatically load the first resource from the address of the first resource corresponding to the first element, thereby automatically playing the first resource. By listening to the target browser event of the opened page of the first application, the first resource corresponding to the first element associated with the target browser event can be automatically played.
[0041] In a possible implementation, the first element is an audio element, the first resource is a silent audio resource, and the method further includes:
[0042] The audio element is added to the HyperText Markup Language (HTML) code of the page of the first application, and the resource attribute of the audio element is set to the address of the silent audio resource.
[0043] In the embodiments of the present disclosure, the silent audio resource may be played by triggering the audio element, without user perception, thereby improving the user experience.
[0044] In a possible implementation, the event listener is a document adding event listener, the target browser event is a first application bridge preparation event, and the first object is a Document Object Model (DOM) object. For example, the document adding event listener can be document.addEventListener. The first application is WeChat, and the first application bridge preparation event can be a WeixinJSBridgeReady event. The WeixinJSBridgeReady event is a WeChat browser event. Through the above event monitoring process, the automatic playback of silent audio resources can be achieved with the help of the WeChat Software Development Kit (SDK) encapsulation method.
[0045] In a possible implementation, in S201, using an event listener to listen to a target browser event of the first application includes: using a document to add an event listener to listen to a bridge preparation event of the first application.
[0046] In a possible implementation, in S202, obtaining the first object of the first element in the callback function of the target browser event includes: obtaining the DOM object of the audio element through a scripting language (JavaScript, JS) in the callback function of the first application bridge preparation event. JavaScript is a lightweight, interpreted or just-in-time compiled programming language with function priority.
[0047] In a possible implementation, in S203, calling the play method of the first object to trigger automatic play of the first resource corresponding to the first element includes: calling the play method of the DOM object to trigger automatic play of the silent audio resource corresponding to the audio element.
[0048] For example, use the document to add an event listener document.addEventListener to listen to the WeixinJSBridgeReady event. In the callback function of the WeixinJSBridgeReady event, the DOM object of the audio (Audio) element is obtained through JS, and the play (play) method of the DOM object is called to trigger the playback of the Audio element. If the audio resource corresponding to the Audio element is silent, the user will not perceive the playback of the audio resource. The audio resource corresponding to the Audio element can be an audio resource that occupies less space, such as mp3, which is conducive to making the playback faster and smoother. The first application is WeChat, which is only an example and not a limitation. In actual applications, it can also be other applications that need to realize automatic playback of multimedia resources such as audio and video, such as other applications that have performed some optimization processing on audio and video playback.
[0049] By adding an event listener to the document to listen to the first application bridge preparation event of the opened page of the first application, the silent audio resource corresponding to the audio element associated with the first application bridge preparation event can be automatically played, and then the second resource that needs to be played later can be automatically played.
[0050] In a possible implementation, Figure 3 As shown, triggering the automatic playing of the silent audio resource corresponding to the audio element includes: S301, triggering the playing of the silent audio resource according to the address of the silent audio resource corresponding to the audio element.
[0051] In an embodiment of the present disclosure, the resource attribute of an audio element may include the address of a resource corresponding to the audio element, such as the address of a silent audio resource. The address of the silent audio resource may be in the form of a uniform resource locator (URL) or the like. When the play method of the DOM object of the audio element is called, the silent audio resource is loaded according to the resource address in the resource attribute of the audio element, and the silent audio resource is triggered to be automatically played. In this way, the playback of the silent audio resource corresponding to the audio element can be triggered without the user's perception, and then the second resource that needs to be played later can be automatically played.
[0052] In a possible implementation, the page is an HTML5 page, and the second resource is a target resource that needs to be automatically played. In S102, the address of the first resource corresponding to the first element is modified to the address of the second resource, including:
[0053] S302: When the silent audio resource has finished playing, the address of the silent audio resource in the resource attribute of the audio element is dynamically modified by using JS to the address of the target resource that needs to be automatically played on the HTML5 page.
[0054] In an embodiment of the present disclosure, in the initial state when the browser page of the first application is opened, the resource attribute of the audio element may include the address of a silent audio resource. After the first application finishes playing the silent audio resource, the resource attribute of the audio element may be dynamically modified to the address of a target resource in the HTML5 page that needs to be automatically played. The target resource may be a multimedia resource such as an audio resource or a video resource. There may be multiple ways to determine the target resource. For example, determine whether it is a target resource based on the position of the resource in the HTML5 page. The target resource may be a resource in a certain area of the HTML5 page of the first application. For example, if the top of a resource reaches the middle position of the HTML5 page, the resource may be the target resource. For another example, if the bottom of a resource reaches the bottom position of the HTML5 page, the resource may be the target resource. By dynamically modifying the resource address in the resource attribute of the audio element, the target resource in the HTML5 page may be automatically played.
[0055] In a possible implementation, in S103, playing the second resource according to the address of the second resource includes: S303, triggering the playing of the target resource according to the modified address of the target resource corresponding to the audio element. According to the resource address in the resource attribute of the dynamically modified audio element, the target resource can be automatically loaded and played.
[0056] In a possible implementation, the resource automatic playback method further includes:
[0057] In response to a recording command, opening a microphone to input a user audio resource;
[0058] The user audio resource is compared with the second resource to obtain a comparison result.
[0059] In some application scenarios, after the second resource is automatically played, the user audio resource can be obtained according to the user's operation, such as clicking a microphone icon, turning on the microphone of the terminal device, recording the user's voice, etc.
[0060] For example, in the scenario of following along with words, pinyin or texts, after automatically playing the second resource such as the words, pinyin or texts that need to be followed, you can wait for the user to turn on the microphone. If the user clicks the microphone icon, a recording command can be generated and the microphone can be turned on. The user voice picked up by the microphone is compared with the second resource, and the comparison result obtained may include a similarity score, etc. After the comparison is completed, other resources that need to be followed can continue to be played in addition to the second resource, or the automatic playback process can be ended. If the user does not turn on the microphone after automatically playing the second resource that needs to be followed, the automatic playback process can be ended; the prompt voice can also be automatically played, the second resource can be repeatedly played, or other resources that need to be followed can be automatically played in addition to the second resource.
[0061] In the embodiments of the present disclosure, by inputting user audio resources through a microphone, richer application scenarios such as follow-up reading scenarios can be supported. In the follow-up reading scenarios, the pages that require follow-up reading can support automatic playback of the content that requires follow-up reading.
[0062] In a possible implementation, the resource automatic playback method further includes:
[0063] Modify the address of the second resource corresponding to the first element to the address of the third resource, where the third resource is a target resource in the page that needs to be automatically played after the second resource is played;
[0064] The third resource is played according to the address of the third resource.
[0065] In the disclosed embodiment, if the second resource corresponds to the first target resource, the third resource corresponds to the second target resource. After the first target resource is played, JS can also be used to dynamically modify the address of the first target resource in the resource attribute of the audio element to the address of the second target resource that needs to be automatically played on the HTML5 page. Then, according to the resource address in the resource attribute of the audio element after dynamic modification, the target resources required in the HTML5 page can be flexibly and automatically played. Specifically, the third resource that needs to be played after the second resource can be determined according to the business logic. After playing the third resource, it can also be determined whether to continue playing other resources according to the business logic. The embodiment of the present application does not limit the specific number of resources that are automatically played continuously, and can be flexibly determined according to actual business needs. In this way, continuous automatic playback of resources can be achieved, which is suitable for richer business scenarios.
[0066] In a possible implementation, in S101, when a page of a first application is opened, automatically playing a first resource according to a first element in the page includes:
[0067] In the case where there are multiple first elements in the page, the play method of the first object of each first element is called respectively to trigger the automatic play of the first resource corresponding to each first element.
[0068] In some examples, a browser page may need to automatically play multiple audio resources. For example, while playing background music, play the learning content that needs to be played back. In this scenario, multiple audio elements for triggering automatic audio playback can be set on the page. For example, the first audio element and the second audio element. The address of the first audio element and the second audio element can be the address of a silent audio resource. If the addresses of the silent audio resources of the two are the same, the two can use the same silent audio resource to trigger automatic playback. If the addresses of the silent audio resources of the two are the same, the two can also use different silent audio resources to trigger automatic playback. Use an event listener to listen to the target browser event of the page of the first application; in the callback function of the target browser event, obtain the DOM object of the first audio element and the DOM object of the second audio element respectively. Call the play method of the DOM object of the first audio element and the second audio element respectively to trigger the automatic playback of the silent audio resources corresponding to the first audio element and the second audio element respectively. Then modify the resource attributes of the first audio element and the second audio element to the addresses of their respective target resources, and automatically play the target resource corresponding to the first audio element and the target resource corresponding to the second audio element. Multiple audio elements on the page can be used to automatically play multiple audio resources at the same time, which can be applied to a wider range of business scenarios.
[0069] Figure 4It is a structural schematic diagram of a resource automatic playback device according to an embodiment of the present disclosure. The resource automatic playback device may include: a first playback module 401, which is used to automatically play a first resource according to a first element in a page of a first application when the page is opened, and the first resource is a resource used to trigger the automatic playback function of the page; an address modification module 402, which is used to modify the address of the first resource corresponding to the first element to the address of a second resource, and the second resource is a target resource in the page that needs to be automatically played; a second playback module 403, which is used to play the second resource according to the address of the second resource.
[0070] Figure 5 4 is a schematic diagram of the structure of a resource automatic playback device according to another embodiment of the present disclosure. The device of this embodiment includes one or more features of the above-mentioned resource automatic playback device embodiment. In a possible implementation, the first playback module 401 also includes:
[0071] A monitoring submodule 501 is used to monitor target browser events of the page of the first application using an event listener;
[0072] An acquisition submodule 502 is used to acquire the first object of the first element in the callback function of the target browser event;
[0073] The playing submodule 503 is used to call the playing device of the first object to trigger the automatic playing of the first resource corresponding to the first element.
[0074] In a possible implementation, the first element is an audio element, the first resource is a silent audio resource, and the device further includes: an adding module for adding the audio element to the hypertext markup language HTML code of the page of the first application, and setting the resource attribute of the audio element to the address of the silent audio resource.
[0075] In a possible implementation, the event listener is a document adding event listener, the target browser event is a first application bridge preparation event, and the first object is a document object model DOM object;
[0076] The monitoring submodule 501 is used to use a document adding event listener to monitor the first application bridge preparation event;
[0077] The acquisition submodule 502 is used to acquire the DOM object of the audio element through the scripting language JS in the callback function of the first application bridge preparation event;
[0078] The playing submodule 503 is used to call the playing device of the DOM object to trigger the automatic playing of the silent audio resource corresponding to the audio element.
[0079] In a possible implementation, the playing submodule 503 is further configured to trigger playing of the silent audio resource according to the address of the silent audio resource corresponding to the audio element.
[0080] In a possible implementation, the page is a fifth-generation hypertext markup language HTML5 page, the second resource is a target resource that needs to be played automatically, and the address modification module 402 is used to dynamically modify the address of the silent audio resource in the resource attributes of the audio element to the address of the target resource that needs to be played automatically on the HTML5 page using JS when the silent audio resource has been played.
[0081] In a possible implementation, the second playing module 403 is used to trigger playing of the target resource according to the modified address of the target resource corresponding to the audio element.
[0082] In a possible implementation, the device further includes:
[0083] The recording module 404 is used to open the microphone to input the user audio resource in response to the recording command;
[0084] The comparison module 405 is used to compare the user audio resource with the second resource to obtain a comparison result.
[0085] In a possible implementation, the address modification module 402 is further used to modify the address of the second resource corresponding to the first element to the address of a third resource, where the third resource is a target resource in the page that needs to be automatically played after the second resource is played;
[0086] In a possible implementation manner, the device further includes: a third playing module 406, configured to play the third resource according to the address of the third resource.
[0087] In a possible implementation, the first playback module is further used to, when there are multiple first elements in the page, respectively call the playback method of the first object of each first element to trigger automatic playback of the first resource corresponding to each first element.
[0088] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0089] In some operating systems such as iOS, automatic audio playback is not allowed in some applications such as WeChat browsers based on factors such as user traffic. In addition, the types of audio files are diverse, including mp3, wav, ogg, etc. Different browsers have different compatible audio file formats. Therefore, it is difficult to achieve automatic playback of audio files and compatibility with audio files of various formats in the browsers of some applications.
[0090] In the related art, usually in the H5 page that needs to play audio automatically, an audio file with better compatibility is used, and after the user opens the page, it is necessary to guide the user to actively click on the page once to trigger the playback of HTML audio (Audio), such as Figure 6 shown.
[0091] The solution of the embodiment of the present disclosure can realize the automatic playback function of the audio on the H5 page where the audio needs to be played, without the user clicking on the page, which has a better user experience effect. In addition, an audio file in the MP3 format or other small space-consuming audio file can be used as a resource to trigger the automatic playback.
[0092] In one application scenario, in the WeChat browser environment of the iOS system, an HTML5 audio (Audio) element is created when the page is initialized. After the page is loaded, that is, after the WeixinJSBridgeReady event is triggered, the pre-created HTML5 Audio element is used to call the Audio element method through JS to first play a silent and small mp3 audio file. Then the Audio element is used to play the mp3 file that needs to be automatically played on the H5 page. This method can achieve the effect of automatically playing audio on the H5 page in the WeChat browser environment of the iOS system.
[0093] like Figure 7As shown, in the disclosed embodiment, an automatic audio playback process may include: adding an Audio element to an HTML page, and the initial resource (src) of the Audio element may be a silent and small mp3 resource address. In JS, the WeixinJSBridgeReady (abbreviated as WXReady) event of the Audio element is monitored. In the WeixinJSBridgeReady event callback, the DOM object of the Audio element is obtained through JS, and the play method of the DOM object is called to trigger the playback of the Audio element once. Because the resource (src) attribute of the Audio element at this time specifies a silent audio file, the user is completely unaware during the entire playback process. It is equivalent to using a silent mp3 audio file (audio resource 1) to activate the automatic playback function of the Audio element, and then using JS to dynamically change the src attribute of the Audio element to the address of the mp3 audio file (audio resource 2) that needs to be automatically played for normal business.
[0094] This process can be achieved through the following parts:
[0095] HTML5 Audio element initialization: Add an audio tag to the HTML code of the page to ensure that the Audio is initialized normally when the page is rendered. At the same time, set the src attribute of the audio tag to a silent audio resource in mp3 format.
[0096] HTML5 Audio element plays silent audio: In the callback function of the WeixinJSBridgeReady event on the page, get the DOM object of the Audio element through JS, call the play method of the DOM object, and trigger the playback of the Audio element. Because the mp3 audio resource is silent, the user will not feel the audio playing.
[0097] HTML5 Audio element plays the actual audio: After the Audio element finishes playing the muted MP3 audio resource, use JS to dynamically modify the src attribute of the Audio element to the MP3 audio address that the H5 page actually needs to play automatically, so as to achieve the effect of automatic audio playback.
[0098] and Figure 6 different, Figure 8 The playback process of a user opening a page and playing audio using the method of an embodiment of the present disclosure is demonstrated.
[0099] In an embodiment of the present disclosure, a method for playing audio using HTML5 Audio is provided. An Audio element is used to initially play a silent and small-sized mp3 audio file, and then the Audio element is used to play the mp3 audio file that needs to be played automatically.
[0100] In the embodiments of the present disclosure, it can be combined with web page parsing and rendering technology to parse and render file formats such as HTML, HTML5, JS, CSS, pictures, text, audio and video, and animation based on W3C standards.
[0101] The solution of the disclosed embodiment can be used in the WeChat browser environment, for example, and in the WeChat browser environment, HTML5 Audio is used to realize automatic playback of mp3 audio. For example, by first using the HTML5Audio element to play a silent and small mp3 audio file, and then using the HTML5Audio element to play the real mp3 audio file that needs to be automatically played, the effect of automatically playing mp3 audio on the H5 page in the iOS system WeChat browser environment is indirectly realized.
[0102] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0103] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0104] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0105] like Fig. 9 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0106] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0107] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as the automatic resource playback method. For example, in some embodiments, the automatic resource playback method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the automatic resource playback method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the automatic resource playback method in any other appropriate manner (e.g., by means of firmware).
[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0109] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0110] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0111] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0112] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0113] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0114] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0115] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A resource automatic playback method, comprising: When a page of a first application is opened, a first element in the page is loaded, and an address of a first resource included in the first element is obtained, so as to load and automatically play the first resource according to the address of the first element in the page, wherein the first resource is a resource for triggering an automatic play function of the page; wherein the first resource is a silent audio resource; Modify the address of the first resource corresponding to the first element to the address of the second resource that needs to be automatically played, where the second resource is a target resource that needs to be automatically played in the page; wherein the target resource includes a resource in a specified area of the page; Loading and automatically playing the second resource according to the address of the second resource; Modify the address of the second resource corresponding to the first element to the address of the third resource, where the third resource is a target resource in the page that needs to be automatically played after the second resource is played; Play the third resource according to the address of the third resource; The method of loading and automatically playing the first resource according to the address of the first element in the page includes: using an event listener to listen to a target browser event of the page of the first application; obtaining a first object of the first element in a callback function of the target browser event; calling a play method of the first object to automatically load the first resource from the address of the first resource corresponding to the first element, so as to trigger automatic play of the first resource corresponding to the first element; Wherein, the event listener is a document adding event listener, the target browser event is a first application bridge preparation event, the first object is a document object model DOM object, and the first element is an audio element; Using an event listener to listen to a target browser event of the first application includes: using a document to add an event listener to listen to a bridge preparation event of the first application; Acquiring the first object of the first element in the callback function of the target browser event includes: acquiring the DOM object of the audio element by using the scripting language JS in the callback function of the first application bridge preparation event; Calling the play method of the first object to trigger automatic play of the first resource corresponding to the first element includes: calling the play method of the DOM object to trigger automatic play of the silent audio resource corresponding to the audio element.
2. The resource automatic playback method according to claim 1, further comprising: The audio element is added to the hypertext markup language HTML code of the page of the first application, and the resource attribute of the audio element is set to the address of the silent audio resource.
3. The resource automatic playback method according to claim 1, wherein: Triggering automatic playback of the silent audio resource corresponding to the audio element, including: According to the address of the silent audio resource corresponding to the audio element, the playing of the silent audio resource is triggered.
4. The resource automatic playback method according to claim 2 or 3, wherein: The page is a fifth generation Hypertext Markup Language HTML5 page, the second resource is a target resource that needs to be automatically played, and the address of the first resource corresponding to the first element is modified to the address of the second resource, including: When the silent audio resource has finished playing, JS is used to dynamically modify the address of the silent audio resource in the resource attribute of the audio element to the address of the target resource that needs to be automatically played on the HTML5 page.
5. The resource automatic playback method according to any one of claims 1 to 3, further comprising: In response to a recording command, opening a microphone to input a user audio resource; The user audio resource is compared with the second resource to obtain a comparison result.
6. The resource automatic playback method according to any one of claims 1 to 3, wherein when a page of a first application is opened, the first resource is automatically played according to the first element in the page, comprising: In the case where there are multiple first elements in the page, the play method of the first object of each first element is called respectively to trigger automatic play of the first resource corresponding to each first element.
7. A resource automatic playback device, comprising: A first playing module is used to load a first element in a page of a first application when the page is opened, obtain an address of a first resource included in the first element, and automatically play the first resource according to the first element in the page, wherein the first resource is a resource for triggering an automatic play function of the page; wherein the first resource is a silent audio resource; an address modification module, used to modify the address of the first resource corresponding to the first element to the address of the second resource that needs to be automatically played, wherein the second resource is a target resource that needs to be automatically played in the page; wherein the target resource includes a resource in a specified area of the page; A second playing module, used for loading and automatically playing the second resource according to the address of the second resource; The address modification module is further used to modify the address of the second resource corresponding to the first element to the address of a third resource, where the third resource is a target resource in the page that needs to be automatically played after the second resource is played; The device further includes: a third playing module, configured to play the third resource according to the address of the third resource; Wherein, the first playing module further includes: A monitoring submodule, used for monitoring target browser events of the page of the first application using an event listener; An acquisition submodule, used for acquiring the first object of the first element in the callback function of the target browser event; a playing submodule, configured to call a playing device of the first object, and automatically load the first resource from the address of the first resource corresponding to the first element, so as to trigger automatic playing of the first resource corresponding to the first element; Wherein, the event listener is a document adding event listener, the target browser event is a first application bridge preparation event, the first object is a document object model DOM object, and the first element is an audio element; The monitoring submodule is further used to use a document to add an event listener to monitor the first application bridge preparation event; The acquisition submodule is further used to acquire the DOM object of the audio element by using the scripting language JS in the callback function of the first application bridge preparation event; The playing submodule is further used to call the playing device of the DOM object to trigger the automatic playing of the silent audio resource corresponding to the audio element.
8. The resource automatic playback device according to claim 7, further comprising: An adding module is used to add the audio element in the hypertext markup language HTML code of the page of the first application, and set the resource attribute of the audio element to the address of the silent audio resource.
9. The resource automatic playback device according to claim 7, wherein: The playing submodule is further used to trigger the playing of the silent audio resource according to the address of the silent audio resource corresponding to the audio element.
10. The automatic resource playback device according to claim 8 or 9, wherein: The page is a fifth-generation hypertext markup language HTML5 page, the second resource is a target resource that needs to be played automatically, and the address modification module is used to use JS to dynamically modify the address of the silent audio resource in the resource attributes of the audio element to the address of the target resource that needs to be played automatically on the HTML5 page after the silent audio resource has been played.
11. The resource automatic playback device according to any one of claims 7 to 9, further comprising: A recording module, configured to open a microphone in response to a recording command to input a user audio resource; A comparison module is used to compare the user audio resource with the second resource to obtain a comparison result.
12. According to the automatic resource playback device according to any one of claims 7 to 9, the first playback module is also used to call the playback method of the first object of each first element respectively when there are multiple first elements in the page, so as to trigger the automatic playback of the first resource corresponding to each first element.
13. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.
15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.