Audio playing control method and electronic equipment
By determining whether an application has registered an audio service within the electronic device and controlling the sending of media control commands, the problem of overlaying audio from unregistered applications is solved, thus improving the user's listening experience.
Patent Information
- Application Number
- CN202411392258.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2026-03-31
AI Technical Summary
When an unregistered application is playing audio, media control commands sent by Bluetooth peripherals cannot be directly sent to the unregistered application, resulting in the audio data of the unregistered application and the registered application playing together, which affects the user's listening experience.
By implementing an audio playback control method in electronic devices, it can determine whether an application has registered an audio service and decide whether to discard or send media control commands based on the determination result, thereby avoiding the launch of multiple applications to prevent audio from playing in an overlapping manner.
It effectively avoids the problem of audio data superposition playback, improves the user listening experience, ensures single-channel audio output, and meets the user's Bluetooth remote control needs.
Smart Images

Figure CN121764436A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminals, and more particularly to audio playback control methods and electronic devices. Background Technology
[0002] Applications include those registered with the audio service (referred to as registered applications in this document) and those not registered with the audio service (referred to as unregistered applications in this document). Because unregistered applications do not support receiving media control commands from Bluetooth peripherals, when an unregistered application is currently playing audio, after the host device receives a media control command from the Bluetooth peripheral, the host device (e.g., a mobile phone) will not send the media control command to the unregistered application. Instead, it will launch a registered application and then send the media control command to the registered application. This results in audio data from both unregistered and registered applications playing simultaneously, negatively impacting the user's listening experience. Summary of the Invention
[0003] This application provides an audio playback control method and an electronic device to optimize the electronic device's control over audio playback and improve the user's listening experience.
[0004] In a first aspect, embodiments of this application provide an audio playback method applied to a first electronic device. The method includes: establishing a Bluetooth communication connection with a second electronic device; receiving a first control command sent by the second electronic device through the Bluetooth communication connection, the first control command being used to instruct the first electronic device to play audio; and in a first case, discarding the first control command and continuing to play audio through the second electronic device, the first case including: when the first control command is received, the first electronic device is playing first audio of a first application, and the first application has not registered an audio service; continuing to play audio through the second electronic device includes: continuing to play the first audio of the first application through the second electronic device.
[0005] In one scenario, upon receiving the first control command, the first electronic device is playing a first audio file, but the first audio file has not finished playing, for example, at the 3rd second of the first audio file. In this case, continuing to play the first audio file of the first application (which can be understood as audio data from the first application) via the second electronic device means: continuously playing the first audio file (i.e., continuously playing the audio data from the first application), for example, continuing to continuously play the audio data after the 3rd second of the first audio file after it has finished playing.
[0006] In some embodiments, the method further includes: in a second case, sending a first control command to a second application to continue playing audio via a second electronic device, wherein the second case includes: when the first control command is received, the first electronic device is playing second audio from the second application, and the second application has registered for an audio service; continuing to play audio via the second electronic device includes: continuing to play the second audio from the second application via the second electronic device.
[0007] Similarly, continuing to play the second audio of the second application through the second electronic device means playing the second audio continuously.
[0008] In some embodiments, the method further includes: in a third case, launching a third application, sending a first control command to the third application, and playing audio through a second electronic device, wherein the third application is an application that has registered an audio service, and the third case includes: when the first control command is received, no application on the first electronic device is playing audio; playing audio through the second electronic device includes: playing the third audio of the third application through the second electronic device.
[0009] By implementing the above method, the first electronic device can launch a registered application when no application is playing audio, send media control commands to that application, and then control the application to play audio, thus satisfying the user's listening experience; when an application is playing audio and that application is a registered application, the received media control commands sent by the Bluetooth peripheral are sent to that application; when an application is playing audio and that application is not a registered application, the media control commands sent by the Bluetooth peripheral are discarded, thereby avoiding launching a registered application to play audio according to the media control commands, and thus avoiding the main device from simultaneously outputting two audio streams, which would overlap and affect the user's listening experience.
[0010] In some embodiments, the first electronic device playing a first audio of a first application includes: the first electronic device playing the first audio of a first application running in the foreground. When the first application is running in the foreground, the first electronic device displays the user interface of the first application. When an application is running in the background, the first electronic device does not display the user interface of that application.
[0011] Optionally, in some embodiments, when the first control command is received and the first electronic device is playing the first audio of the first application running in the background, the first electronic device may launch the third application, send the first control command to the third application, stop playing the first audio of the first application, and instead play the third audio of the third application.
[0012] In some embodiments, launching a third application includes: when the interface currently displayed in the foreground of the first electronic device is an interface of a desktop application, switching the foreground interface to display the user interface of the third application; or, when the interface currently displayed in the foreground of the first electronic device is the user interface of an application other than a desktop application, not switching the foreground interface to display the user interface of the third application.
[0013] Desktop applications can include multiple interfaces, such as the homescreen (also known as the main page), the negative one screen on the left side of the homescreen, one or more interfaces on the right side of the homescreen, and the activity center, etc. An application other than a desktop application refers to any application installed on an electronic device other than the desktop application, including system applications and third-party applications. Examples include system-provided note-taking and sticky note applications, as well as third-party downloaded social applications such as V and W.
[0014] After switching to the user interface of the third application, users can directly operate the user interface of the third application. This allows users to further configure playback parameters, such as playing in playlist order, random playback, turning stereo surround sound on / off, and so on, enhancing the user's listening experience.
[0015] In scenarios where the foreground interface is not switched to the user interface of a third-party application, users can continue to browse the user interface of the previously displayed application without affecting their original browsing experience.
[0016] In some embodiments, after continuing to play the second audio of the second application, the method further includes: receiving a second control instruction sent by the second electronic device, the second control instruction being used to instruct the playback of the audio to stop; sending the second control instruction to the second application, the second application responding to the second control instruction to stop playing the second audio.
[0017] In some embodiments, after continuing to play the first audio from the first application, the method further includes: receiving a second control instruction sent by a second electronic device, the second control instruction being used to instruct the playback of the audio to stop; discarding the second control instruction and continuing to play the first audio.
[0018] In some embodiments, the first electronic device has multiple applications installed that have registered for the audio service, and the third application is the most recently run application among the multiple applications that have registered for the audio service. In this way, the first electronic device can play audio that the user has recently listened to, improving the user's listening experience.
[0019] Preferably, the first application belongs to: game application, video application, or news and information application. Belonging to a specific category means it is one of those applications. For example, if the first application is application T, and application T belongs to news and information applications, then it is one of many news and information applications.
[0020] Preferably, the second application is a music application or an audiobook application.
[0021] Preferably, the first electronic device is a mobile phone or tablet computer, and the second electronic device is a true wireless earphone or a car audio system, etc.
[0022] The first control instruction is, for example, the play instruction. The second control instruction is, for example, the pause instruction.
[0023] In a second aspect, embodiments of this application provide an electronic device including one or more processors and one or more memories; wherein the one or more memories are coupled to one or more processors, and the one or more memories are used to store a computer program, which, when executed by one or more processors, causes the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0024] Thirdly, embodiments of this application provide a chip system applied to an electronic device. The chip system includes one or more processors, which are used to invoke computer instructions to cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof.
[0025] Fourthly, embodiments of this application provide a computer-readable storage medium including a computer program that, when executed on an electronic device, causes the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0026] Fifthly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0027] Understandably, the electronic device provided in the second aspect, the chip system provided in the third aspect, the computer storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method provided in this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description
[0028] Figure 1A This application provides a Bluetooth application scenario.
[0029] Figure 1B This application provides a Bluetooth application scenario for multi-channel audio overlay playback.
[0030] Figure 2 This is a flowchart of an audio playback control method provided in an embodiment of this application;
[0031] Figure 3 This is a system framework diagram provided in the embodiments of this application;
[0032] Figure 4 This is a system interaction diagram provided in the embodiments of this application;
[0033] Figure 5 This is a schematic diagram of the hardware structure of a main device provided in an embodiment of this application. Detailed Implementation
[0034] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be a limitation of this application.
[0035] Based on the Bluetooth (BT) communication protocol, mobile phones, tablets, and other electronic devices can establish Bluetooth communication connections with true wireless (TWS) earphones, car audio systems, and other electronic devices. In this Bluetooth-based communication system, the mobile phones, tablets, and other electronic devices are referred to as the master devices, while the true wireless earphones, car audio systems, and other electronic devices are referred to as Bluetooth peripherals. Based on the Bluetooth communication connection between the master device and the Bluetooth peripheral, the master device can send audio data to the Bluetooth peripheral, which can then play it back.
[0036] It is understood that, not limited to mobile phones and tablets, the main device can also be other types of electronic devices, such as laptops and smartwatches. Similarly, not limited to TWS earphones and car audio systems, Bluetooth peripherals can also be other types of electronic devices, such as home audio systems and projectors. The specific types of the main device and Bluetooth peripherals in the embodiments of this application are not limited.
[0037] Figure 1A This application provides a Bluetooth application scenario.
[0038] Users can bring their main device (such as a mobile phone) into the vehicle. The vehicle is equipped with a car audio system. With both the main device and the car audio system's Bluetooth function enabled, the main device can establish a Bluetooth communication connection with the car audio system after entering the vehicle. In this case, the car audio system acts as a Bluetooth peripheral for the main device.
[0039] After establishing a Bluetooth communication connection, the Bluetooth peripheral can send media control commands to the host device. Typically, the Bluetooth peripheral first sends a play command. In response to this command, the host device can determine the target audio to be played, and then send the target audio to the Bluetooth peripheral via the Bluetooth communication connection for playback.
[0040] In some scenarios, when the master device receives a play command from a Bluetooth peripheral, it is running a music application A. In response to the command, the master device can determine the target audio to be played from music application A, such as song B, and then send the target audio to the Bluetooth peripheral for playback.
[0041] In some scenarios, when the master device receives a play command from a Bluetooth peripheral, it may not be running any music applications. In response to the command, the master device can identify the most recently used music application from among one or more installed music applications, launch that application, determine the target audio to be played from that application, and send the target audio to the Bluetooth peripheral for playback.
[0042] Applications installed on the main device include those that have registered with the audio service (referred to as registered applications) and those that have not registered with the audio service (referred to as unregistered applications).
[0043] Registered applications support receiving media control commands sent by Bluetooth peripherals and can perform the next operation based on the received media control commands. For example, upon receiving a play command, the registered application can play audio in response to the command; upon receiving a pause command, the registered application can stop playing audio in response to the command; upon receiving a forward command, the registered application can retrieve the next audio file in the playlist and play it; upon receiving a backward command, the registered application can retrieve the previous audio file in the playlist and play it.
[0044] Conversely, unregistered applications do not support receiving media control commands sent by Bluetooth peripherals (i.e., after the Bluetooth module receives a media control command sent by the Bluetooth peripheral, it will not send the media control command to the unregistered application), and therefore cannot execute the next operation indicated by the media control command.
[0045] Typically, music and audiobook apps register for audio services and are therefore registered apps. Game apps, video players, and news apps, while also involving audio playback, generally do not register for audio services and are therefore not registered apps (i.e., unregistered apps). Furthermore, desktop applications, note-taking apps, and weather apps, which do not involve audio playback, are even less likely to register for audio services and are therefore not registered apps (unregistered apps).
[0046] Since unregistered applications do not support receiving media control commands sent by Bluetooth peripherals, when a media control command is received from a Bluetooth peripheral and an unregistered application is running, the main device will not send the aforementioned media control command to the unregistered application. Instead, it will launch a registered application and then send the aforementioned media control command to the registered application.
[0047] For example, refer to Figure 1B The main device is currently running a short video application X (which is an unregistered application). After the main device enters the vehicle, it establishes a Bluetooth communication connection with the vehicle's audio system. The Bluetooth peripheral (i.e., the audio system) can send media control commands, such as a play command, to the main device via this Bluetooth connection. At this point, because the short video application X is not a registered application, the main device will not send the play command to X. Instead, it will launch a registered application, such as a music application Y, and then send the play command to Y. In response to the play command, the music application Y can retrieve its recent playlist, identify the target audio, and then send the target audio to the Bluetooth peripheral for playback via the Bluetooth connection. After establishing the Bluetooth connection, when the short video application X plays audio, the main device will send the audio data from X to the Bluetooth peripheral for playback.
[0048] At this point, the audio data of the unregistered application (e.g., short video application X) that was originally running and the audio data of the registered application (e.g., music application Y) that was launched based on media control commands are superimposed and played in the Bluetooth peripheral, affecting the user's listening experience.
[0049] Therefore, this application provides an audio playback control method.
[0050] By implementing this method, upon receiving a media control command from a Bluetooth peripheral, the master device can determine whether an application is playing audio. When no application is playing audio, the master device can launch a registered application, send the media control command to that application, and thus control the application to play audio, thereby satisfying the user's listening experience.
[0051] When an application is playing audio, the master device can further verify whether the application is registered with the audio service, i.e., whether it is a registered application. After confirming that the application is registered, the master device can send media control commands received from the Bluetooth peripheral to that application. The registered application can then execute the operations indicated by the media control commands according to a preset command policy, such as playing audio or pausing playback. If the application is determined to be unregistered, the master device can discard the media control commands sent by the Bluetooth peripheral to avoid launching a registered application to play audio according to the media control commands. This prevents the master device from simultaneously outputting two audio streams (one from the registered application and one from the unregistered application), causing the audio to overlap and affecting the user's listening experience.
[0052] Figure 2 This is a flowchart illustrating an audio playback control method provided in an embodiment of this application. This method can be applied to a main device.
[0053] S201. Enable Bluetooth.
[0054] S202. Establish a Bluetooth communication connection with a Bluetooth peripheral.
[0055] S203, Receive the media control command sent by the Bluetooth peripheral.
[0056] After establishing a Bluetooth communication connection, the Bluetooth peripheral can send media control commands to the host device through the Bluetooth communication connection to set the media playback status of the host device.
[0057] In some embodiments, after establishing a Bluetooth communication connection, the Bluetooth peripheral immediately sends a play command to the master device to control the master device to play audio. It can be understood that during the duration of the Bluetooth communication connection, the master device playing audio specifically means: the master device determines the audio data of the target audio to be played, then sends the audio data to the Bluetooth peripheral, which converts the audio data of the electrical signal into a sound signal and plays it.
[0058] In other embodiments, after establishing a Bluetooth communication connection, the Bluetooth peripheral does not immediately send a play command to the master device. During the Bluetooth communication connection, the Bluetooth peripheral can detect user actions performed on it, such as clicking the play control to play, clicking the next track control to switch tracks, etc. Upon detecting such user actions, the Bluetooth peripheral can send corresponding media control commands to the master device.
[0059] S204. Confirm if any application is playing audio.
[0060] When an application is playing audio, step S205: Confirm whether the application has registered for an audio service.
[0061] When the application registers an audio service, S206, the media control command is sent to the application.
[0062] After the media control command is sent to the application, the application can execute the operation indicated by the media control command according to the pre-set command policy within the application.
[0063] For example, upon receiving a play command, the registered application can play audio in response to the command; upon receiving a pause command, the registered application can stop playing audio in response to the command; upon receiving a forward command, the registered application can retrieve the next audio file in the playlist and play it; upon receiving a backward command, the registered application can retrieve the previous audio file in the playlist and play it.
[0064] Furthermore, the instruction policy also records methods for handling repeated instructions. For example, in one specific method, when a registered application is playing audio, upon receiving a play instruction, the registered application may discard the play instruction. Optionally, when a registered application is playing audio, upon receiving a play instruction, in response to the instruction, the registered application may also replay the currently playing audio file, or play an audio file from a specific list. This application's embodiments do not impose limitations on this.
[0065] For example, when the main device is running a music application Y and the music application Y is playing audio, after receiving a play command from a Bluetooth peripheral, the main device can send the play command to the music application Y. The music application Y can process the play command according to its pre-defined command policy. For example, after determining that the music application Y is playing audio, the music application Y can ignore the play command. In this way, the user can continue listening to the currently playing audio.
[0066] If the application has not registered an audio service, S207, discard the media control instruction.
[0067] For example, when the main device is running a short video application X and the short video application X is playing audio, the main device can discard the play command after receiving it from a Bluetooth peripheral.
[0068] In this way, after discarding the play command, the main device will not launch the registered application according to the play command, thus preventing the simultaneous output of multiple audio streams and avoiding the problem of audio overlay playback. Users can continue to browse the short video application X without any obstacles and play the audio of the short video application X through Bluetooth peripherals.
[0069] If no application is playing audio, in step S208, a registered application is launched, and the media control command is sent to the registered application. Similarly, the registered application can execute the operations indicated by the media control command according to the preset command policy.
[0070] For example, when no application is currently playing audio, such as when the desktop (e.g., the home screen) is displayed, or when a note-taking application is running in the foreground, upon receiving a play command from a Bluetooth peripheral, the master device can, in response to the command, launch a registered application (which could be a recently used registered application), such as music application Y, and then send the play command to music application Y. In response to the command, music application Y can determine the target audio and then send the target audio to the Bluetooth peripheral, controlling the Bluetooth peripheral to play the target audio.
[0071] Since no other audio is playing on the main device before the registered application is launched, the main device only receives the audio output from the launched registered application. Therefore, there is no issue of audio overlay playback, and it does not affect the user's listening experience. Users can continue their previous tasks, such as browsing notes, while listening to the audio.
[0072] Similarly, upon receiving a forward / backward command from the Bluetooth peripheral, the master device can launch the registered application and then send the command to the launched application. In response, the registered application can identify the target audio and send it to the Bluetooth peripheral, controlling the peripheral to play the target audio. Upon receiving a pause command from the Bluetooth peripheral, the master device can also launch the registered application, maintaining its paused playback state.
[0073] The main device can have multiple registered applications installed. When launching a registered application, preferably, the main device first launches the registered application most recently used by the user. For example, the main device has two registered applications installed: music application Z and music application Y. Among them, the registered application most recently opened by the user is music application Y. In this case, when launching a registered application, the main device first launches music application Y, obtains the playlist and target audio from music application Y, and sends it to the Bluetooth peripheral for playback.
[0074] In this way, when an application is currently playing audio on the main device, the main device will not arbitrarily launch a registered application and output audio based on media control commands sent by the Bluetooth peripheral, thus avoiding the problem of audio overlay playback and ensuring the user's listening experience. When no application is currently playing audio on the main device, the main device can launch a registered application based on media control commands sent by the Bluetooth peripheral, and control the registered application to play or pause audio, thus meeting the user's Bluetooth remote control needs.
[0075] Optionally, after launching a registered application, the main device can further determine whether the desktop is currently being displayed.
[0076] In scenarios where the desktop is displayed, preferably, the main device can display the user interface of the registered application that has been pulled up, allowing the user to further set playback parameters, such as playing in playlist order, random playback, turning stereo surround sound on / off, etc., to enhance the user's listening experience.
[0077] In scenarios where the desktop is not displayed, such as in a lock screen scenario or when a note-taking application is displayed, the main device can run the launched registered application in the background without displaying the user interface of the aforementioned application, thus avoiding disturbing the user.
[0078] Figure 3 This is a system framework diagram provided in the embodiments of this application.
[0079] This application uses the layered architecture of the Android system as an example to illustrate the system structure of the main device. For example... Figure 3 As shown, the main device's software system includes an application layer, a framework layer, system libraries, and a kernel layer. These layers communicate with each other through software interfaces.
[0080] The application layer can include a series of applications. These applications include system applications (such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, etc.) and third-party applications (such as music application Z, music application Y, short video application X, social application W, etc.).
[0081] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The framework layer includes predefined capability modules such as a window manager, phone manager, resource manager, notification manager, view system, and media session. The window manager can be used to obtain screen size, determine the presence of a status bar, lock the screen, and capture the screen. The phone manager provides communication functions for the host device. The resource manager provides various resources for the application, such as localized strings, icons, images, layout files, and video files. The notification manager can be used by the application to convey notification messages and display this information in the status bar for the user to access. The view system includes visual controls, such as controls for displaying text and images. The view system can be used to build the application's graphical user interface (GUI). The media session can be used to standardize audio and video playback control, provide unified management of media sessions, and support media control interaction between different terminal devices. In this embodiment, the framework layer also includes an identification module for identifying the currently running application in the foreground, whether the application is performing a playback operation, and whether the application has registered an audio service.
[0082] The system library comprises multiple functional modules, such as a surface manager, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), and media libraries. The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for various applications. The 3D graphics processing libraries implement 3D graphics drawing, image rendering, compositing, and layer processing. The 2D graphics engines are used for 2D graphics rendering. The media libraries support playback and recording of various common audio and video formats, as well as still image files. The media libraries support multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0083] The kernel layer is the layer between hardware and software, and includes multiple hardware drivers, such as display drivers, audio drivers, Bluetooth drivers, Wi-Fi drivers, camera drivers, sensor drivers, etc.
[0084] The hardware layer of the main device may include a chip system, an audio module, a display, a camera, and various sensors. The chip system may include an application processor (AP), a baseband processor (BP, also known as a modem), and in some implementations, a Bluetooth chip, a Wi-Fi chip, etc. The audio module may include a speaker, a receiver, a microphone, etc. The aforementioned processors or chips may be deployed independently on the main device, or partially or entirely integrated into a single chip system on the main device.
[0085] The display is driven by a display driver and is used to display visual content such as images and GUIs. The audio module (including speakers, receivers, and microphones) is driven by an audio driver. The speakers and receivers convert audio electrical signals into sound signals for the user to hear; the microphone collects sound signals and converts them back into electrical signals. The Bluetooth chip is driven by a Bluetooth driver and provides Bluetooth connection and communication services. The Wi-Fi chip is driven by a Wi-Fi driver and provides Wi-Fi connection and communication services. The camera is driven by a camera driver and is used to capture images. Various sensors, such as pressure sensors, gyroscopes, barometric pressure sensors, magnetic sensors, accelerometers, proximity sensors, near-field sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors, are driven by their respective sensor drivers and provide corresponding sensing services.
[0086] Figure 4 This is a system interaction diagram provided in the embodiments of this application.
[0087] S501, turn on Bluetooth.
[0088] Users can instruct the host device to enable Bluetooth by interacting with the Bluetooth shortcut icon or by using the toggle button in Bluetooth settings. Upon detecting these user events, the Bluetooth module can then enable Bluetooth. The Bluetooth module wakes up the Bluetooth chip via the Bluetooth driver.
[0089] S502. Establish Bluetooth communication connection.
[0090] After Bluetooth is enabled, the Bluetooth module can enter the Bluetooth connection establishment process. The Bluetooth module can drive the Bluetooth chip to receive Bluetooth probe frames in the environment and discover nearby Bluetooth devices. Figure 1B In the scenario shown, the host device can then discover the car audio system that supports Bluetooth connectivity. After authentication, the host device can establish a Bluetooth communication connection with the car audio system. Once connected, the car audio system becomes a Bluetooth peripheral for the host device.
[0091] S503, Whether to send media control commands.
[0092] Referring to the description in S203, in some embodiments, after establishing a Bluetooth communication connection, the Bluetooth peripheral immediately sends a media control command, such as a play command, to the master device to control the master device to play audio. In some embodiments, after establishing a Bluetooth communication connection, the Bluetooth peripheral does not immediately send a media control command to the master device. During the duration of the Bluetooth communication connection, the Bluetooth peripheral can detect user actions performed on the Bluetooth peripheral and then send a media control command matching the user actions to the master device.
[0093] S504. Confirm if any application is currently playing audio.
[0094] After receiving a media control command from a Bluetooth peripheral, the Bluetooth module can send a request to the identification module to obtain the audio working status.
[0095] Specifically, upon receiving the aforementioned request, the recognition module can query the audio module to determine if an audio stream is currently available. If no audio stream is found, the recognition module can determine that no application is currently playing audio, i.e., the audio working state is idle. If an audio stream is found, the recognition module can determine that an application is currently playing audio, i.e., the audio working state is playing. Furthermore, the recognition module can determine the application currently playing the audio based on identification information such as the audio stream's packet name.
[0096] After confirming that an application is currently playing audio, S505 checks whether the application has registered for an audio service.
[0097] The identification module can send a query request to the audio module to check whether the target application has registered for the audio service, that is, whether the target application is a registered application, and whether the target application can receive media control commands sent by the Bluetooth peripheral. The target application is the application currently playing audio.
[0098] The audio module can indicate which applications have registered for the audio service and which have not through the registration status field. Upon receiving the query request, the audio module can obtain the registration status field of the target application and send it to the recognition module, thereby informing the recognition module whether the target application has registered for the audio service. For example, if the registration status field of the target application equals true, it means that the target application has registered for the audio service; if the registration status field of the target application equals false, it means that the target application has not registered for the audio service.
[0099] If it is determined that the target application has registered for an audio service, S506, the media control command is sent to the target application. The target application can then execute the operations indicated by the media control command according to a preset command policy.
[0100] If it is confirmed that the target application has not registered an audio service, S507 discards the media control command.
[0101] In this way, the main device will not launch the registered application based solely on the aforementioned media control commands, thus preventing the simultaneous output of multiple audio streams and avoiding the problem of audio overlay playback.
[0102] When it is determined that no application is currently playing audio, S508 launches the registered application and sends the media control command to the registered application. Similarly, the registered application can execute the operations indicated by the media control command according to the preset command policy, which will not be elaborated here.
[0103] In this scenario, since the main device does not play other audio when the registered application is launched, the main device will only have one audio output from the launched registered application after the registered application is launched. Therefore, there will be no issue of audio overlay playback, and it will not affect the user's listening experience.
[0104] Figure 5 This is a schematic diagram of the hardware structure of a main device provided in an embodiment of this application.
[0105] like Figure 5 As shown, the main device includes a chip system 61, a memory 62, an audio module 63, a display 64, a camera 65, and a sensor module 66.
[0106] Chip system 61 includes one or more processor chips, such as AP, BP, Bluetooth chip, Wi-Fi chip, and graphics processing unit (GPU), image signal processor (ISP), video codec, digital signal processor (DSP), etc. GPU, ISP, video codec, and DSP are not all shown in the diagram. Different processor chips can be independent devices or integrated into a single chip system.
[0107] The processor may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface. The processor communicates with other components through these interfaces.
[0108] Memory 62 includes one or more random access memory (RAM) and one or more non-volatile memory (NVM). RAM can be directly read and written by the processor and can be used to store executable programs (e.g., machine instructions) of the operating system or other running programs, as well as user and application data. NVM can store executable programs and user data. Executable programs and user data stored in NVM can be loaded into RAM for direct read and write operations by the processor.
[0109] In this embodiment, the executable program code implementing the audio playback control method described herein can be stored in the NVM. After the host device is powered on, it can retrieve the executable program code from the NVM and load it into RAM, thus running the audio playback control method. In this way, the host device can: when a user browses an unregistered application, discard media control commands sent by the Bluetooth peripheral, avoiding the problem of audio overlay playback caused by registered applications being launched in response to the media control commands.
[0110] The host device may also include an external storage interface for connecting to an external NVM to expand the host device’s storage capacity.
[0111] Audio module 63 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. Audio module 63 includes a speaker, a receiver, and a microphone. The speaker, also called a "loudspeaker," is used to convert audio electrical signals into sound signals. The receiver, also called a "earpiece," is used to convert audio electrical signals into sound signals. The main device can play audio through the speaker / receiver for the user to listen to. The microphone, also called a "microphone" or "voice transducer," is used to collect sound signals and convert them into electrical signals.
[0112] When no Bluetooth communication connection is established, the master device can play audio through the speaker in audio module 63. After a Bluetooth communication connection is established, the master device can send audio data to an external device via the Bluetooth chip, and the audio will be played through the external device's speaker. The master device may also include a headphone jack. The master device can send audio data to wired headphones via the headphone jack, and the audio will be played through the speaker on the wired headphones.
[0113] The display 64 includes a display panel. The main device can implement display functions through the GPU, the display 64, and the application processor.
[0114] Camera 65 is used to capture images. The main device may include one or more cameras 65. The main device can implement shooting functions through ISP, camera 65, video codec, GPU, display 64, and application processor, etc.
[0115] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the main device. In other embodiments of this application, the main device may include more or fewer components.
[0116] As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the listed items. As used in the above embodiments, depending on the context, the term “when” can be interpreted as meaning “if…” or “after…” or “in response to determining…” or “in response to detecting…”. Similarly, depending on the context, the phrase “when…” or “if (the stated condition or event) is interpreted as meaning “if…” or “in response to determining…” or “when (the stated condition or event) is detected” or “in response to detecting (the stated condition or event)”.
[0117] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0118] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. An audio playing method applied to a first electronic device, comprising: The method comprises: establishing a Bluetooth communication connection with a second electronic device; receiving a first control instruction sent by the second electronic device through the Bluetooth communication connection, the first control instruction being used to instruct the first electronic device to play audio; in a first case, discarding the first control instruction, and continuing to play audio by the second electronic device, the first case comprising: when the first control instruction is received, the first electronic device is playing first audio of a first application, and the first application has not registered an audio service; and the continuing to play audio by the second electronic device comprises: continuing to play the first audio of the first application by the second electronic device.
2. The method of claim 1, wherein, The method further comprises: in a second case, sending the first control instruction to a second application, and continuing to play audio by the second electronic device, the second case comprising: when the first control instruction is received, the first electronic device is playing second audio of the second application, and the second application has registered an audio service; and the continuing to play audio by the second electronic device comprises: continuing to play the second audio of the second application by the second electronic device.
3. The method according to claim 1 or 2, characterized in that, The method further comprises: in a third case, starting a third application, sending the first control instruction to the third application, and playing audio by the second electronic device, the third application being an application that has registered an audio service, the third case comprising: when the first control instruction is received, no application on the first electronic device is playing audio; and the playing audio by the second electronic device comprises: playing third audio of the third application by the second electronic device.
4. The method according to any of claims 1 to 3, characterized in that, The first electronic device playing first audio of a first application comprises: the first electronic device playing first audio of a first application running in the foreground.
5. The method of claim 3, wherein, The starting the third application comprises: when an interface currently displayed in the foreground of the first electronic device is an interface of a desktop application, switching the interface displayed in the foreground to a user interface of the third application; or, when the interface currently displayed in the foreground of the first electronic device is a user interface of an application other than the desktop application, not switching the interface displayed in the foreground to the user interface of the third application.
6. The method of claim 2, wherein, After the continuing to play second audio of the second application, the method further comprises: receiving a second control instruction sent by the second electronic device, the second control instruction being used to instruct to stop playing audio; sending the second control instruction to the second application, the second application stopping playing the second audio in response to the second control instruction.
7. The method according to any of claims 1 to 6, characterized in that, After the continuing to play first audio of the first application, the method further comprises: receiving a second control instruction sent by the second electronic device, the second control instruction being used to instruct to stop playing audio; discarding the second control instruction, and continuing to play the first audio.
8. The method of claim 1, wherein, The first application belongs to: a game application, a video application, or a news information application.
9. The method of claim 1, wherein, The second application belongs to a music application or an audiobook application.
10. The method of claim 3, wherein, The first electronic device has a plurality of applications registered for audio services installed thereon, and the third application is one of the plurality of applications registered for audio services that was most recently executed.
11. An electronic device, comprising: comprising one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are configured to store a computer program that, when executed by the one or more processors, causes performance of the method of any one of claims 1-10.
12. A chip system applied to an electronic device, the chip system comprising one or more processors, characterized in that, The processor is configured to invoke computer instructions to cause the electronic device to perform the method of any one of claims 1-10.
13. A computer readable storage medium comprising a computer program, characterized in that, The computer program, when executed on an electronic device, causes the electronic device to perform the method of any one of claims 1-10.
