An audio playing method, device, equipment, medium and product

By creating different page player objects based on the system type within an H5 application nested in WebView, the problem of poor audio playback compatibility was solved, enabling normal audio playback on both iOS and Android systems and improving the uniformity and stability of audio playback.

CN119620998BActive Publication Date: 2026-02-27AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411676404.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2026-02-27
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In H5 applications nested within WebView, audio playback suffers from poor compatibility across different mobile operating system versions, resulting in inconsistent playback effects, particularly on iOS and Android systems.

Method used

By obtaining the system type corresponding to the audio player, a targeted target page player object is created, and audio is played based on these objects. This includes creating an audio tag for the iOS system and listening to the loadedmetadata event, and creating an audioContext instance for the Android system and processing the audio header node to achieve audio source splicing and playback.

Benefits of technology

This solves the problem of poor audio playback compatibility in H5 applications nested in WebView, ensuring that audio can be played normally on different operating systems, thus improving the consistency and stability of audio playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119620998B_ABST
    Figure CN119620998B_ABST
Patent Text Reader

Abstract

The application discloses an audio playing method, device, equipment, medium and product. The method comprises the following steps: acquiring a system type corresponding to an audio player; creating a target page player object according to the system type, and playing to-be-played audio based on the target page player object. Through the technical scheme of the application, the technical problem of poor playing compatibility of audio played through an audio tag in a H5 mobile terminal application nested by WebView for different operating systems can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of audio playback technology, and in particular to an audio playback method, apparatus, device, medium and product. Background Technology

[0002] With the development of data and wireless network technologies, mobile devices have become indispensable, and audio and video playback has permeated all aspects of technological life, including new media, digital humans, and the metaverse. Furthermore, because the mini-program model offers users a more convenient experience, integrating mini-programs into major apps has become the mainstream app operation mode. Therefore, embedding H5 (Hypertext Markup Language 5) applications within WebView (a component used to display web page content within an application, allowing developers to embed a complete web browser function within their application) has also become a mainstream development model.

[0003] However, this development model, which primarily uses the `audio` tag (used to embed audio content in H5, supporting playback of various audio file formats such as mp3 and wav) to achieve audio playback, suffers from poor compatibility. For mini-program applications integrated into various apps, i.e., H5 applications nested in WebView, audio playback exhibits drastically different phenomena across different mobile operating system versions: for iOS (iPhone Operating System), some versions only play the audio once, while others play it normally; for Android, some versions fail to play the audio, while others play it normally. Audio playback is an indispensable part of fields such as artificial intelligence, including speech synthesis and voice question answering. Therefore, there is an urgent need for an audio playback method for H5 applications nested in WebView to solve these problems. Summary of the Invention

[0004] This invention provides an audio playback method, apparatus, device, medium, and product to solve the technical problem of poor playback compatibility when playing audio via the audio tag across different operating systems in H5 mobile applications nested within WebView.

[0005] According to one aspect of the present invention, an audio playback method is provided, comprising:

[0006] Get the system type corresponding to the audio player;

[0007] Create a target page player object based on the system type, and play the audio to be played based on the target page player object.

[0008] In some embodiments of the present invention, creating a target page player object according to the system type and playing audio to be played based on the target page player object includes:

[0009] If the system type is the first operating system, then create a first page player object and set a listener event for the first page player object. When the listener detects that the audio to be played has finished loading, play the audio to be played.

[0010] If the system type is a second operating system, then a second page player object is created, and an audio header node is created for the second page player object. The audio to be played is decoded and concatenated to the audio header node to obtain the audio source, and the audio source is played.

[0011] In some embodiments of the present invention, after creating the first page player object, the method further includes:

[0012] Obtain the audio to be played, and obtain the source type of the audio to be played;

[0013] If the source type of the audio to be played is a local audio file, then the audio to be played is introduced into the playback page, and the audio to be played is assigned to the target attribute of the first page player object;

[0014] If the source type of the audio to be played is a downloaded audio stream, then the audio to be played is converted into target data, and a downloadable link is created based on the target data. The downloadable link is then assigned to the target attribute of the first page player object.

[0015] In some embodiments of the present invention, a second page player object is created, and an audio header node is created for the second page player object. The audio to be played is decoded and concatenated to the audio header node to obtain an audio source. Playing the audio source includes:

[0016] Create a second page player object, and create an audio head node and an audio tail node for the second page player object;

[0017] Obtain the audio to be played and convert it into a target object;

[0018] The target object is decoded, and the decoded data is concatenated to the audio header node;

[0019] Connect the audio header node and the audio tail node to obtain the audio source, and then play the audio source.

[0020] In some embodiments of the present invention, obtaining the audio to be played includes:

[0021] If the source type of the audio to be played is a local audio file, then the audio to be played is imported, and the audio stream is obtained through the target request;

[0022] If the source type of the audio to be played is a downloaded audio stream, then the audio stream is obtained through the target request.

[0023] In some embodiments of the present invention, after creating the first page player object, the method further includes:

[0024] Set the control properties of the player object on the first page and display the audio control panel.

[0025] According to another aspect of the present invention, an audio playback device is provided, the device comprising:

[0026] The acquisition module is used to obtain the system type corresponding to the audio player;

[0027] The creation and playback module is used to create a target page player object according to the system type, and play the audio to be played based on the target page player object.

[0028] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0029] At least one processor; and

[0030] A memory communicatively connected to the at least one processor; wherein,

[0031] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the audio playback method according to any embodiment of the present invention.

[0032] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the audio playback method according to any embodiment of the present invention.

[0033] According to another aspect of the present invention, embodiments of the present invention also provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the audio playback method described in any embodiment of the present invention.

[0034] This invention, through its embodiments, obtains the system type corresponding to the audio player, creates a target page player object based on the system type, and plays the audio to be played based on the target page player object. This technical solution solves the problem of poor playback compatibility when playing audio via the `audio` tag across different operating systems in H5 mobile applications nested within WebView.

[0035] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0036] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 This is a flowchart of an audio playback method according to an embodiment of the present invention;

[0038] Figure 2 This is a schematic diagram of the structure of an audio playback device according to an embodiment of the present invention;

[0039] Figure 3 This is a schematic diagram of the structure of an electronic device that implements the audio playback method of this invention. Detailed Implementation

[0040] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and their derivatives, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0042] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0043] Example 1

[0044] Figure 1 This is a flowchart of an audio playback method according to an embodiment of the present invention. This embodiment is applicable to audio playback situations. The method can be executed by the audio playback device in this embodiment of the present invention, which can be implemented in software and / or hardware, such as... Figure 1 As shown, the method specifically includes the following steps:

[0045] S101. Obtain the system type corresponding to the audio player.

[0046] In this embodiment, the audio player can be, for example, the audio player of an H5 mobile application nested in a WebView, that is, the audio player of a mini-program application integrated in various apps.

[0047] For example, system types can be divided into iOS and Android systems. In actual operation, the H5 application needs to first determine whether the container is currently in an iOS or Android system environment. For different system types, this embodiment of the invention adopts different audio playback methods.

[0048] S102. Create a target page player object according to the system type, and play the audio to be played based on the target page player object.

[0049] In this embodiment, the target page player object can be an object created on the H5 page for successful audio playback. For example, for iOS systems, to achieve audio playback, an `audio` tag needs to be created on the H5 page; this `audio` tag is the target page player object for iOS. For Android systems, to achieve audio playback, an `audioContext` instance needs to be created on the H5 page (the core of the Web Audio API, providing an interface for audio processing and playback, capable of creating and connecting various audio sources, processors, and outputs. The Web Audio API is a powerful web standard for processing and synthesizing audio on web pages, providing advanced, cross-platform audio processing capabilities, allowing developers to implement complex audio effects in the browser, such as mixing, sound effects processing, and audio analysis). This `audioContext` instance is the target page player object for Android systems.

[0050] The audio to be played can be audio data selected by the user for playback. For example, the audio to be played can be a local audio file or an audio stream downloaded from the server.

[0051] Specifically, for different system types, different page player objects are created, and the audio to be played is played based on the created target page player object to complete the audio playback operation.

[0052] This invention, through its embodiments, obtains the system type corresponding to the audio player, creates a target page player object based on the system type, and plays the audio to be played based on the target page player object. This technical solution solves the problem of poor playback compatibility when playing audio via the `audio` tag across different operating systems in H5 mobile applications nested within WebView.

[0053] Optionally, a target page player object is created based on the system type, and the audio to be played is played based on the target page player object, including:

[0054] If the system type is the first operating system, then create a first page player object and set a listener event for the first page player object. When the listener detects that the audio to be played has finished loading, play the audio to be played.

[0055] In this embodiment, the first operating system can be the iOS system, and the first page player object can be the audio tag.

[0056] It's important to note that the listener event can be the `loadedmetadata` event, used to monitor whether the audio to be played has finished loading. It's worth noting that the `loadedmetadata` event is typically used in web development in conjunction with... <video>and <audio>The element is associated with this event when the media data has finished loading and is ready to be played. This means that all of the media file's data has been loaded and can be rendered for playback, but it is not necessarily required to play the entire media file.

[0057] In the embodiment, the loading and playing of the audio object is a crucial step for the audio to be normally played in the iOS system. First, an event listening to the loadedmetadata event of the audio object is added to the audio object, and then the load method of the audio object is executed to load the audio object. Once the loadedmetadata event is listened to, the play method of the audio object is executed to play the audio object. Thus, the audio file of the H5 application based on WebView nesting in the iOS system can be normally played.

[0058] Specifically, for the iOS system, an audio tag is created in H5 and an audio source is specified. Then, an event listening to the loadedmetadata event of the audio tag is added to the audio tag. After the audio tag acquires the audio source, the source file is loaded first, and then the source file is played after the loading of the source file is listened to, so that the playing problem of the iOS can be solved.

[0059] If the system type is the second operating system, a second page player object is created, an audio head node is created for the second page player object, an audio source is obtained by concatenating the decoded audio to be played to the audio head node, and the audio source is played.

[0060] In the embodiment, the second operating system can be an Android system, and the second page player object can be an audioContext instance.

[0061] It can be known that in the Web Audio API, the audio head node is the starting point of the entire audio processing graph, which represents an audio processing context. The audio head node is responsible for controlling the clock of the audio, the creation and connection of the node, and the rendering of the audio.

[0062] The audio source can be an audio source obtained by concatenating the audio data obtained by decoding the audio to be played to the audio head node.

[0063] Specifically, for the Android system, first create an audioContext instance in H5, create an audio header node for this instance, then convert the obtained audio stream (i.e. the audio to be played) into an arrayBuffer object and decode it into the audio data type corresponding to the audioContext, then mount the audio data to the audio source, and finally connect the audio header and footer nodes to drive the hardware for playback, which can solve the playback problem of the Android system.

[0064] Optionally, after creating the first page player object, the following may also be included:

[0065] Get the audio to be played, and get the source type of the audio to be played.

[0066] It should be noted that the source type can refer to whether the audio to be played is a local audio file or an audio stream downloaded from the server.

[0067] If the source type of the audio to be played is a local audio file, then the audio to be played is imported into the playback page, and the audio to be played is assigned to the target property of the player object on the first page.

[0068] The local audio file can be an audio data file stored on a local device (such as a smartphone, computer, or other smart device). In this embodiment, the playback page can specifically be an H5 page.

[0069] It should be explained that the target attribute in this embodiment can specifically be the src attribute. As is known, the src attribute is a commonly used attribute in HTML and web development to specify the URL (Uniform Resource Locator) address of an external resource. This attribute can be used in various HTML tags to include or reference external resources.

[0070] Specifically, if the source type of the audio to be played is a local audio file, you need to first import this file in the H5 page, and then assign it to the src attribute of the audio object. It is worth noting that if you directly assign the relative or absolute path of this audio file to src, you may encounter an error when loading this file because it cannot find a usable source file.

[0071] If the source type of the audio to be played is a downloaded audio stream, then the audio to be played is converted into target data, and a downloadable link is created based on the target data. The downloadable link is then assigned to the target property of the first page player object.

[0072] It should be noted that the downloaded audio stream can be an audio stream downloaded from the server. In this embodiment, the target data can be Blob (Binary Large Object) data. Blob data is a data type used to represent binary files and is widely used in web development to process non-text data, such as images, videos, and audio files. The downloadable link can be a link that allows downloading the audio to be played.

[0073] Specifically, if the audio to be played is an audio stream downloaded from the server, the audio stream needs to be converted into Blob data. Then, a downloadable link is created for the window object based on this Blob data, and the download link is assigned to the src attribute. To facilitate the network transmission of multimedia data, sometimes the server needs to base64 encode the data stream. After the H5 application obtains the base64 data, it first decodes the base64 data, then converts it back into Blob data and performs a series of subsequent operations.

[0074] Optionally, create a second-page player object and an audio header node for it. Decode the audio to be played and append it to the audio header node to obtain the audio source. Play the audio source, including:

[0075] Create a second page player object, and create an audio head node and an audio tail node for the second page player object.

[0076] As we know, in the Web Audio API, the audio head node and audio tail node are two important concepts, representing the beginning and end of the audio processing graph, respectively.

[0077] The audio head node is the starting point of the entire audio processing graph. It manages the lifecycle of the audio stream, including creating and connecting other audio nodes, controlling playback and pause, etc. The audio head node provides a global timeline for synchronizing audio events. Furthermore, the audio head node is responsible for outputting the final audio mix to the device's audio hardware.

[0078] The audio tail node is the end point of the audio processing graph. It is the last node in the audio stream, where the audio signal is sent to the audio hardware for playback. In the Web Audio API, the audio tail node is typically represented by the destination property of the audio head node. Developers cannot create audio tail nodes directly; they are automatically created by the audio head node and are unique in the audio processing graph.

[0079] In practice, to achieve audio playback on an Android system, you first need to create an audioContext instance on the H5 page and then generate the audio header node using the createBufferSource method of the audioContext instance.

[0080] Get the audio to be played and convert it into a target object.

[0081] In this embodiment, the target object can be an arrayBuffer object. An arrayBuffer object is a byte array object, representing a segment of binary data in memory, which can store various data types.

[0082] Specifically, after obtaining the audio stream, it is converted into an arrayBuffer object.

[0083] The target object is decoded, and the decoded data is concatenated to the audio header node.

[0084] In practice, the decodeAudioData method of audioContext is used to decode the arrayBuffer object of the audio source, and the decoded data is then concatenated to the audio header node.

[0085] Connect the audio head node and the audio tail node to obtain the audio source, and then play the audio source.

[0086] In practice, the audio head node is connected to the tail node using the connect method of the audio head node, thus obtaining a complete audio source. Finally, the audio source's start method can be used to play the audio immediately.

[0087] Optionally, obtain the audio to be played, including:

[0088] If the source type of the audio to be played is a local audio file, then the audio to be played is imported, and the audio stream is obtained through the target request.

[0089] In this embodiment, the target request can be a fetch request. As we know, a fetch request is an API used in modern web development to initiate network requests in a browser; it provides an interface for asynchronously fetching resources from a server.

[0090] Specifically, if the audio to be played is a local audio file, it needs to be imported first, and then the audio stream needs to be obtained through a fetch request.

[0091] If the source type of the audio to be played is a downloaded audio stream, then the audio stream is obtained through the target request.

[0092] Specifically, if the audio to be played is downloaded from the server as an audio stream, it can be downloaded directly via a fetch request.

[0093] Optionally, after creating the first page player object, the following may also be included:

[0094] Set the control properties of the player object on the first page and display the audio control panel.

[0095] In this embodiment, the control attribute can be the `controls` attribute, which can be understood as a control attribute that can control the playback progress of the audio to be played. The audio control panel can be a panel that can control the playback progress of the audio to be played, and the control content can include, for example, play, pause, fast forward, rewind, previous track, and next track.

[0096] Specifically, for iOS systems, to implement audio playback, you first need to create an `audio` tag on the H5 page. If you need to display an audio control panel, you need to set the `controls` property of the `audio` tag; if you don't need to display the audio control panel, you need to set the `display` property of the `audio` tag to `none`, and then append the `audio` tag to the DOM entity.

[0097] This invention addresses the poor playback compatibility issue encountered when playing audio via the `<audio>` tag in an H5 mobile application nested within a WebView. It proposes a method for audio playback in an H5 mobile application with a WebView nested within a WebView. This method creates different page player objects for different operating systems and implements audio playback based on these different object types. For iOS, loading and playing audio via the `<audio>` tag may result in the audio file only playing once. To address this, this invention adds a `loadedmetadata` listener event to the `<audio>` object. During audio loading, the `<audio>` object's playback method is not executed until the `loadedmetadata` listener event is entered, at which point the already loaded audio file is played normally. For Android, loading and playing audio via the `<audio>` tag may result in the audio file not playing at all. To address this, this invention proposes creating an `<audioContext>` instance, generating its audio header node, decoding and concatenating the acquired audio stream data to the header node, obtaining the instance's audio tail node, connecting the header and tail nodes, and then executing the `start` method of the audio source to play the complete audio file normally. In the entire audio playback process, the source type of the audio source is crucial. The iOS audio tag playback method proposed in this embodiment requires that if the audio file is local, it needs to be imported into the H5 page first, and then the audio file is assigned to the audio source; if the audio file is obtained from the server, the audio source needs to convert the Blob data into a browser URL link. Similarly, the Android audioContext object playback method proposed in this embodiment requires that if the audio file is local, it also needs to be imported into the H5 page first, and then the audio file is used as a request parameter to execute a fetch request to obtain the audio source; if the audio stream is obtained from the server, it can be downloaded directly via a fetch request. Only through these methods can the audio source be correctly obtained for audio playback. This invention solves the technical problem of poor playback compatibility when playing audio via the audio tag across different operating systems in H5 mobile applications nested within WebView.

[0098] Example 2

[0099] Figure 2 This is a schematic diagram of an audio playback device according to an embodiment of the present invention. This embodiment is applicable to audio playback applications. The device can be implemented using software and / or hardware, and can be integrated into any device that provides audio playback functionality, such as… Figure 2 As shown, the audio playback device specifically includes: an acquisition module 201 and a creation and playback module 202.

[0100] Among them, the acquisition module 201 is used to acquire the system type corresponding to the audio player;

[0101] The creation and playback module 202 is used to create a target page player object according to the system type, and play the audio to be played based on the target page player object.

[0102] Optionally, the creation and playback module 202 includes:

[0103] The first creation and playback unit is used to create a first page player object if the system type is a first operating system, and set a listening event for the first page player object. When the listening event detects that the audio to be played has finished loading, the audio to be played is played.

[0104] The second creation and playback unit is used to create a second page player object if the system type is a second operating system, and to create an audio header node for the second page player object, decode the audio to be played and concatenate it to the audio header node to obtain an audio source, and play the audio source.

[0105] Optionally, the device further includes:

[0106] The acquisition unit is used to acquire the audio to be played and to acquire the source type of the audio to be played;

[0107] An import unit is used to import the audio to be played on the playback page if the source type of the audio to be played is a local audio file, and to assign the audio to be played to the target attribute of the first page player object.

[0108] The conversion unit is configured to convert the audio to be played into target data if the source type of the audio to be played is a downloaded audio stream, create a downloadable link based on the target data, and assign the downloadable link to the target attribute of the first page player object.

[0109] Optionally, the second creation and playback unit includes:

[0110] Create a sub-unit to create a second page player object, and create an audio head node and an audio tail node for the second page player object;

[0111] The acquisition and conversion subunit is used to acquire the audio to be played and convert the audio to be played into a target object;

[0112] The decoding and splicing subunit is used to decode the target object and splice the decoded data to the audio header node;

[0113] The connection and playback subunit is used to connect the audio head node and the audio tail node to obtain an audio source and play the audio source.

[0114] Optionally, the acquisition and conversion subunit is specifically used for:

[0115] If the source type of the audio to be played is a local audio file, then the audio to be played is imported, and the audio stream is obtained through the target request;

[0116] If the source type of the audio to be played is a downloaded audio stream, then the audio stream is obtained through the target request.

[0117] Optionally, the device further includes:

[0118] The settings and display unit is used to set the control properties of the player object on the first page and to display the audio control panel.

[0119] The above-mentioned products can execute the audio playback method provided in any embodiment of the present invention, and have the corresponding functional modules and beneficial effects of executing the method.

[0120] Example 3

[0121] Figure 3 A schematic diagram of an electronic device 30 that can be used to implement embodiments of the present invention 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 processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0122] like Figure 3 As shown, the electronic device 30 includes at least one processor 31 and a memory, such as a read-only memory (ROM) 32 or a random access memory (RAM) 33, communicatively connected to the at least one processor 31. The memory stores computer programs executable by the at least one processor. The processor 31 can perform various appropriate actions and processes based on the computer program stored in the ROM 32 or loaded from storage unit 38 into the RAM 33. The RAM 33 can also store various programs and data required for the operation of the electronic device 30. The processor 31, ROM 32, and RAM 33 are interconnected via a bus 34. An input / output (I / O) interface 35 is also connected to the bus 34.

[0123] Multiple components in electronic device 30 are connected to I / O interface 35, including: input unit 36, such as keyboard, mouse, etc.; output unit 37, such as various types of monitors, speakers, etc.; storage unit 38, such as disk, optical disk, etc.; and communication unit 39, such as network card, modem, wireless transceiver, etc. Communication unit 39 allows electronic device 30 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0124] Processor 31 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 31 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 31 performs the various methods and processes described above, such as audio playback methods:

[0125] Get the system type corresponding to the audio player;

[0126] Create a target page player object based on the system type, and play the audio to be played based on the target page player object.

[0127] In some embodiments, the audio playback method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 38. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 30 via ROM 32 and / or communication unit 39. When the computer program is loaded into RAM 33 and executed by processor 31, one or more steps of the audio playback method described above may be performed. Alternatively, in other embodiments, processor 31 may be configured to perform the audio playback method by any other suitable means (e.g., by means of firmware).

[0128] Various embodiments 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-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0129] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0130] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device 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 provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, 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 sound input, voice input, or tactile input).

[0132] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0133] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0134] In one embodiment, the present invention further includes a computer program product, which includes a computer program that, when executed by a processor, implements the audio playback method of any embodiment of the present invention.

[0135] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0136] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0137] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.< / audio> < / video>

Claims

1. An audio playback method, characterized by, The method comprises the following steps: acquiring a system type corresponding to an audio player; creating a target page player object according to the system type, and playing to-be-played audio based on the target page player object; wherein the step of creating the target page player object according to the system type and playing the to-be-played audio based on the target page player object comprises the following steps: if the system type is a first operating system, creating a first page player object, setting a listening event for the first page player object, and playing the to-be-played audio after the listening event detects that the to-be-played audio is loaded completely; if the system type is a second operating system, creating a second page player object, creating an audio header node for the second page player object, splicing the to-be-played audio to the audio header node after decoding the to-be-played audio to obtain an audio source, and playing the audio source.

2. The method of claim 1, wherein, After the first page player object is created, the method further comprises the following steps: acquiring to-be-played audio and a source type of the to-be-played audio; if the source type of the to-be-played audio is a local audio file, introducing the to-be-played audio in a playing page and assigning the to-be-played audio to a target attribute of the first page player object; if the source type of the to-be-played audio is a downloaded audio stream, converting the to-be-played audio into target data, creating a downloadable link according to the target data, and assigning the downloadable link to the target attribute of the first page player object.

3. The method of claim 1, wherein, The step of creating the second page player object and splicing the to-be-played audio to the audio header node to obtain the audio source comprises the following steps: creating the second page player object and creating an audio header node and an audio tail node for the second page player object; acquiring the to-be-played audio and converting the to-be-played audio into a target object; decoding the target object and splicing data obtained after decoding to the audio header node; connecting the audio header node and the audio tail node to obtain an audio source, and playing the audio source.

4. The method of claim 3, wherein, The step of acquiring the to-be-played audio comprises the following steps: if the source type of the to-be-played audio is a local audio file, introducing the to-be-played audio and acquiring an audio stream through a target request; if the source type of the to-be-played audio is a downloaded audio stream, acquiring an audio stream through the target request.

5. The method of claim 1, wherein, After the first page player object is created, the method further comprises the following steps: setting a control attribute of the first page player object and displaying an audio control panel.

6. An audio playback device, characterized by The method comprises the following steps: an acquiring module, configured to acquire a system type corresponding to an audio player; a creating and playing module, configured to create a target page player object according to the system type, and play to-be-played audio based on the target page player object; wherein the creating and playing module comprises the following steps: a first creating and playing unit, configured to, if the system type is a first operating system, create a first page player object, set a listening event for the first page player object, and play the to-be-played audio after the listening event detects that the to-be-played audio is loaded completely; A second creating and playing unit is configured to, if the system type is a second operating system, create a second page player object, create an audio header node for the second page player object, splice the to-be-played audio to the audio header node after decoding to obtain an audio source, and play the audio source.

7. An electronic device, comprising: The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the audio playing method in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for causing the processor to implement the audio playing method in any one of claims 1-5 when executed.

9. A computer program product comprising a computer program which, when executed by a processor, implements the audio playing method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Player and embedded play box based on Android operating system

    CN106101751A

  • Music playing method and system, readable storage medium and intelligent terminal equipment

    CN107943447A