A method for seamless switching of audio data

By considering the time delay when switching Bluetooth devices and utilizing the synchronization mechanism of electronic devices sending instructions and audio frames, seamless connection of audio data is achieved during the switching process of Bluetooth devices, solving the audio interruption problem and improving the user experience.

CN115243236BActive Publication Date: 2025-09-26HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110444578.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-23
Publication Date
2025-09-26
Estimated Expiration
2041-04-23

AI Technical Summary

Technical Problem

When a smartphone switches Bluetooth device connections, audio data will be interrupted, affecting the user experience.

Method used

By taking into account the time delay of Bluetooth devices during the switching process, an electronic device is used to send a stop playback instruction and audio frames to the first audio playback device, and at the same time send a start playback instruction and adjacent audio frames to the second audio playback device, ensuring that in an ideal situation, the second device starts playing when the first device stops playing, thereby achieving seamless connection of audio data.

Benefits of technology

This enables seamless switching of audio data when switching Bluetooth devices, avoiding interruptions and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115243236B_ABST
    Figure CN115243236B_ABST
Patent Text Reader

Abstract

The present application provides a method for seamless switching of audio data, the method comprising: establishing a communication connection between an electronic device and an audio player. The electronic device transmits audio data. Afterwards, the electronic device does not disconnect from the first audio player device, and at the same time establishes a Bluetooth connection with the second audio player device. The electronic device 100 determines the difference T in the playback delay between the first audio player device and the second audio player device, so that the time difference between the first audio player device receiving the stop playback instruction and the second audio player device receiving the start playback instruction is the difference T. Afterwards, when the first audio player device stops playing the audio data, the second audio player device starts playing the audio data. The method implements that when the electronic device switches the Bluetooth device connection, the time delay existing when the Bluetooth device is switched is taken into account, and there will be no interruption of audio data. It also implements synchronization of the audio data playback progress when the Bluetooth device is switched, thereby improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a method for seamless switching of audio data. Background Art

[0002] With the development of wireless communication technology, people have become accustomed to connecting different smart terminal devices wirelessly. Among them, Bluetooth technology, as a relatively mature short-range wireless communication technology, is widely used in smart devices. For example, smartphones and other terminals are connected to audio playback devices (such as Bluetooth headsets) via Bluetooth, and smartphones can transmit audio data to audio playback devices.

[0003] However, when a smartphone switches to another nearby audio playback device (such as a car's Bluetooth), the audio data played by the smartphone will be lost during the connection switching process between the Bluetooth headset, the car's Bluetooth, and the smartphone, affecting the user experience. Therefore, ensuring that audio data is not lost when switching audio playback devices is an urgent problem to be solved. Summary of the Invention

[0004] The present application provides a method for seamless switching of audio data, which enables an electronic device to take into account the time delay existing when switching Bluetooth devices when switching Bluetooth device connections, and avoids audio data interruption. It also achieves synchronization of audio data playback progress when switching Bluetooth devices, thereby improving user experience.

[0005] In a first aspect, the present application provides an audio data seamless switching system, which includes an electronic device, a first audio playback device, and a second audio playback device; the electronic device is used to send audio data to the first audio playback device; the first audio playback device is used to play audio data; the electronic device is also used to: establish a communication connection with the second audio playback device; send a stop playback instruction and a first audio frame to the first audio playback device; send a start playback instruction and a second audio frame to the second audio playback device; the first audio playback device is also used to stop playing the audio data after playing the first audio frame at a first moment after receiving the stop instruction and the first audio frame sent by the electronic device; the second audio playback device is also used to start playing the second audio frame at a first moment after receiving the start playback instruction and the second audio frame sent by the electronic device; wherein the second audio frame is an adjacent frame after the first audio frame.

[0006] The system provided in the first aspect enables an electronic device to take into account the time delay that occurs when switching Bluetooth device connections. When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a stop playback instruction and the first audio frame to the first audio playback device, and the electronic device sends a start playback instruction and the second audio frame to the second audio playback device. Thereafter, ideally, the first audio playback device stops playing the audio data after playing the first audio frame at the first moment, and the second audio playback device just begins playing the second audio frame at the first moment. Alternatively, when the first playback delay of the first audio playback device is less than the second playback delay of the second audio playback device, the electronic device sends a start playback instruction and the second audio frame to the second audio playback device, and the electronic device sends a stop playback instruction and the first audio frame to the first audio playback device. Thereafter, ideally, the first audio playback device stops playing the audio data after playing the first audio frame at the first moment, and the second audio playback device just begins playing the second audio frame at the second moment. In this way, the method realizes that when the electronic device switches the Bluetooth device connection, the time delay existing when the Bluetooth device is switched is taken into account, and there will be no interruption of audio data. In addition, the audio data playback progress is synchronized when the Bluetooth device is switched, and the audio data is played seamlessly, thereby improving the user experience.

[0007] In combination with the first aspect, in a possible implementation, the electronic device is specifically used to: at a second moment, send a stop playback instruction and a first audio frame to a first audio playback device; at a third moment, send a start playback instruction and a second audio frame to a second audio playback device; wherein the difference between the first moment and the second moment shown is the first playback delay of the first audio playback device, and the difference between the first moment and the third moment is the second playback delay of the second audio playback device; the difference between the second moment and the third moment is a first value, and the delay difference between the first playback delay and the second playback delay is the first value.

[0008] Among them, the first playback delay of the first audio playback device starts from the time the first audio frame leaves the electronic device and stops after the first audio playback device plays the first audio frame. This period of time is the first playback delay of the first audio playback device. The second playback delay of the second audio playback device starts from the time the second audio frame leaves the electronic device and stops after the second audio playback device plays the second audio frame. This period of time is the second playback delay of the second audio playback device. The first playback delay includes the Bluetooth transmission delay of the first audio device, the decoding delay of the first audio device and the hardware delay of the first audio device. The second playback delay includes the Bluetooth transmission delay of the second audio device, the decoding delay of the second audio device and the hardware delay of the second audio device.

[0009] In a second aspect, the present application provides another audio data seamless switching system, which includes an electronic device, a first audio playback device, and a second audio playback device; the electronic device is used to send audio data to the first audio playback device; the first audio playback device is used to play the audio data. The electronic device is also used to: establish a communication connection with the second audio playback device; when the first playback delay of the first audio playback device is less than the second playback delay of the second audio playback device, send a first instruction and a first audio frame to the first audio playback device; send a second instruction and a first audio frame to the second audio playback device; the first audio playback device is also used to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame at a reduced volume at a first moment and stop playing the audio data at a second moment; the second audio playback device is also used to, after receiving the second instruction and the first audio frame sent by the electronic device, play the first audio frame at a increased volume at a second moment.

[0010] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0011] The volume increase can be a linear increase, a gradient increase, a volume increase to a preset value and then stop increasing, or a volume increase to a certain time and then stop increasing. This application does not limit the volume decrease and volume increase methods.

[0012] Through the system provided in the second aspect, when the electronic device switches the Bluetooth device connection, the time delay existing when the Bluetooth device switches is taken into account, and there is audio data that is repeatedly played between the two devices. In order to ensure an uninterrupted process when the electronic device switches the playback device, the repeated audio data is played by decreasing the volume of the first audio playback device and playing the repeated audio data by increasing the volume of the second audio playback device. The problem of repeated playback has been solved and the audio data can be played without interruption.

[0013] In conjunction with the second aspect, in one possible implementation, when the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device is further configured to: send a first instruction and a first audio frame to the first audio playback device; and send a second instruction and a first audio frame to the second audio playback device. The first audio playback device is further configured to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame at a decreasing volume at a fourth moment, and stop playing the audio data after playing the first audio frame; and the second audio playback device is further configured to, after receiving the second instruction and the first audio frame sent by the electronic device, play the first audio frame at a increasing volume at a fourth moment.

[0014] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0015] The volume increase can be a linear increase, a gradient increase, a volume increase to a preset value and then stop increasing, or a volume increase to a certain time and then stop increasing. This application does not limit the volume decrease and volume increase methods.

[0016] When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and the electronic device sends a second instruction and a first audio frame to the second audio playback device. Afterwards, ideally, the first audio playback device stops playing the audio data after playing the first audio frame, and the second audio playback device just starts playing the first audio frame. That is, the audio data repeatedly played by the first audio playback device and the second audio playback device is the first audio frame. In order to ensure an uninterrupted process when the electronic device switches playback devices, the first audio frame is played by the first audio playback device with the volume decreased, and the second audio playback device is played with the volume increased, thereby solving the problem of repeated playback and achieving uninterrupted playback of audio data.

[0017] In a third aspect, the present application provides a method for seamless switching of audio data, the method comprising: an electronic device sends audio data to a first audio playback device, and plays the audio data through the first audio playback device. Afterwards, the electronic device establishes a communication connection with the second audio playback device without disconnecting from the first audio playback device, and then the electronic device sends a stop playback instruction and a first audio frame to the first audio playback device; wherein, the stop playback instruction is used to instruct the first audio playback device to stop playing the audio data after playing the first audio frame at a first moment after receiving the stop playback instruction and the first audio frame sent by the electronic device; the electronic device sends a start playback instruction and a second audio frame to the second audio playback device; wherein, the start playback instruction is used to instruct the second audio playback device to start playing the second audio frame at a first moment after receiving the start playback instruction and the second audio frame sent by the electronic device. wherein, the second audio frame is an adjacent frame after the first audio frame.

[0018] The method provided in the third aspect enables an electronic device to take into account the time delay that occurs when switching Bluetooth device connections. When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a stop playback instruction and the first audio frame to the first audio playback device, and the electronic device sends a start playback instruction and the second audio frame to the second audio playback device. Thereafter, ideally, the first audio playback device stops playing the audio data after playing the first audio frame at the first moment, and the second audio playback device just begins playing the second audio frame at the first moment. Alternatively, when the first playback delay of the first audio playback device is less than the second playback delay of the second audio playback device, the electronic device sends a start playback instruction and the second audio frame to the second audio playback device, and the electronic device sends a stop playback instruction and the first audio frame to the first audio playback device. Thereafter, ideally, the first audio playback device stops playing the audio data after playing the first audio frame at the first moment, and the second audio playback device just begins playing the second audio frame at the second moment. In this way, the method realizes that when the electronic device switches the Bluetooth device connection, the time delay existing when the Bluetooth device is switched is taken into account, and there will be no interruption of audio data. In addition, the audio data playback progress is synchronized when the Bluetooth device is switched, and the audio data is played seamlessly, thereby improving the user experience.

[0019] In combination with the third aspect, in one possible implementation, the electronic device, at a second moment, sends a stop playback instruction and a first audio frame to the first audio playback device; at a third moment, sends a start playback instruction and a second audio frame to the second audio playback device; wherein the difference between the first moment and the second moment shown is the first playback delay of the first audio playback device, and the difference between the first moment and the third moment is the second playback delay of the second audio playback device; the difference between the second moment and the third moment is the first value, and the delay difference between the first playback delay and the second playback delay is the first value.

[0020] Among them, the first playback delay of the first audio playback device starts from the time the first audio frame leaves the electronic device and stops after the first audio playback device plays the first audio frame. This period of time is the first playback delay of the first audio playback device. The second playback delay of the second audio playback device starts from the time the second audio frame leaves the electronic device and stops after the second audio playback device plays the second audio frame. This period of time is the second playback delay of the second audio playback device. The first playback delay includes the Bluetooth transmission delay of the first audio device, the decoding delay of the first audio device and the hardware delay of the first audio device. The second playback delay includes the Bluetooth transmission delay of the second audio device, the decoding delay of the second audio device and the hardware delay of the second audio device.

[0021] In conjunction with the third aspect, in one possible implementation, the electronic device disconnects from the first audio playback device when the first audio playback device stops playing audio data after playing the first audio frame. This allows the electronic device to maintain its connection with the first audio playback device while establishing a connection for the second audio data. When the second audio playback device begins playing audio data, and the first audio playback device stops playing audio data after playing the first audio frame, the electronic device disconnects from the first audio playback device, enabling seamless playback of audio data.

[0022] In conjunction with the third aspect, in one possible implementation, when the first playback delay is greater than the second playback delay, the first moment precedes the second moment; when the first playback delay is less than the second playback delay, the second moment precedes the first moment. When the first playback delay is greater than the second playback delay, the time it takes for the first audio playback device to receive and play a frame of audio data is greater than the time it takes for the second audio playback device to receive and play a frame of audio data. In order for the first audio playback device to just stop playing the audio data and the second audio playback device to just start playing the audio data, the electronic device needs to send a stop playback instruction and the first audio frame to the first audio playback device before sending the start playback instruction and the second audio frame to the second audio playback device. After the playback delay difference between the first audio playback device and the second audio playback device, the second audio playback device receives the start playback instruction and the second audio frame. When the first playback delay is less than the second playback delay, the time it takes for the first audio playback device to receive a frame of audio data and play the frame of audio data is less than the time it takes for the second audio playback device to receive a frame of audio data and play the frame of audio data. In order to ensure that the first audio playback device just stops playing the audio data and the second audio playback device just starts playing the audio data, the electronic device needs to send a start playback instruction and the second audio frame to the second audio playback device before sending the stop playback instruction and the first audio frame to the first audio playback device. After the playback delay difference between the first audio playback device and the second audio playback device, the first audio playback device receives the stop playback instruction and the first audio frame.

[0023] In conjunction with the third aspect, in a possible implementation, after the electronic device establishes a communication connection with the second audio playback device, before the electronic device starts sending a stop instruction to the first audio playback device or sending a start instruction to the second audio playback device, the electronic device also needs to calculate the playback delay of the first audio playback device and the second audio playback device. Specifically, the electronic device sends first test data to the first audio playback device and sends second test data to the second audio playback device. The electronic device receives first information sent by the first audio playback device, which includes a fourth moment and a fifth moment; wherein the fourth moment is the moment when the first test data leaves the electronic device, and the fifth moment is the moment when the first audio playback device plays the first test data; the electronic device receives second information sent by the second audio playback device, which includes a sixth moment and a seventh moment; wherein the sixth moment is the moment when the second test data leaves the electronic device, and the seventh moment is the moment when the second audio playback device plays the second test data; the electronic device determines a first playback delay, which is the difference between the fifth moment and the fourth moment; the electronic device determines a second playback delay, which is the difference between the seventh moment and the sixth moment.

[0024] In one possible implementation, if the electronic device has previously calculated the playback delay of the first audio playback device and the playback delay of the second audio playback device, the electronic device can save the playback delay of the first audio playback device and the playback delay of the second audio playback device in the electronic device. Thereafter, the electronic device does not need to recalculate the playback delay of the first audio playback device and the playback delay of the second audio playback device each time.

[0025] In a fourth aspect, the present application provides another method for seamless switching of audio data, the method comprising: an electronic device sends audio data to a first audio playback device, and plays the audio data through the first audio playback device; the electronic device establishes a communication connection with a second audio playback device. When the first playback delay of the first audio playback device is less than the second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and sends a second instruction and a first audio frame to the second audio playback device. The first instruction is used to instruct the first audio playback device to play the first audio frame with a reduced volume at a first moment and stop playing the audio data at a second moment after receiving the first instruction and the first audio frame sent by the electronic device; the second instruction is used to instruct the second audio playback device to play the first audio frame with a increased volume at a second moment after receiving the second instruction and the first audio frame sent by the electronic device.

[0026] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0027] The volume increase can be a linear increase, a gradient increase, a volume increase to a preset value and then stop increasing, or a volume increase to a certain time and then stop increasing. This application does not limit the volume decrease and volume increase methods.

[0028] Through the system provided in the second aspect, when the electronic device switches the Bluetooth device connection, the time delay existing when the Bluetooth device switches is taken into account, and there is audio data that is repeatedly played between the two devices. In order to ensure an uninterrupted process when the electronic device switches the playback device, the repeated audio data is played by decreasing the volume of the first audio playback device and playing the repeated audio data by increasing the volume of the second audio playback device. The problem of repeated playback has been solved and the audio data can be played without interruption.

[0029] In combination with the fourth aspect, in a possible implementation, the electronic device also sends a second audio frame to the first audio playback device, and the first instruction is also used to instruct the first audio playback device to play the first audio frame with the volume reduced at a first moment after receiving the first instruction and the first audio frame sent by the electronic device, and stop playing the audio data after playing the second audio frame at a second moment.

[0030] In combination with the fourth aspect, in a possible implementation, in combination with the second aspect, in a possible implementation, the electronic device is specifically used to: at a third moment, the electronic device sends a first instruction and a first audio frame to a first audio playback device; at a third moment, send a second instruction and a first audio frame to a second audio playback device; wherein the difference between the first moment and the third moment is the first playback delay of the first audio playback device, and the difference between the second moment and the third moment is the second playback delay of the second audio playback device; the difference between the second moment and the first moment is a first value, and the delay difference between the first playback delay and the second playback delay is the first value.

[0031] The first playback delay of the first audio playback device is the time from the moment the first audio frame leaves the electronic device until the first audio playback device plays the first audio frame, and the time is stopped. This period is the first playback delay of the first audio playback device. The second playback delay of the second audio playback device is the time from the moment the first audio frame leaves the electronic device until the second audio playback device plays the first audio frame, and the time is stopped. This period is the second playback delay of the second audio playback device. The first audio frame can be audio data for a real-time call, music, or video.

[0032] The first playback delay includes the Bluetooth transmission delay of the first audio device, the decoding delay of the first audio device, and the hardware delay of the first audio device. The second playback delay includes the Bluetooth transmission delay of the second audio device, the decoding delay of the second audio device, and the hardware delay of the second audio device.

[0033] In conjunction with the fourth aspect, in one possible implementation, when a first playback delay of a first audio playback device is greater than a second playback delay of a second audio playback device, the electronic device is further configured to: send a first instruction and a first audio frame to the first audio playback device; and send a second instruction and a first audio frame to the second audio playback device. The first audio playback device is further configured to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame at a decreasing volume at a fourth moment, and stop playing the audio data after playing the first audio frame; and the second audio playback device is further configured to, after receiving the second instruction and the first audio frame sent by the electronic device, play the first audio frame at a increasing volume at a fourth moment.

[0034] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0035] The volume increase can be a linear increase, a gradient increase, a volume increase to a preset value and then stop increasing, or a volume increase to a certain time and then stop increasing. This application does not limit the volume decrease and volume increase methods.

[0036] When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and the electronic device sends a second instruction and a first audio frame to the second audio playback device. Afterwards, ideally, the first audio playback device stops playing the audio data after playing the first audio frame, and the second audio playback device just starts playing the first audio frame. That is, the audio data repeatedly played by the first audio playback device and the second audio playback device is the first audio frame. In order to ensure an uninterrupted process when the electronic device switches playback devices, the first audio frame is played by the first audio playback device with the volume decreased, and the second audio playback device is played with the volume increased, thereby solving the problem of repeated playback and achieving uninterrupted playback of audio data.

[0037] In one possible implementation, the first instruction includes a volume-down instruction and a stop-play instruction; the second instruction includes a volume-up instruction and a start-play instruction. The volume-down instruction instructs the first audio playback device to play the first audio frame at a reduced volume after receiving the first audio frame; the stop-play instruction instructs the first audio playback device to stop playing the audio data after receiving the second audio frame and completing the second audio frame. The volume-up instruction instructs the second audio playback device to play the first audio frame at a increased volume after receiving the first audio frame.

[0038] In a possible implementation, the electronic device may also send a volume increase instruction and a stop playback instruction to the first audio playback device respectively.

[0039] In combination with the fourth aspect, in one possible implementation, the electronic device sends a first instruction and a first audio frame to the first audio playback device at a fifth moment; and the electronic device sends a second instruction and a first audio frame to the second audio playback device at a sixth moment, wherein the difference between the fourth moment and the fifth moment is the first playback delay of the first audio playback device, and the difference between the fourth moment and the sixth moment is the second playback delay of the second audio playback device; the difference between the sixth moment and the fifth moment is the first value, and the first playback delay and the second playback delay are the first value.

[0040] The first playback delay of the first audio playback device is the time from the moment the first audio frame leaves the electronic device until the first audio playback device plays the first audio frame, and the time is stopped. This period is the first playback delay of the first audio playback device. The second playback delay of the second audio playback device is the time from the moment the first audio frame leaves the electronic device until the second audio playback device plays the first audio frame, and the time is stopped. This period is the second playback delay of the second audio playback device. The first audio frame can be audio data for a real-time call, music, or video.

[0041] The first playback delay includes the Bluetooth transmission delay of the first audio device, the decoding delay of the first audio device, and the hardware delay of the first audio device. The second playback delay includes the Bluetooth transmission delay of the second audio device, the decoding delay of the second audio device, and the hardware delay of the second audio device.

[0042] In conjunction with the fourth aspect, in one possible implementation, before the electronic device begins sending a stop command to the first audio playback device or a start command to the second audio playback device, the electronic device further calculates the playback delay between the first and second audio playback devices. Specifically, the electronic device sends first test data to the first audio playback device and second test data to the second audio playback device. The electronic device receives first information from the first audio playback device, including a seventh time and an eighth time; the seventh time is the time when the first test data leaves the electronic device, and the eighth time is the time when the first audio playback device plays the first test data. The electronic device receives second information from the second audio playback device, including a ninth time and a tenth time; the ninth time is the time when the second test data leaves the electronic device, and the tenth time is the time when the second audio playback device plays the second test data. The electronic device determines a first playback delay, which is the difference between the eighth and seventh times. The electronic device determines a second playback delay, which is the difference between the tenth and ninth times. In this way, the electronic device calculates the playback delay between the first and second audio playback devices, enabling seamless playback of audio data when the first and second audio playback devices are subsequently switched.

[0043] In one possible implementation, if the electronic device has previously calculated the playback delay of the first audio playback device and the playback delay of the second audio playback device, the electronic device can save the playback delay of the first audio playback device and the playback delay of the second audio playback device in the electronic device. Thereafter, the electronic device does not need to recalculate the playback delay of the first audio playback device and the playback delay of the second audio playback device each time.

[0044] In a fifth aspect, the present application provides an electronic device comprising one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code. The computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device performs the steps of the electronic device execution method in any possible implementation of any of the above aspects.

[0045] In a sixth aspect, an embodiment of the present application provides a computer storage medium comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute the method steps in any possible implementation of any of the above aspects.

[0046] In a seventh aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables an electronic device to execute the steps of the electronic device execution method in any possible implementation of any of the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A schematic diagram of a system architecture provided in an embodiment of the present application;

[0048] Figure 2A-2B A timing diagram of audio data playback when a group of electronic devices 100 switches Bluetooth devices provided in an embodiment of the present application;

[0049] Figures 3A-3H A schematic diagram of the operation of switching Bluetooth devices for a group of electronic devices 100 provided in an embodiment of the present application;

[0050] Figure 4 Another interface diagram provided for an embodiment of the present application;

[0051] Figure 5A-5B A schematic diagram of a set of home application scenarios provided by an embodiment of the present application;

[0052] Figure 6 A schematic diagram illustrating the principle of calculating the reference time of two Bluetooth devices by an electronic device 100 provided in an embodiment of the present application;

[0053] Figure 7 A schematic diagram of the principle of calculating the playback delay of audio data played by an audio playback device 200 provided by an electronic device 100 according to an embodiment of the present application;

[0054] Figure 8 A schematic diagram of the principle of calculating the playback delay of audio data played by an audio playback device 300 provided by an electronic device 100 according to an embodiment of the present application;

[0055] Figures 9-12 A schematic diagram illustrating the principle of seamlessly playing audio data when a group of electronic devices 100 switches between Bluetooth devices according to an embodiment of the present application;

[0056] Figure 13 A flowchart of a method for seamless switching of audio data provided in an embodiment of the present application;

[0057] Figure 14 A schematic structural diagram of an electronic device 100 provided in an embodiment of the present application;

[0058] Figure 15 A software structure block diagram of an electronic device 100 provided in an embodiment of the present application;

[0059] Figure 16 A schematic diagram of the hardware structure of an audio playback device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] The following is a clear and detailed description of the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship between related objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0061] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0062] The term "user interface (UI)" in the specification, claims and drawings of this application refers to the media interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is a source code written in a specific computer language such as Java and Extensible Markup Language (XML). The interface source code is parsed and rendered on the terminal device, and finally presented as content that the user can recognize, such as images, text, buttons and other controls. Controls, also known as widgets, are the basic elements of the user interface. Typical controls include toolbars, menu bars, input boxes, buttons, scroll bars, images and text. The properties and contents of controls in the interface are defined by tags or nodes, such as XML through <textview> 、 <imgview> 、 <videoview>The controls contained in the interface are specified by nodes such as <head> and <body>. A node corresponds to a control or attribute in the interface, and the node is presented as user-visible content after parsing and rendering. In addition, many applications, such as hybrid applications, usually also contain web pages in their interfaces. A web page, also called a page, can be understood as a special control embedded in the application interface. A web page is a source code written in a specific computer language, such as hypertext markup language (HTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as user-recognizable content by a browser or a web page display component with similar functions to a browser. The specific content contained in a web page is also defined by tags or nodes in the web page source code, such as HTML through <body>. 、 、 <video> 、 <canvas>To define the elements and attributes of a web page.

[0063] A common form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operations that uses graphics to display. It can be a window, control, or other interface element displayed on the display of an electronic device.

[0064] The following describes a system architecture provided by an embodiment of the present application.

[0065] See Figure 1 , Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of the present application. Figure 1 As shown, the system includes an electronic device 100, an audio playback device 200, and an audio playback device 300. For example, the audio playback device 200 can be a Bluetooth device such as a Bluetooth headset or a Bluetooth speaker, and the audio playback device 300 can be a Bluetooth device such as a car Bluetooth or a Bluetooth speaker. The audio playback device 200 and the audio playback device 300 can also be other devices, such as a Bluetooth watch, etc., which are not limited in this application.

[0066] The device type of the audio playback device 200 and the device type of the audio playback device 300 can be the same or different. For example, the audio playback device 200 can be a Bluetooth headset and the audio playback device 300 can be a car Bluetooth. For another example, the device type of the audio playback device 200 and the device type of the audio playback device 300 can both be Bluetooth speakers.

[0067] The electronic device 100 can communicate with the audio playback device 200 and the audio playback device 300 via any of Bluetooth technologies (including classic Bluetooth and Bluetooth low energy (BLE)), Wi-Fi direct connection, and local area network.

[0068] In the embodiment of the present application, the audio playback device 200 is a Bluetooth headset, the audio playback device 300 is a car Bluetooth, and the electronic device 100 establishes a connection with the audio playback device 200 and the audio playback device 300 via Bluetooth.

[0069] First, after the electronic device 100 establishes a Bluetooth connection with the audio playback device 200, the electronic device 100 can send audio data to the audio playback device 200 for playback via the Bluetooth transmission link.

[0070] Afterwards, the audio playback device 300 is started and sends a broadcast that carries the device identification of the audio playback device 300. The electronic device 100 receives the broadcast sent by the audio playback device 300 and recognizes the device identification of the audio playback device 300 in the broadcast, i.e., the electronic device 100 has previously established a Bluetooth connection with the audio playback device 300 and the priority of the audio playback device 300 is higher than the priority of the audio playback device 200. Then, the electronic device 100 disconnects the Bluetooth connection with the audio playback device 200 and establishes a Bluetooth connection with the audio playback device 300. Afterwards, the electronic device 100 can send audio data to the audio playback device 300 for playback via the Bluetooth transmission link with the audio playback device 300.

[0071] Alternatively, the audio playback device 300 is started. The electronic device 100 receives the user's Bluetooth connection switching operation. In response to the user's Bluetooth connection switching, the electronic device 100 disconnects the Bluetooth connection with the audio playback device 200 and establishes a Bluetooth connection with the audio playback device 300. Afterwards, the electronic device 100 can send audio data to the audio playback device 300 for playback via the Bluetooth transmission link with the audio playback device 300.

[0072] Currently, the electronic device 100 disconnects the Bluetooth connection with the audio playback device 200 and establishes a Bluetooth connection with the audio playback device 300. After that, the electronic device 100 sends the audio data to the audio playback device 300 for playback. During the period from when the electronic device 100 is disconnected from the audio playback device 200 to when the electronic device 100 sends the audio data to the audio playback device 300 for playback, the audio data will be lost, affecting the user experience.

[0073] For example, when the audio data is call voice, when the electronic device 100 switches the Bluetooth connection from the audio playback device 200 to the audio playback device 300, the call voice during this period is interrupted. After waiting for a period of time, the audio playback device 300 will play the call voice, so a section of the call voice is lost.

[0074] For another example, when the audio data is music, when the electronic device 100 switches the Bluetooth connection from the audio playback device 200 to the audio playback device 300, the music being played will be paused. After waiting for a period of time, the audio playback device 300 will play the music, and a section of the music will be lost.

[0075] Currently, the electronic device 100 can adopt any of the following methods to solve the problem of audio data loss and interruption during the Bluetooth device switching process.

[0076] Method 1:

[0077] The electronic device 100 establishes a Bluetooth connection with the audio playback device 200 and sends audio data to the audio playback device 200. When the electronic device 100 switches the connection with the audio playback device 200 to the connection with the audio playback device 300, the electronic device records the playback progress of the audio data when the connection with the audio playback device 200 is disconnected. Afterwards, the electronic device 100 is disconnected from the audio playback device 200, and the electronic device 100 sends the complete audio file corresponding to the played audio data to the audio playback device 300, and at the same time sends the playback progress of the audio data to the audio playback device 300. The audio playback device 300 receives the complete audio file and the playback progress of the audio data sent by the electronic device 100, and starts playing the audio data according to the playback progress of the audio data.

[0078] However, this method has the following problems:

[0079] 1. The electronic device 100 needs to send the complete audio file corresponding to the played audio data to the audio playback device 300. In the real-time call application scenario, the electronic device 100 cannot obtain the ungenerated audio data and cannot achieve playback progress synchronization.

[0080] Second, this method only solves the problem of synchronizing the playback progress of the audio playback device 200 and the audio playback device 300. In the process from when the audio playback device 200 stops playing to when the audio playback device 300 starts playing, there is still the problem of playback interruption.

[0081] Method 2:

[0082] like Figure 2A As shown, at time 0, the electronic device 100 establishes a Bluetooth connection with the audio playback device 200, the electronic device 100 starts to transmit audio data to the audio playback device 200, and the audio playback device 200 plays the audio data.

[0083] like Figure 2A As shown, when the total duration of the audio data played by the audio playback device 200 is 120ms, that is, at the 120ms moment, the audio playback device 300 is turned on, the audio playback device 300 issues a broadcast, the electronic device 100 receives the broadcast issued by the audio playback device 300, and the priority of the audio playback device 300 is higher than the priority of the audio playback device 200. In response to the broadcast issued by the audio playback device 300, the electronic device 100 will establish a Bluetooth connection with the second Bluetooth device. Specifically, first, the electronic device 100 disconnects the Bluetooth connection with the audio playback device 200. Afterwards, the electronic device 100 caches the audio data played after the 120ms moment. When the duration of the audio data cached by the electronic device 100 reaches 120ms, the electronic device 100 establishes a Bluetooth connection with the audio playback device 300, and the audio playback device 300 starts to play the audio data sent by the electronic device 100.

[0084] like Figure 2B As shown, after the electronic device 100 establishes a Bluetooth connection with the audio playback device 300, the electronic device 100 sends the buffered audio data of 120ms to the audio playback device 300, and the audio playback device 300 starts playing the buffered 120ms audio data sent by the electronic device 100. After the audio playback device 300 finishes playing the buffered 120ms audio data, it continues to play the audio data after 240ms.

[0085] However, to avoid delay, the audio data played by the audio playback device 300 is connected to the buffered audio data. The audio playback device 300 will play the received 120ms of buffered audio data in a shorter time. That is, the audio playback device 300 will play the received 120ms of buffered audio data within 80ms. At 320ms, the audio playback device 300 has played the received 120ms of buffered audio data. At 320ms, the audio playback device 300 will play the audio data after 240ms.

[0086] However, this method has the following problems:

[0087] After the electronic device 100 is disconnected from the audio playback device 200, the electronic device 100 sends the cached audio data to the audio playback device 300. There is still a terminal process from when the audio playback device 200 stops playing, when the electronic device 100 sends the cached audio data to the audio playback device 300, to when the audio playback device 300 starts playing. In addition, in order to avoid delay, the audio playback device 300 will accelerate the playback of the audio data cached by the electronic device 100. However, accelerating the playback of the cached audio data will make the user experience worse.

[0088] Therefore, in order to solve the above problems, the present application provides a method for seamless switching of audio data. The method includes: the electronic device 100 establishes a communication connection with the audio playback device 200 (first audio playback device). The audio playback device 200 plays the audio data transmitted by the electronic device 100. At the same time, the audio playback device 300 (second audio playback device) is turned on, and the electronic device 100 does not disconnect from the audio playback device 200, and at the same time establishes a Bluetooth connection with the audio playback device 300. The electronic device 100 determines the difference T between the playback delays of the first audio playback device and the second audio playback device, so that the time difference between the first audio playback device receiving the stop playback instruction and the second audio playback device receiving the start playback instruction is the difference T. Afterwards, when the first audio playback device stops playing the audio data, the second audio playback device starts playing the audio data. In this way, when the electronic device 100 switches the Bluetooth device connection, the time delay existing when the Bluetooth device is switched is taken into account, and there will be no audio data interruption. In addition, the audio data playback progress is synchronized when the audio playback device 200 and the audio playback device 300 are switched, thereby improving the user experience.

[0089] It should be noted that the audio data mentioned in the embodiments of the present application may be predictable audio data, such as audio data played by music or video applications; the audio data mentioned in the embodiments of the present application may also be unpredictable audio data, such as audio data of real-time calls, etc.

[0090] The playback delay of the audio data played by the audio playback device 200 refers to the time from when the electronic device 100 sends the audio data to the audio playback device 200 to when the microphone of the audio playback device 200 collects the audio data. This period of time is called the playback delay of the audio data played by the audio playback device 200. Specifically, the electronic device 100 sends the audio data frame at moment one to the audio playback device 200. The audio data frame at moment one is transmitted to the audio playback device 200 after a period of time. The audio playback device 200 decodes the audio data frame at moment one, and plays the audio data frame at moment one after steps such as analog-to-digital conversion. The moment when the audio data frame is played is moment two, that is, the moment when the microphone of the audio playback device 200 collects the audio data frame is moment two. The difference between moment two and moment one is the playback delay of the audio data played by the audio playback device 200. The playback delay of the audio data played by the audio playback device 200 includes Bluetooth transmission delay + encoding and decoding delay + hardware delay.

[0091] The Bluetooth transmission delay is the transmission time taken by the electronic device 100 to send audio data to the audio playback device 200 via the Bluetooth channel.

[0092] The encoding and decoding delay is the decoding time required for the audio playback device 200 to receive audio data and decode the audio data.

[0093] The hardware delay is the time it takes for the audio player 200 to perform analog-to-digital conversion on the decoded audio data and then play the audio data through the audio module. The hardware delay may be tested before the audio player 200 leaves the factory.

[0094] The principle of the playback delay of the audio data played by the audio playback device 300 is the same as that of the audio data played by the audio playback device 200, and will not be repeated here in this application.

[0095] The electronic device 100 can establish a connection with the audio playback device 300 in any of the following ways:

[0096] Method 1: The electronic device 100 receives a user operation and establishes a connection with the audio playback device 300.

[0097] In a possible implementation, the electronic device 100 may receive a user operation to establish a connection with the second audio playback device 300 in a setting interface.

[0098] like Figure 3A As shown, Figure 3A The user interface 30 for displaying installed applications on the electronic device 100 is exemplarily shown. The user interface 30 displays: a status bar, a calendar indicator, a weather indicator, a tray with commonly used application icons, a navigation bar, an icon 301 for file management, an icon 302 for email, an icon 303 for music, an icon 304 for settings, an icon 305 for sports and health, an icon 306 for weather, etc. The tray of commonly used application icons includes an icon 307 for a camera, an icon 308 for an address book, an icon 309 for a phone, and an icon 310 for information. Among them, the status bar may include: one or more signal strength indicators of a mobile communication signal (also referred to as a cellular signal), an operator name (such as "China Mobile"), one or more signal strength indicators of a Wi-Fi signal, a battery status indicator, a time indicator, etc. The navigation bar may include system navigation keys such as a return key, a home screen key, and a multitasking key. In some embodiments, Figure 3A The user interface 30 exemplarily shown may be a home screen.

[0099] like Figure 3A As shown, the electronic device 100 receives and responds to the user's operation of clicking the setting icon 304, and the electronic device 100 displays the following Figure 3B The setting interface 40 shown. Figure 3B As shown, the settings interface 40 includes an airplane mode icon, which turns off the airplane mode of the electronic device 100, a Wi-Fi icon, which turns off the Wi-Fi of the electronic device 100, and a Bluetooth icon 311, a personal hotspot icon, a mobile network icon, a do not disturb mode icon, a display and brightness icon, a Huawei account icon, a privacy icon, etc. Figure 3B As shown, the electronic device 100 receives and responds to the user's operation of clicking the Bluetooth icon 311, and the electronic device 100 displays the following Figure 3C User interface 50 is shown.

[0100] like Figure 3C As shown, the user interface 50 includes a Bluetooth icon, and the Bluetooth function of the electronic device 100 is turned on. The user interface 50 also includes device identification icons that have previously established a Bluetooth connection with the electronic device 100. For example, the device identification icons may include "lisa", "HUAWEI", "123", "Nancy", etc. The electronic device 100 has established a connection with the device corresponding to the device identification "lisa", and the electronic device 100 has not established a connection with the devices corresponding to the device identifications "HUAWEI", "123", and "Nancy". The user interface 50 also shows an identification icon for a new device that has not previously established a Bluetooth connection with the electronic device 100. The identification icon for the new device may be "jack", "ABC", etc. For example, the device corresponding to the device identification "lisa" may be the audio playback device 200, and the device corresponding to the device identification "123" may be the audio playback device 300.

[0101] like Figure 3C As shown, the electronic device 100 can receive and respond to the user's operation of clicking the device identification icon "123". If the distance between the device corresponding to the device identification icon "123" and the electronic device 100 is within a preset range, the electronic device 100 can establish a Bluetooth connection with the device corresponding to the device identification icon "123".

[0102] In another possible implementation, the electronic device 100 may receive an operation of switching a Bluetooth device from the user in the audio data playback interface, and establish a Bluetooth connection with the audio playback device 300 .

[0103] like Figure 3D As shown, Figure 3D The user interface 60 displayed by the electronic device 100 is exemplarily shown. The user interface 60 includes a music playing screen 601.

[0104] The music playing screen 601 includes the name of the music being played and a control icon. Figure 3D In the example, the title of the music being played is “Dream It Possible.” The control icons include a play / pause control 602, a previous song control 603, a next song control 604, a progress bar 605, a download control 606, a share control 607, a switch control 608, and a more control 609.

[0105] like Figure 3D As shown, the electronic device 100 receives and responds to the user's operation of clicking the switch control 608, and the electronic device 100 displays the following Figure 3E User interface 70 is shown.

[0106] The user interface 70 displays a prompt box 610, which displays the audio playback mode of the electronic device 100. In some embodiments, after the electronic device 100 detects a user operation on the switch control 608, it can change the display form of the user interface 70, such as adding a shadow when displaying the user interface 70.

[0107] like Figure 3E As shown, prompt box 610 shows that electronic device 100 has established a connection with the Bluetooth headset with device identifier "Lisa" and that electronic device 100 is playing audio data through the Bluetooth headset. Prompt box 610 also displays an icon of the device identifier to which electronic device 100 can establish a connection. The device identifier icon can be, for example, "Nancy", "Huawei", "123", etc.

[0108] The electronic device 100 may receive and respond to the user's operation of clicking the device identification icon displayed in the prompt box 610 , and the electronic device 100 may establish a Bluetooth connection with the device corresponding to the device identification icon.

[0109] like Figure 3E As shown, the electronic device 100 can receive and respond to the operation of the device identification icon "123", and the electronic device 100 establishes a Bluetooth connection with the device corresponding to the device identification icon "123".

[0110] Or, as Figure 3F As shown, when the electronic device 100 detects a downward sliding gesture on the display screen, in response to the sliding gesture, as shown in FIG. Figure 3G As shown, electronic device 100 displays window 620 on user interface 60. Window 620 includes a music playback widget 630. Music playback widget 630 includes the title of the music being played and control icons. In music playback widget 630, the title of the music being played is "Dream It Possible." The control icons include a play / pause control 602, a previous song control 603, a next song control 604, a progress bar 605, and a switch control 608.

[0111] In some embodiments, after the electronic device 100 detects a downward sliding gesture on the display screen, it can change the display form of the user interface 60, such as adding a shadow when displaying the user interface 60.

[0112] like Figure 3G As shown, the electronic device 100 receives and responds to the user's operation of clicking the switch control 608 in the music playing small window 630, as shown in FIG. Figure 3H As shown, the electronic device 100 displays a window 650 on the user interface 60 .

[0113] like Figure 3H As shown, window 650 shows that electronic device 100 has established a connection with a Bluetooth headset with a device identifier of "Lisa" and that electronic device 100 is playing audio data through the Bluetooth headset. Window 650 also displays icons of device identifiers to which electronic device 100 can establish a connection. The device identifier icons may be, for example, "Nancy," "Huawei," "123," and so on.

[0114] The electronic device 100 may receive and respond to the user's operation of clicking the icon of the device identification displayed in the window 650 , and the electronic device 100 may establish a Bluetooth connection with the device corresponding to the icon of the device identification.

[0115] like Figure 3H As shown, the electronic device 100 can receive and respond to the operation of the device identification icon "123", and the electronic device 100 establishes a Bluetooth connection with the device corresponding to the device identification icon "123".

[0116] Mode 2: There are other Bluetooth devices near the electronic device 100, and when one of the other Bluetooth devices (such as the audio playback device 300) has a higher priority than the audio playback device 200, the electronic device 100 will establish a connection with the audio playback device 300.

[0117] Table 1

[0118] < / canvas> < / video> Device identification Priority Ranking 123 First Lisa second Huawei third Nancy fourth

[0119] As shown in Table 1, Table 1 illustrates the priority of some devices. For example, the device corresponding to the device ID "123" ranks first in priority, the device corresponding to the device ID "Lisa" ranks second in priority, the device corresponding to the device ID "Huawei" ranks third in priority, and the device corresponding to the device ID "Nancy" ranks fourth in priority.

[0120] When the electronic device 100 has established a Bluetooth connection with the audio playback device 200, the audio playback device 300 is turned on and has a higher priority than the audio playback device 200. The audio playback device 300 continuously sends broadcasts. The distance between the audio playback device 300 and the electronic device 100 is within a preset range. The electronic device 100 receives the broadcasts sent by the audio playback device 300 and recognizes the identifier of the audio playback device 300 carried in the broadcasts. If the electronic device 100 has previously established a Bluetooth connection with the audio playback device 300 and the priority of the audio playback device 300 is higher than that of the audio playback device 200, the electronic device 100 will establish a Bluetooth connection with the audio playback device 300.

[0121] If the electronic device 100 has not established a Bluetooth connection with the audio playback device 300 before, the user interface of the electronic device 100 will display the following Figure 4 The prompt box 660 shown. The prompt box 660 includes prompt information and selection controls. The prompt information includes "123 is about to establish a connection with you. Do you agree to establish the connection?", where "123" is the device identifier of the audio playback device 300. The selection control includes control 6601 and control 6602.

[0122] Alternatively, the prompt message may be "Do you want to switch the connection with "Lisa" to the connection with "123"? The device corresponding to the device identifier "Lisa" has currently established a connection with the electronic device 100, and the device corresponding to the device identifier "123" is the audio playback device 300. The prompt message may also display other content, which is not limited in this application.

[0123] like Figure 4 As shown, the electronic device 100 receives and responds to the user's operation of clicking the control 6601, and the electronic device 100 establishes a Bluetooth connection with the audio playback device 300.

[0124] Method three: There are other Bluetooth devices near the electronic device 100. When one of the other Bluetooth devices (for example, the audio playback device 300) is closer to the electronic device 100 than the distance between the audio playback device 200 and the electronic device 100, the electronic device 100 automatically switches the connection with the audio playback device 200 to the connection with the audio playback device 300.

[0125] like Figure 5A As shown, the electronic device 100 has established a Bluetooth connection with the audio playback device 200 (e.g., a speaker), the electronic device 100 sends audio data to the audio playback device 200 (e.g., a speaker), and the audio playback device 200 (e.g., a speaker) plays the audio data sent by the electronic device 100.

[0126] At this time, the electronic device 100 moves from the first position to the second position. At this time, the audio playback device 300 (e.g., a speaker) is turned on near the second position. At this time, the distance between the audio playback device 200 (e.g., a speaker) and the electronic device 100 is 1.2 meters, and the distance between the audio playback device 300 (e.g., a speaker) and the electronic device 100 is 0.8 meters. Because the distance between the audio playback device 300 (e.g., a speaker) and the electronic device 100 is smaller than the distance between the audio playback device 200 (e.g., a speaker) and the electronic device 100, the electronic device 100 can now establish a Bluetooth connection with the audio playback device 300.

[0127] In some embodiments, in order to avoid the electronic device 100 from frequently switching Bluetooth devices, the electronic device 100 may establish a Bluetooth connection with the audio playback device 300 (e.g., a speaker) based on the distance between the audio playback device 300 (e.g., a speaker) and the electronic device 100 being less than the distance between the audio playback device 200 (e.g., a speaker) and the electronic device 100, and the electronic device 100 may establish a Bluetooth connection with the audio playback device 300 based on the duration for which the distance between the audio playback device 300 (e.g., a speaker) and the electronic device 100 being less than the distance between the audio playback device 200 (e.g., a speaker) and the electronic device 100 reaching a preset time.

[0128] like Figure 5B As shown, Figure 5B Schematic diagram of home application scenario.

[0129] like Figure 5B As shown, the home application scenario includes a first room area 510, a second room area 520 and a living room area 530. The first room area 510 includes a first speaker 501, the second room area 520 includes a first speaker 502, and the living room area 530 includes a third speaker 503.

[0130] The electronic device 100 first establishes a Bluetooth connection with the third speaker 503 in the living room area 530 , and the third speaker 503 plays the audio data sent by the electronic device 100 .

[0131] Afterwards, the electronic device 100 moves to the first room area 510, and the first speaker 501 is turned on. Since the distance between the first speaker 501 and the electronic device 100 is smaller than the distance between the third speaker 503 and the electronic device 100, the electronic device 100 actively establishes a Bluetooth connection with the first speaker 501.

[0132] In some embodiments, the electronic device 100 is moved to the first room area 510, and the first speaker 501 is turned on. Since the distance between the first speaker 501 and the electronic device 100 is less than the distance between the third speaker 503 and the electronic device 100, and the distance between the first speaker 501 and the electronic device 100 is less than the distance between the third speaker 503 and the electronic device 100 for a preset time, the electronic device 100 actively establishes a Bluetooth connection with the first speaker 501.

[0133] The following will focus on how the electronic device 100 calculates the playback delay of the audio data played by the audio playback device 200 and the audio playback device 300 before switching the Bluetooth device, and switches the Bluetooth device based on the difference in the playback delay of the two Bluetooth devices to achieve uninterrupted audio playback.

[0134] Next, the principle of how the electronic device 100 calculates the reference time of the two Bluetooth devices based on the NTP (Network Time Protocol) after the two devices establish a connection will be introduced.

[0135] like Figure 6 As shown, Figure 6 Schematic diagram of the principle of calculating the reference time of two Bluetooth devices.

[0136] like Figure 6 As shown, electronic device 100 sends message 1 to device 2 at time T1. Message 1 carries the timestamp of when it left electronic device 100, which is time T1. For example, time T1 is 10:00:00, and time T1 is the system time of electronic device 100. When electronic device 100 sends message 1 to device 1, it needs to pass through a network delay before it reaches device 1.

[0137] Device 1 receives message 1 sent by electronic device 100 at time T2, and adds the timestamp of device 1 (time T2) to message 1. For example, time T2 is 11:00:01, and the timestamp T2 is the system time of device 1.

[0138] Message 2 leaves device 1 at time T3. Device 1 adds the timestamp of message 1 leaving electronic device 100 (time T1) to message 2, the timestamp of message 1 arriving at device 1 (time T2), and the timestamp of message 2 leaving device 1 (time T3). For example, time T3 is 11:00:02, and the timestamp T3 is the system time of device 1.

[0139] After a period of network delay, the time when the message 2 arrives at the device 1 is time T4. For example, time T4 is 10:00:03, and the timestamp T4 is the system time of the electronic device 100.

[0140] Message 2 carries timestamps T1, T2, and T3.

[0141] The round-trip delay of data transmission between electronic device 100 and device 1 = (T4 - T1) - (T3 - T2).

[0142] For example, the round trip delay of data transmission between the electronic device 100 and the device 1 can be calculated as: round trip delay = (10:00:03 - 10:00:00) - (11:00:02 - 11:00:01) = 2 seconds.

[0143] The time difference between the electronic device 100 and the device 1 is offset=[(T2-T1)+(T3-T4)] / 2.

[0144] For example, the time difference between electronic device 100 and device 1 is offset=[(11:00:01-10:00:00)+(11:00:02-10:00:03)] / 2=1 hour.

[0145] The electronic device 100 uses Figure 6 The method shown calculates the time difference between the electronic device 100 and the audio playback device 200 and the time difference between the electronic device 100 and the audio playback device 300 respectively.

[0146] For example, the time difference between the electronic device 100 and the audio playback device 200 is 5 minutes, and the time difference between the electronic device 100 and the audio playback device 200 is 10 minutes.

[0147] After waiting for the audio path of the audio playback device 300 to be initialized, the electronic device 100 starts to calculate the playback delay between the audio playback device 200 and the audio playback device 300 .

[0148] First, the electronic device 100 calculates the playback delay of the audio data played by the audio playback device 200 according to the test data.

[0149] like Figure 7 As shown, the electronic device 100 continuously sends audio data to the audio playback device 200, and the audio playback device 200 plays the audio data. Afterwards, the timestamp of the current progress of the audio data played by the electronic device 100 is time 3. The electronic device 100 sends test data to the audio playback device 200. The test data includes the time when the test data leaves the electronic device 100, that is, time 3. The test data can be audio data of a specific frequency. The audio data of the specific frequency can be audio data that is perceptible to the human ear or audio data that is not perceptible to the human ear. This application does not limit this.

[0150] The test data passes through the Bluetooth channel between electronic device 100 and audio playback device 200 and, after a period of time, is transmitted to the Bluetooth protocol stack of audio playback device 200. Audio playback device 200 records the time when the test data arrives at the Bluetooth protocol stack of audio playback device 200, which is time 4. The difference between time 4 and time 3 is the transmission delay of the Bluetooth channel between electronic device 100 and audio playback device 200.

[0151] Afterwards, the audio playback device 200 decodes the test data and records the time corresponding to the decoding of the test data, that is, time 5. The difference between time 5 and time 4 is the encoding and decoding delay of the audio playback device 200.

[0152] The audio playback device 200 then transmits the decoded test data to the audio playback module, which performs analog-to-digital conversion, amplifies the power, and plays the test data, allowing the human ear to hear the audio data played by the audio playback device 200. Specifically, after the test data is played, the audio playback device 200 records the time at which the test data is captured by the microphone of the audio playback device 200, i.e., time 6. The difference between time 6 and time 5 is the hardware latency of the audio playback device 200.

[0153] After the audio playback device 200 records the moment when the microphone of the audio playback device 200 collects the test data, the audio playback device 200 sends message three to the electronic device 100. Message three carries the moment when the test data leaves the electronic device 100 (moment three), the moment when the test data arrives at the Bluetooth protocol stack of the audio playback device 200 (moment four), the corresponding moment after the test data is decoded (moment five), and the moment when the microphone of the audio playback device 200 collects the test data (moment six).

[0154] The electronic device 100 receives the message 3 sent by the audio playback device 200, and the time when the message 3 reaches the electronic device 100 is time 7. The electronic device 100 parses the information carried in the message 3 and calculates the playback delay of the audio data played by the audio playback device 200 based on the information carried in the message 3.

[0155] The electronic device 100 can calculate the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 200, that is, the difference between the time when the audio data frame leaves the electronic device 100 (time 3) and the time when the test data arrives at the Bluetooth protocol stack of the audio playback device 200 (time 4) is the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 200. For example, when time 3 is 10:00:320 and time 4 is 10:05:360, the relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes, and the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 200 is 40ms.

[0156] The electronic device 100 can calculate the codec latency of the audio playback device 200. Specifically, the difference between the time corresponding to when the test data is decoded (time 5) and the time when the test data reaches the Bluetooth protocol stack of the audio playback device 200 (time 4) is the codec latency of the audio playback device 200. For example, if time 5 is 10:00:400 and time 4 is 10:05:360, and the relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes, then the codec latency of the audio playback device 200 is 40 ms.

[0157] The electronic device 100 can calculate the hardware delay of the audio playback device 200. In some embodiments, the hardware delay of the audio playback device 200 can also be that the audio playback device 200 has been tested when it leaves the factory, and the audio playback device 200 does not need to calculate the hardware delay of the audio playback device 200 during subsequent use. In other embodiments, the difference between the moment (moment six) when the microphone of the audio playback device 200 collects the test data and the corresponding moment (moment five) after the test data is decoded is the hardware delay of the audio playback device 200. For example, when moment six is ​​10:00:480 and moment five is 10:05:400, the relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes, then the hardware delay of the audio playback device 200 is 80ms.

[0158] The electronic device 100 can calculate the playback delay of the audio data played by the audio playback device 200. The difference between the time when the test data is collected by the microphone of the audio playback device 200 (time six) and the time when the test data leaves the electronic device 100 (time three) is the playback delay of the audio data played by the audio playback device 200. Alternatively, the playback delay of the audio data played by the audio playback device 200 is equal to the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 200 plus the encoding and decoding delay of the audio playback device 200 plus the hardware delay of the audio playback device 200. For example, if time three is 10:00:320 and time six is ​​10:05:480, and the relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes, then the playback delay of the audio data played by the audio playback device 200 is 160ms.

[0159] While electronic device 100 calculates the playback delay of audio data played by audio playback device 200 based on the test data, electronic device 100 can also calculate the playback delay of audio data played by audio playback device 300 based on the test data. Both can be performed simultaneously or separately, and this application does not limit this.

[0160] like Figure 8 As shown, when the electronic device 100 sends the test data to the audio playback device 300, the electronic device 100 records the time when the test data leaves the electronic device 100, i.e., time 3, and the test data includes the time when the test data leaves the electronic device 100, i.e., time 3. The test data can be audio data of a specific frequency, and the audio data of the specific frequency can be audio data perceptible to the human ear or audio data imperceptible to the human ear, which is not limited in this application.

[0161] The test data passes through the Bluetooth channel between the electronic device 100 and the audio playback device 300 and, after a period of time, is transmitted to the Bluetooth protocol stack of the audio playback device 300. The audio playback device 300 records the time at which the test data arrives at the Bluetooth protocol stack of the audio playback device 300, which is time 8. The difference between time 8 and time 3 is the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 300.

[0162] Afterwards, the audio playback device 300 decodes the test data and records the time corresponding to the decoding of the test data, namely time 9. The difference between time 9 and time 8 is the encoding and decoding delay of the audio playback device 300.

[0163] The audio playback device 300 then transmits the decoded test data to the audio playback module, which performs analog-to-digital conversion, amplifies the power, and plays the test data, allowing the human ear to hear the audio data played by the audio playback device 300. That is, after the test data is played, the audio playback device 300 records the time at which the test data is captured by the audio playback device 300's microphone, namely, time 10. The difference between time 10 and time 9 is the hardware latency of the audio playback device 300.

[0164] After the audio playback device 300 records the moment when the microphone of the audio playback device 300 collects the test data, the audio playback device 300 sends message four to the electronic device 100. Message four carries the moment when the test data leaves the electronic device 100 (moment three), the moment when the test data arrives at the Bluetooth protocol stack of the audio playback device 300 (moment eight), the corresponding moment after the test data is decoded (moment nine), and the moment when the microphone of the audio playback device 300 collects the test data (moment ten).

[0165] The electronic device 100 receives the message 4 sent by the audio playback device 300, and the message 4 arrives at the electronic device 100 at time 11. The electronic device 100 parses the information carried by the message 4 and calculates the playback delay of the audio data played by the audio playback device 300 based on the information carried by the message 4.

[0166] The electronic device 100 can calculate the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 300, that is, the difference between the time when the audio data frame leaves the electronic device 100 (time 3) and the time when the test data arrives at the Bluetooth protocol stack of the audio playback device 300 (time 8) is the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 300. For example, when time 3 is 10:00:320 and time 8 is 10:10:400, the relative time difference between the electronic device 100 and the audio playback device 300 is 10 minutes, and the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 300 is 80ms.

[0167] The electronic device 100 can calculate the codec latency of the audio playback device 300. Specifically, the difference between the time corresponding to when the test data is decoded (time 9) and the time when the test data reaches the Bluetooth protocol stack of the audio playback device 300 (time 8) is the codec latency of the audio playback device 300. For example, if time 8 is 10:00:400 and time 9 is 10:10:440, and the relative time difference between the electronic device 100 and the audio playback device 300 is 10 minutes, then the codec latency of the audio playback device 300 is 40 ms.

[0168] The electronic device 100 can calculate the hardware delay of the audio playback device 300. In some embodiments, the hardware delay of the audio playback device 300 can also be that the audio playback device 300 has been tested when it leaves the factory, and the audio playback device 300 does not need to calculate the hardware delay of the audio playback device 300 during subsequent use. In other embodiments, the difference between the moment (moment ten) when the microphone of the audio playback device 300 collects the test data and the corresponding moment (moment nine) after the test data is decoded is the hardware delay of the audio playback device 300. For example, when moment ten is 10:00:560 and moment nine is 10:10:440, the relative time difference between the electronic device 100 and the audio playback device 300 is 10 minutes, then the hardware delay of the audio playback device 300 is 120ms.

[0169] The electronic device 100 can calculate the playback delay of the audio data played by the audio playback device 300. The difference between the time when the test data is collected by the microphone of the audio playback device 300 (time 10) and the time when the test data leaves the electronic device 100 (time 3) is the playback delay of the audio data played by the audio playback device 300. Alternatively, the playback delay of the audio data played by the audio playback device 300 is equal to the transmission delay of the Bluetooth channel between the electronic device 100 and the audio playback device 300 plus the encoding and decoding delay of the audio playback device 300 plus the hardware delay of the audio playback device 300. For example, if time 3 is 10:00:320 and time 10 is 10:10:560, and the relative time difference between the electronic device 100 and the audio playback device 300 is 10 minutes, then the playback delay of the audio data played by the audio playback device 300 is 240ms.

[0170] After the electronic device 100 calculates the playback delays between the audio playback device 200 and the audio playback device 300, if the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 sends a stop audio playback instruction to the audio playback device 200 at time M. After a time T has passed, the electronic device 100 starts playing the audio instruction and sends the audio data to the audio playback device 300. If the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the electronic device 100 sends a start audio playback instruction and audio data to the audio playback device 300 at time M. After a difference T has passed, the electronic device 100 stops playing the audio instruction and sends the audio data to the audio playback device 200. Time T is the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300.

[0171] First, in the application scenario where the audio data is audio data played by a music or video application, the electronic device 100 can obtain the audio data after the timestamp of the currently played audio data in advance. Specifically, the electronic device 100 discovers the audio playback device 300, and the electronic device 100 does not disconnect from the audio playback device 200, and establishes a Bluetooth connection with the audio playback device 300. Afterwards, after the audio path of the audio playback device 300 is initialized, the electronic device 100 calculates the playback delay of the audio playback device 200 and the audio playback device 300. After the playback delay of the audio playback device 200 and the audio playback device 300 is calculated, the electronic device 100 controls the audio playback device 200 and the audio playback device 300 to seamlessly switch and play the audio data.

[0172] The playback delay of the audio playback device 200 is shorter than the playback delay of the audio playback device 300.

[0173] like Figure 9 As shown, Figure 9 The timing diagram of the electronic device 100 achieving seamless connection of the audio data played by the audio playback device 200 and the audio playback device 300 is shown as an example. Figure 9 as well as Figure 9 The time shown is the system time of the electronic device 100 .

[0174] For example, if the Bluetooth transmission delay of the audio playback device 200 is 40ms, the encoding and decoding delay of the audio playback device 200 is 40ms, and the hardware delay of the audio playback device 200 is 80ms, then the playback delay of the audio playback device 200 is 160ms. The relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes.

[0175] If the Bluetooth transmission delay of the audio player 300 is 80ms, the encoding and decoding delay of the audio player 300 is 40ms, and the hardware delay of the audio player 300 is 120ms, the playback delay of the audio player 300 is 240ms. The relative time difference between the electronic device 100 and the audio player 300 is 10 minutes.

[0176] First, the electronic device 100 establishes a connection with the audio playback device 200 , the electronic device 200 sends audio data to the audio playback device 200 , and the audio playback device 200 plays the audio data.

[0177] Afterwards, the audio playback device 300 is turned on, and the electronic device 100 does not disconnect from the audio playback device 200 , but establishes a connection with the audio playback device 300 .

[0178] Exemplarily, the audio playback device 300 establishes a Bluetooth connection with the electronic device 100 at time 10:00:240.

[0179] After a period of time, the audio path of audio playback device 300 is initialized. Audio playback device 300 sends an audio path initialization completion notification to electronic device 100. Electronic device 100 receives and responds to the audio path initialization completion notification sent by audio playback device 300. Electronic device 100 then begins calculating the playback delay between audio playback device 200 and audio playback device 300. How electronic device 100 calculates the playback delay between audio playback device 200 and audio playback device 300 has been described in detail in the previous embodiment and will not be repeated here.

[0180] For example, at time 10:00:280, the audio path of the audio playback device 300 is initialized. Afterwards, at time 10:00:320, the electronic device 100 simultaneously sends a segment of audio data of a special frequency to the audio playback device 200 and the audio playback device 300 to calculate the playback delay of the audio playback device 200 and the audio playback device 300. Because the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the playback delay of the audio playback device 200 is calculated before the playback delay of the audio playback device 300. For example, at time 10:00:520, the playback delay of the audio playback device 200 is calculated, and at time 10:00:600, the playback delay of the audio playback device 300 is calculated.

[0181] After the electronic device 100 calculates the playback delays of the audio playback device 200 and the audio playback device 300, because the playback delay of the audio playback device 200 is smaller than the playback delay of the audio playback device 300, the electronic device 100 first sends a start playback instruction to the audio playback device 300.

[0182] Exemplarily, the electronic device 100 sends a start playing instruction to the audio playing device 300 at time 10:00:640.

[0183] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200 .

[0184] For example, at the time 10:00:640, the electronic device 100 sends a start playback instruction to the audio playback device 300 and simultaneously sends the audio data with a timestamp of 2'30"00 to the audio playback device 200 .

[0185] After a time ΔT from when the electronic device 100 sends the start play instruction to the audio player 300, the electronic device 100 sends a stop play instruction to the audio player 200. It should be noted that the time ΔT is the difference in play delay between the audio player 200 and the audio player 300.

[0186] For example, if the playback delay of the audio playback device 200 is 160 ms and the playback delay of the audio playback device 300 is 240 ms, then the difference ΔT between the playback delays of the audio playback device 200 and the audio playback device 300 is 80 ms.

[0187] At 10:00:640, the electronic device 100 sends a start play instruction to the audio playback device 300. After 80 ms, at 10:00:720, the electronic device 100 sends a stop play instruction to the audio playback device 200.

[0188] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200. Therefore, when the electronic device 100 sends the stop playback instruction to the audio playback device 200, it sends the audio data with the corresponding timestamp to the audio playback device 200.

[0189] For example, at the time 10:00:720, the electronic device 100 sends a stop playback instruction to the audio playback device 200 and simultaneously sends the audio data with a timestamp of 2'30"80 to the audio playback device 200.

[0190] After the electronic device 100 sends a stop play instruction to the audio playback device 200, the stop play instruction is transmitted to the audio playback device 200 via the Bluetooth channel between the electronic device 100 and the audio playback device 200. The decoder in the audio playback device 200 then decodes the data packet containing the stop play instruction. The audio playback device 200 recognizes the stop play instruction and controls the codec in the audio playback device 200 to stop working. After the codec in the audio playback device 200 stops working, the audio data decoded by the audio playback device 200 before the codec stops working will be played. After the codec stops working, the audio playback device 200 receives the audio data sent by the electronic device 100, but the codec in the audio playback device 200 has stopped working and cannot decode the audio data. Therefore, the audio data sent by the audio playback device 200 after the codec stops working will not be played.

[0191] Therefore, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, it also sends the audio data of the timestamp corresponding to that moment to the audio playback device 200. After the Bluetooth transmission delay and encoding and decoding delay of the audio playback device 200, the audio data of the timestamp is just decoded, and the codec of the audio playback device 200 just stops working.

[0192] For example, it can be seen from the above embodiment that the Bluetooth transmission delay of the audio playback device 200 is 40ms, and the encoding and decoding delay of the audio playback device 200 is 40ms. Therefore, at time 10:00:720, the electronic device 100 sends the audio data with a timestamp of 2'30"80 to the audio playback device 200. After a Bluetooth transmission delay of 40ms and an encoding and decoding delay of 40ms, a total of 80ms, the audio data with a timestamp of 2'30"80 is just decoded at time 10:00:800. At time 10:00:800, the codec in the audio playback device 200 just stops working, and at the same time that the electronic device 100 sends a stop playback instruction to the audio playback device 200, the audio data with the corresponding timestamp sent is just decoded. The audio data with the corresponding timestamp can be played by the audio playback device 200, and the audio data with the corresponding timestamp is the audio data last played by the audio playback device 200.

[0193] For example, at time 10:00:800, the audio data with a timestamp of 2'30"80 is decoded by the audio playback device 200. After the hardware delay of the audio playback device 200, the audio data with a time stamp of 2'30"80 is played by the audio playback device 200. As can be seen from the aforementioned embodiment, the hardware delay of the audio playback device 200 is 80ms. Therefore, at time 10:00:880, the audio data with a time stamp of 2'30"80 is played by the audio playback device 200.

[0194] In order to ensure that the timestamp of the audio data when the audio playback device 200 just stops playing is consistent with the timestamp when the audio playback device 300 just starts playing, the electronic device 100 sends the audio data with the corresponding timestamp at the same time when sending a stop playback instruction to the audio playback device 200, and sends the audio data with the corresponding timestamp to the audio playback device 300 at the same time when sending a start playback instruction to the audio playback device 300.

[0195] For example, at time 10:00:720, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, the timestamp of the audio data sent to the audio playback device 200 is 2'30"80. Therefore, at time 10:00:640, the electronic device 200 sends a start playback instruction to the audio playback device 300 and sends the audio data with a timestamp of 2'30"80 to the audio playback device 300. Since the playback delay of the audio playback device 300 is 240ms, at time 10:00:880, the audio playback device 300 just plays the audio data with a timestamp of 2'30"80.

[0196] At the aforementioned time 10:00:880, the timestamp of the last audio data played by audio playback device 200 is 2'30"80, and at the time 10:00:880, audio playback device 300 just plays the audio data with the timestamp of 2'30"80. Therefore, audio playback device 200 just stops playing and audio playback device 300 just starts playing, and audio playback device 200 and audio playback device 300 achieve seamless switching of audio data playback.

[0197] It should be noted that at time 10:00:640, the timestamp of the audio data sent by the electronic device 100 to the audio playback device 200 is 2'30"00, while the timestamp of the audio data sent by the electronic device 100 to the audio playback device 300 is 2'30"80. Because the audio data is audio data played by a music or video application, the electronic device 100 will cache a section of data. Therefore, at time 10:00:640, when the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200, it can obtain the audio data with a timestamp of 2'30"80 in advance, and send the audio data with a timestamp of 2'30"80 to the audio playback device 300.

[0198] The playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300.

[0199] like Figure 10 As shown, Figure 10 The timing diagram exemplarily shows the electronic device 100 achieving seamless connection of audio data played by the audio playback device 200 and the audio playback device 300.

[0200] It should be noted that Figure 10 and Figure 10 The time involved in the illustrated embodiment is the system time of the electronic device 100 .

[0201] For example, if the Bluetooth transmission delay of the audio playback device 200 is 80ms, the encoding and decoding delay of the audio playback device 200 is 40ms, and the hardware delay of the audio playback device 200 is 120ms, the playback delay of the audio playback device 200 is 240ms. The relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes.

[0202] If the Bluetooth transmission delay of the audio player 300 is 40ms, the encoding and decoding delay of the audio player 300 is 40ms, and the hardware delay of the audio player 300 is 80ms, the playback delay of the audio player 300 is 160ms. The relative time difference between the electronic device 100 and the audio player 200 is 10 minutes.

[0203] First, the electronic device 100 establishes a connection with the audio playback device 200 , the electronic device 200 sends audio data to the audio playback device 200 , and the audio playback device 200 plays the audio data.

[0204] Afterwards, the audio playback device 300 is turned on, and the electronic device 100 does not disconnect from the audio playback device 200 , but establishes a connection with the audio playback device 300 .

[0205] Exemplarily, the audio playback device 300 establishes a Bluetooth connection with the electronic device 100 at time 10:00:240.

[0206] After a period of time, the audio path of audio playback device 300 is initialized. Audio playback device 300 sends an audio path initialization completion notification to electronic device 100. Electronic device 100 receives and responds to the audio path initialization completion notification sent by audio playback device 300. Electronic device 100 then begins calculating the playback delay between audio playback device 200 and audio playback device 300. How electronic device 100 calculates the playback delay between audio playback device 200 and audio playback device 300 has been described in detail in the previous embodiment and will not be repeated here.

[0207] For example, at time 10:00:280, the audio path of the audio playback device 300 is initialized. Afterwards, at time 10:00:320, the electronic device 100 simultaneously sends a segment of audio data of a special frequency to the audio playback device 200 and the audio playback device 300 to calculate the playback delay of the audio playback device 200 and the audio playback device 300. Because the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the playback delay of the audio playback device 300 is calculated before the playback delay of the audio playback device 200. For example, at time 10:00:520, the playback delay of the audio playback device 300 is calculated, and at time 10:00:600, the playback delay of the audio playback device 200 is calculated.

[0208] After the electronic device 100 calculates the playback delays of the audio playback device 200 and the audio playback device 300, because the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 first sends a stop playback instruction to the audio playback device 200.

[0209] Exemplarily, the electronic device 100 sends a stop playback instruction to the audio playback device 200 at time 10:00:640.

[0210] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200 .

[0211] For example, at time 10:00:640, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playing device 200.

[0212] After a time ΔT after the electronic device 100 sends the stop play instruction to the audio player 200, the electronic device 100 sends the start play instruction to the audio player 300. It should be noted that the time ΔT is the difference in play delay between the audio player 200 and the audio player 300.

[0213] For example, if the playback delay of the audio playback device 200 is 240 ms and the playback delay of the audio playback device 300 is 160 ms, the difference ΔT between the playback delays of the audio playback device 200 and the audio playback device 300 is 80 ms.

[0214] At 10:00:640, the electronic device 100 sends a stop play instruction to the audio playback device 200. After 80 ms, at 10:00:720, the electronic device 100 sends a start play instruction to the audio playback device 300.

[0215] After the electronic device 100 sends a stop play instruction to the audio playback device 200, the stop play instruction is transmitted to the audio playback device 200 via the Bluetooth channel between the electronic device 100 and the audio playback device 200. The decoder in the audio playback device 200 then decodes the data packet containing the stop play instruction. The audio playback device 200 recognizes the stop play instruction and controls the codec in the audio playback device 200 to stop working. After the codec in the audio playback device 200 stops working, the audio data decoded by the audio playback device 200 before the codec stops working will be played. After the codec stops working, the audio playback device 200 receives the audio data sent by the electronic device 100, but the codec in the audio playback device 200 has stopped working and cannot decode the audio data. Therefore, the audio data sent by the audio playback device 200 after the codec stops working will not be played.

[0216] Therefore, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, it also sends the audio data of the timestamp corresponding to that moment to the audio playback device 200. After the Bluetooth transmission delay and encoding and decoding delay of the audio playback device 200, the audio data of the timestamp is just decoded, and the codec of the audio playback device 200 just stops working.

[0217] For example, it can be seen from the above embodiment that the Bluetooth transmission delay of the audio playback device 200 is 80ms, and the encoding and decoding delay of the audio playback device 200 is 40ms. Therefore, at time 10:00:760, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200. After a Bluetooth transmission delay of 80ms and an encoding and decoding delay of 40ms, a total of 120ms, the audio data with a timestamp of 2'30"00 is just decoded at time 10:00:760. At time 10:00:760, the codec in the audio playback device 200 just stops working, and when the electronic device 100 sends a stop playback instruction to the audio playback device 200, the audio data with the corresponding timestamp sent is just decoded. The audio data with the corresponding timestamp can be played by the audio playback device 200, and the audio data with the corresponding timestamp is the audio data last played by the audio playback device 200.

[0218] For example, at time 10:00:760, the audio data with a timestamp of 2'30"00 is decoded by the audio playback device 200. After the hardware delay of the audio playback device 200, the audio data with a time stamp of 2'30"00 is played by the audio playback device 200. As can be seen from the aforementioned embodiment, the hardware delay of the audio playback device 200 is 120ms. Therefore, at time 10:00:880, the audio data with a time stamp of 2'30"00 is played by the audio playback device 200.

[0219] In order to ensure that the timestamp of the audio data when the audio playback device 200 just stops playing is consistent with the timestamp when the audio playback device 300 just starts playing, the electronic device 100 sends the audio data with the corresponding timestamp at the same time when sending a stop playback instruction to the audio playback device 200, and sends the audio data with the corresponding timestamp to the audio playback device 300 at the same time when sending a start playback instruction to the audio playback device 300.

[0220] For example, at time 10:00:640, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, the timestamp of the audio data sent to the audio playback device 200 is 2'30"00. Therefore, at time 10:00:720, the electronic device 200 sends a start playback instruction to the audio playback device 300 and sends the audio data with a timestamp of 2'30"00 to the audio playback device 300. Since the playback delay of the audio playback device 300 is 160ms, at time 10:00:880, the audio playback device 300 just plays the audio data with a timestamp of 2'30"00.

[0221] As mentioned above, at the time 10:00:880, the timestamp of the last audio data played by the audio playback device 200 is 2'30"00, and at the time 10:00:880, the audio playback device 300 just plays the audio data with the timestamp of 2'30"00. Therefore, the audio playback device 200 just stops playing and the audio playback device 300 just starts playing, and the audio playback device 200 and the audio playback device 300 achieve seamless switching of playing audio data.

[0222] Secondly, when the audio data is a real-time call, in the application scenario, the electronic device 100 cannot obtain the audio data after the timestamp of the currently played audio data in advance. Specifically, the electronic device 100 discovers the audio playback device 300, and the electronic device 100 does not disconnect from the audio playback device 200, and establishes a Bluetooth connection with the audio playback device 300. Afterwards, after the audio path of the audio playback device 300 is initialized, the electronic device 100 calculates the playback delay of the audio playback device 200 and the audio playback device 300. After the playback delay of the audio playback device 200 and the audio playback device 300 is calculated, the electronic device 100 controls the audio playback device 200 and the audio playback device 300 to seamlessly switch and play the audio data.

[0223] The playback delay of the audio playback device 200 is shorter than the playback delay of the audio playback device 300.

[0224] like Figure 11 As shown, Figure 11 The timing diagram of the electronic device 100 achieving seamless connection of the audio data played by the audio playback device 200 and the audio playback device 300 is shown as an example. Figure 11 as well as Figure 11 The time shown is the system time of the electronic device 100 .

[0225] For example, if the Bluetooth transmission delay of the audio playback device 200 is 40ms, the encoding and decoding delay of the audio playback device 200 is 40ms, and the hardware delay of the audio playback device 200 is 80ms, then the playback delay of the audio playback device 200 is 160ms. The relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes.

[0226] If the Bluetooth transmission delay of the audio player 300 is 80ms, the encoding and decoding delay of the audio player 300 is 40ms, and the hardware delay of the audio player 300 is 120ms, the playback delay of the audio player 300 is 240ms. The relative time difference between the electronic device 100 and the audio player 300 is 10 minutes.

[0227] First, the electronic device 100 establishes a connection with the audio playback device 200 , the electronic device 200 sends audio data to the audio playback device 200 , and the audio playback device 200 plays the audio data.

[0228] Afterwards, the audio playback device 300 is turned on, and the electronic device 100 does not disconnect from the audio playback device 200 , but establishes a connection with the audio playback device 300 .

[0229] Exemplarily, the audio playback device 300 establishes a Bluetooth connection with the electronic device 100 at time 10:00:240.

[0230] After a period of time, the audio path of audio playback device 300 is initialized. Audio playback device 300 sends an audio path initialization completion notification to electronic device 100. Electronic device 100 receives and responds to the audio path initialization completion notification sent by audio playback device 300. Electronic device 100 then begins calculating the playback delay between audio playback device 200 and audio playback device 300. How electronic device 100 calculates the playback delay between audio playback device 200 and audio playback device 300 has been described in detail in the previous embodiment and will not be repeated here.

[0231] For example, at time 10:00:280, the audio path of the audio playback device 300 is initialized. Afterwards, at time 10:00:320, the electronic device 100 simultaneously sends a segment of audio data of a special frequency to the audio playback device 200 and the audio playback device 300 to calculate the playback delay of the audio playback device 200 and the audio playback device 300. Because the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the playback delay of the audio playback device 200 is calculated before the playback delay of the audio playback device 300. For example, at time 10:00:520, the playback delay of the audio playback device 200 is calculated, and at time 10:00:600, the playback delay of the audio playback device 300 is calculated.

[0232] After the electronic device 100 calculates the playback delays of the audio playback device 200 and the audio playback device 300, because the playback delay of the audio playback device 200 is smaller than the playback delay of the audio playback device 300, the electronic device 100 first sends a start playback instruction to the audio playback device 300.

[0233] Exemplarily, the electronic device 100 sends a start playing instruction to the audio playing device 300 at time 10:00:640.

[0234] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200 .

[0235] For example, at the time 10:00:640, the electronic device 100 sends a start playback instruction to the audio playback device 300 and simultaneously sends the audio data with a timestamp of 2'30"00 to the audio playback device 200 .

[0236] Since the audio data is from a real-time call, the electronic device 100 cannot obtain the audio data after the timestamp 2'30"00 at the time 10:00:640. That is, at the same time, the timestamps of the audio data sent by the electronic device 100 to the audio playback device 200 and the audio playback device 300 are the same.

[0237] For example, at time 10:00:640, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200 , and at the same time, the electronic device 200 sends the audio data with a timestamp of 2'30"00 to the audio playback device 300 .

[0238] After a time ΔT from when the electronic device 100 sends the start play instruction to the audio player 300, the electronic device 100 sends a stop play instruction to the audio player 200. It should be noted that the time ΔT is the difference in play delay between the audio player 200 and the audio player 300.

[0239] For example, if the playback delay of the audio playback device 200 is 160 ms and the playback delay of the audio playback device 300 is 240 ms, then the difference ΔT between the playback delays of the audio playback device 200 and the audio playback device 300 is 80 ms.

[0240] At 10:00:640, the electronic device 100 sends a start play instruction to the audio playback device 300. After 80 ms, at 10:00:720, the electronic device 100 sends a stop play instruction to the audio playback device 200.

[0241] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200 .

[0242] For example, at the time 10:00:720, the electronic device 100 sends a stop playback instruction to the audio playback device 200 and simultaneously sends the audio data with a timestamp of 2'30"80 to the audio playback device 200.

[0243] Since the audio data is from a real-time call, the electronic device 100 cannot obtain the audio data after the timestamp 2'30"80 at the time 10:00:720. That is, at the same time, the timestamps of the audio data sent by the electronic device 100 to the audio playback device 200 and the audio playback device 300 are the same.

[0244] For example, at time 10:00:720, the electronic device 100 sends the audio data with a timestamp of 2'30"80 to the audio playback device 200 , and at the same time, the electronic device 200 sends the audio data with a timestamp of 2'30"80 to the audio playback device 300 .

[0245] After the electronic device 100 sends a stop play instruction to the audio playback device 200, the stop play instruction is transmitted to the audio playback device 200 via the Bluetooth channel between the electronic device 100 and the audio playback device 200. The decoder in the audio playback device 200 then decodes the data packet containing the stop play instruction. The audio playback device 200 recognizes the stop play instruction and controls the codec in the audio playback device 200 to stop working. After the codec in the audio playback device 200 stops working, the audio data decoded by the audio playback device 200 before the codec stops working will be played. After the codec stops working, the audio playback device 200 receives the audio data sent by the electronic device 100, but the codec in the audio playback device 200 has stopped working and cannot decode the audio data. Therefore, the audio data sent by the audio playback device 200 after the codec stops working will not be played.

[0246] Therefore, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, it also sends the audio data of the timestamp corresponding to that moment to the audio playback device 200. After the Bluetooth transmission delay and encoding and decoding delay of the audio playback device 200, the audio data of the timestamp is just decoded, and the codec of the audio playback device 200 just stops working.

[0247] For example, it can be seen from the above embodiment that the Bluetooth transmission delay of the audio playback device 200 is 40ms, and the encoding and decoding delay of the audio playback device 200 is 40ms. Therefore, at time 10:00:720, the electronic device 100 sends the audio data with a timestamp of 2'30"80 to the audio playback device 200. After a Bluetooth transmission delay of 40ms and an encoding and decoding delay of 40ms, a total of 80ms, the audio data with a timestamp of 2'30"80 is just decoded at time 10:00:800. At time 10:00:800, the codec in the audio playback device 200 just stops working, and at the same time that the electronic device 100 sends a stop playback instruction to the audio playback device 200, the audio data with the corresponding timestamp sent is just decoded. The audio data with the corresponding timestamp can be played by the audio playback device 200, and the audio data with the corresponding timestamp is the audio data last played by the audio playback device 200.

[0248] For example, at time 10:00:800, the audio data with a timestamp of 2'30"80 is decoded by the audio playback device 200, and after the hardware delay of the audio playback device 200, the audio data with a time stamp of 2'30"80 is played by the audio playback device 200. It can be seen from the above embodiment that the hardware delay of the audio playback device 200 is 80ms, so at time 10:00:880, the audio data with a time stamp of 2'30"80 is played by the audio playback device 200. At the same time, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200 at time 10:00:640. Since the playback delay of the audio playback device 200 is 160ms, the audio data with a timestamp of 2'30"00 is played by the audio playback device 200 at time 10:00:800.

[0249] For the audio playback device 300, the timestamp of the audio data sent by the electronic device 100 to the audio playback device 300 at 10:00:640 is 2'30"00. Since the playback delay of the audio playback device 300 is 240ms, the audio data with a time of 2'30"00 is played by the audio playback device 300 at 10:00:880.

[0250] From the above analysis, we can see that at time 10:00:880, the timestamp of the audio data last played by audio playback device 200 is 2'30"80. The timestamp of the audio data just started to be played by audio playback device 300 is 2'30"00. Therefore, the timestamp of the audio data repeatedly played by audio playback device 300 and audio playback device 200 is 2'30"00-2'30"80.

[0251] In order to solve the problem of audio data being repeatedly played by the audio playback device 300 and the audio playback device 200, when the audio playback device 200 plays the audio data with a timestamp of 2'30"00-2'30"80, the volume of the played audio data gradually decreases, and when the audio playback device 300 plays the audio data with a timestamp of 2'30"00-2'30"80, the volume of the played audio data gradually increases.

[0252] For example, between time 2'30"800 and time 2'30"880, the volume of the audio data with timestamps 2'30"00-2'30"80 played by the electronic device 100 gradually decreases. After time 2'30"880, the volume of the audio data with timestamps 2'30"00-2'30"80 played by the electronic device 100 gradually increases.

[0253] In a specific implementation, when the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200 , the volume reduction instruction is sent to the audio playback device 200 .

[0254] For example, at the time 10:00:640, the electronic device 100 sends the audio data with the timestamp of 2'30"00 to the audio playback device 200, and at the same time, the electronic device 100 sends a volume reduction instruction to the audio playback device 200.

[0255] At the same time, when the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 300 , the volume increase instruction is sent to the audio playback device 300 .

[0256] For example, at the time 10:00:640, the electronic device 100 sends the audio data with the timestamp of 2'30"00 to the audio playback device 300, and at the same time, the electronic device 100 sends a volume increase instruction to the audio playback device 300.

[0257] The playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300.

[0258] like Figure 12 As shown, Figure 12 The timing diagram exemplarily shows the electronic device 100 achieving seamless connection of audio data played by the audio playback device 200 and the audio playback device 300.

[0259] It should be noted that Figure 12 and Figure 12 The time involved in the illustrated embodiment is the system time of the electronic device 100 .

[0260] For example, if the Bluetooth transmission delay of the audio playback device 200 is 80ms, the encoding and decoding delay of the audio playback device 200 is 40ms, and the hardware delay of the audio playback device 200 is 120ms, the playback delay of the audio playback device 200 is 240ms. The relative time difference between the electronic device 100 and the audio playback device 200 is 5 minutes.

[0261] If the Bluetooth transmission delay of the audio player 300 is 40ms, the encoding and decoding delay of the audio player 300 is 40ms, and the hardware delay of the audio player 300 is 80ms, the playback delay of the audio player 300 is 160ms. The relative time difference between the electronic device 100 and the audio player 200 is 10 minutes.

[0262] First, the electronic device 100 establishes a connection with the audio playback device 200 , the electronic device 200 sends audio data to the audio playback device 200 , and the audio playback device 200 plays the audio data.

[0263] Afterwards, the audio playback device 300 is turned on, and the electronic device 100 does not disconnect from the audio playback device 200 , but establishes a connection with the audio playback device 300 .

[0264] Exemplarily, the audio playback device 300 establishes a Bluetooth connection with the electronic device 100 at time 10:00:240.

[0265] After a period of time, the audio path of audio playback device 300 is initialized. Audio playback device 300 sends an audio path initialization completion notification to electronic device 100. Electronic device 100 receives and responds to the audio path initialization completion notification sent by audio playback device 300. Electronic device 100 then begins calculating the playback delay between audio playback device 200 and audio playback device 300. How electronic device 100 calculates the playback delay between audio playback device 200 and audio playback device 300 has been described in detail in the previous embodiment and will not be repeated here.

[0266] For example, at time 10:00:280, the audio path of the audio playback device 300 is initialized. Afterwards, at time 10:00:320, the electronic device 100 simultaneously sends a segment of audio data of a special frequency to the audio playback device 200 and the audio playback device 300 to calculate the playback delay of the audio playback device 200 and the audio playback device 300. Because the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the playback delay of the audio playback device 300 is calculated before the playback delay of the audio playback device 200. For example, at time 10:00:520, the playback delay of the audio playback device 300 is calculated, and at time 10:00:600, the playback delay of the audio playback device 200 is calculated.

[0267] After the electronic device 100 calculates the playback delays of the audio playback device 200 and the audio playback device 300, because the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 first sends a stop playback instruction to the audio playback device 200.

[0268] Exemplarily, the electronic device 100 sends a stop playback instruction to the audio playback device 200 at time 10:00:640.

[0269] Before the audio playback device 300 starts playing the audio data, the electronic device 100 continues to send the audio data to the audio playback device 200 .

[0270] For example, at time 10:00:640, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playing device 200.

[0271] After a time ΔT after the electronic device 100 sends the stop play instruction to the audio player 200, the electronic device 100 sends the start play instruction to the audio player 300. It should be noted that the time ΔT is the difference in play delay between the audio player 200 and the audio player 300.

[0272] For example, if the playback delay of the audio playback device 200 is 240 ms and the playback delay of the audio playback device 300 is 160 ms, the difference ΔT between the playback delays of the audio playback device 200 and the audio playback device 300 is 80 ms.

[0273] At 10:00:640, the electronic device 100 sends a stop play instruction to the audio playback device 200. After 80 ms, at 10:00:720, the electronic device 100 sends a start play instruction to the audio playback device 300.

[0274] After the electronic device 100 sends a stop play instruction to the audio playback device 200, the stop play instruction is transmitted to the audio playback device 200 via the Bluetooth channel between the electronic device 100 and the audio playback device 200. The decoder in the audio playback device 200 then decodes the data packet containing the stop play instruction. The audio playback device 200 recognizes the stop play instruction and controls the codec in the audio playback device 200 to stop working. After the codec in the audio playback device 200 stops working, the audio data decoded by the audio playback device 200 before the codec stops working will be played. After the codec stops working, the audio playback device 200 receives the audio data sent by the electronic device 100, but the codec in the audio playback device 200 has stopped working and cannot decode the audio data. Therefore, the audio data sent by the audio playback device 200 after the codec stops working will not be played.

[0275] Therefore, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, it also sends the audio data of the timestamp corresponding to that moment to the audio playback device 200. After the Bluetooth transmission delay and encoding and decoding delay of the audio playback device 200, the audio data of the timestamp is just decoded, and the codec of the audio playback device 200 just stops working.

[0276] For example, it can be seen from the above embodiment that the Bluetooth transmission delay of the audio playback device 200 is 80ms, and the encoding and decoding delay of the audio playback device 200 is 40ms. Therefore, at time 10:00:760, the electronic device 100 sends the audio data with a timestamp of 2'30"00 to the audio playback device 200. After a Bluetooth transmission delay of 80ms and an encoding and decoding delay of 40ms, a total of 120ms, the audio data with a timestamp of 2'30"00 is just decoded at time 10:00:760. At time 10:00:760, the codec in the audio playback device 200 just stops working, and when the electronic device 100 sends a stop playback instruction to the audio playback device 200, the audio data with the corresponding timestamp sent is just decoded. The audio data with the corresponding timestamp can be played by the audio playback device 200, and the audio data with the corresponding timestamp is the audio data last played by the audio playback device 200.

[0277] For example, at time 10:00:760, the audio data with a timestamp of 2'30"00 is decoded by the audio playback device 200. After the hardware delay of the audio playback device 200, the audio data with a time stamp of 2'30"00 is played by the audio playback device 200. As can be seen from the aforementioned embodiment, the hardware delay of the audio playback device 200 is 120ms. Therefore, at time 10:00:880, the audio data with a time stamp of 2'30"00 is played by the audio playback device 200.

[0278] In order to ensure that the timestamp of the audio data when the audio playback device 200 just stops playing is consistent with the timestamp when the audio playback device 300 just starts playing, the electronic device 100 sends the audio data with the corresponding timestamp at the same time when sending a stop playback instruction to the audio playback device 200, and sends the audio data with the corresponding timestamp to the audio playback device 300 at the same time when sending a start playback instruction to the audio playback device 300.

[0279] For example, at time 10:00:640, when the electronic device 100 sends a stop playback instruction to the audio playback device 200, the timestamp of the audio data sent to the audio playback device 200 is 2'30"00. Therefore, at time 10:00:720, the electronic device 200 sends a start playback instruction to the audio playback device 300 and sends the audio data with a timestamp of 2'30"00 to the audio playback device 300. Since the playback delay of the audio playback device 300 is 160ms, at time 10:00:880, the audio playback device 300 just plays the audio data with a timestamp of 2'30"00.

[0280] As mentioned above, at the time 10:00:880, the timestamp of the last audio data played by the audio playback device 200 is 2'30"00, and at the time 10:00:880, the audio playback device 300 just plays the audio data with the timestamp of 2'30"00. Therefore, the audio playback device 200 just stops playing and the audio playback device 300 just starts playing, and the audio playback device 200 and the audio playback device 300 achieve seamless switching of playing audio data.

[0281] like Figure 13 As shown, Figure 13 Flowchart of a method for seamless switching of audio data provided in an embodiment of the present application. The method is applied to an audio playback system, which includes an electronic device 100, an audio playback device 200 and an audio playback device 300. The hardware structure of the audio playback device 200 and the audio playback device 300 can be referred to in the following Figure 16 The structure of the audio playback device in the illustrated embodiment will not be described in detail here.

[0282] S1305-S1308, the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, and the electronic device 100 implements seamless switching of the audio data playback between the two Bluetooth devices.

[0283] S13010-S1313, in an application scenario where the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300 and the audio data is predictable, the electronic device 100 implements seamless switching of audio data playback between the two Bluetooth devices.

[0284] S13014-S1319, when the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300 and the audio data is unpredictable, the electronic device 100 implements seamless switching of audio data playback between the two Bluetooth devices.

[0285] It should be noted that the embodiment of the present application may first execute S13010-S1313, then execute S13014-S1319, and then execute S1305-S1308; the embodiment of the application may first execute S13014-S1319, then execute S13010-S1313, and then execute S1305-S1308, and so on. The present application does not limit the execution order of S13010-S1313, S13014-S1319, and S1305-S1308.

[0286] S1301 : The electronic device 100 establishes a communication connection with the audio playback device 200 .

[0287] The electronic device 100 can establish a communication connection with the audio playback device 200 via any one of Bluetooth, Wi-Fi direct connection, local area network, etc. The embodiment of the present application takes the electronic device 100 and the audio playback device 200 establishing a communication connection via Bluetooth technology as an example for description.

[0288] After the electronic device 100 establishes a Bluetooth connection with the audio playback device 200 , the electronic device 100 sends the audio data to the audio playback device 200 , and the audio playback device 200 plays the audio data.

[0289] It should be noted that the audio data may be audio data played in a music or video application, or audio data in a real-time call. A real-time call may include a voice call, a video call, and the like.

[0290] S1302 : The electronic device 100 establishes a communication connection with the audio playback device 300 without disconnecting the communication connection with the audio playback device 200 .

[0291] After the electronic device 100 establishes a communication connection with the audio playback device 200, the audio playback device 300 is turned on, and the electronic device 100 does not disconnect from the audio playback device 200. While the electronic device 100 establishes a communication connection with the audio playback device 200, it also establishes a communication connection with the audio playback device 300.

[0292] How the electronic device 100 establishes a connection with the second Bluetooth device 300, please refer to Figures 3A-5B The embodiments shown in this application will not be described in detail here.

[0293] S1303: The electronic device 100 determines the playback delay (first playback delay) of the audio playback device 200 and the playback delay (second playback delay) of the audio playback device 300.

[0294] The method for the electronic device 100 to determine the playback delay between the audio playback device 200 and the audio playback device 300 is described in detail in the following. Figure 7-Figure 8 The embodiments shown will not be described in detail here.

[0295] In some embodiments, if the electronic device 100 has previously established a communication connection with the audio playback device 200 and the audio playback device 300, and the electronic device 100 stores the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300, the electronic device 100 may not execute S1303. The electronic device 100 does not need to calculate the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300, and can directly obtain the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300 from the electronic device 100.

[0296] In some embodiments, the playback delay of the audio playback device 200 (first playback delay) and the playback delay of the audio playback device 300 (second playback delay) may include transmission delay and hardware delay. Specifically, the playback delay of the audio playback device 200 starts when the audio playback device 200 receives the first audio frame and stops when the audio playback device 200 plays the first audio frame. This period of time is the playback delay of the audio playback device 200. The playback delay of the audio playback device 300 starts when the audio playback device 300 receives the second audio frame and stops when the audio playback device 300 plays the second audio frame. This period of time is the playback delay of the audio playback device 300.

[0297] In this case, the calculation process for the first and second playback delays is as follows: After the electronic device establishes a communication connection with the second audio playback device, and before the electronic device begins sending a stop command to the first audio playback device or a start command to the second audio playback device, the electronic device further calculates the playback delays between the first and second audio playback devices. Specifically, the electronic device sends first test data to the first audio playback device and second test data to the second audio playback device. The electronic device receives first information from the first audio playback device, including a fifth and sixth time points; the fifth time point is the time point when the first test data arrives at the first audio playback device for playback, and the sixth time point is the time point when the first audio playback device plays the first test data. The electronic device receives second information from the second audio playback device, including a seventh and eighth time points; the seventh time point is the time point when the second test data arrives at the second audio playback device for playback, and the eighth time point is the time point when the second audio playback device plays the second test data. The electronic device determines a first playback delay, which is the difference between the sixth and fifth time points; and determines a second playback delay, which is the difference between the eighth and seventh time points. In this way, the electronic device calculates the playback delay between the first audio playback device and the second audio playback device, making it possible to seamlessly play audio data when the first audio playback device and the second audio playback device are switched.

[0298] S1304: Is the playback delay of the audio playback device 200 greater than the playback delay of the audio playback device 300?

[0299] If the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 executes S1305-S1308.

[0300] For real-time call application scenarios (i.e., audio data is unpredictable) or music or video playback application scenarios (i.e., audio data is predictable), when the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, a stop playback instruction and the audio data at the first timestamp can be first sent to the audio playback device 200. After the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300 has passed, a start playback instruction and the audio data at the first timestamp are sent to the audio playback device 300. In this way, ideally, the audio playback device 200 has just finished playing the audio data at the first timestamp and stopped playing the audio data, and the audio playback device 200 has just started playing the audio data at the first timestamp. This achieves seamless switching during audio data playback.

[0301] If the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300 , the electronic device 100 executes S1309 .

[0302] If the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, it is necessary to separate the real-time call application scenario (i.e., the audio data is unpredictable) and the music or video playback application scenario (i.e., the audio data is predictable). Because for the real-time call application scenario, since the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the real-time call application scenario cannot obtain the audio data after the current timestamp in advance. Therefore, the timestamps of the audio data when the audio playback device 200 stops playing and the audio playback device 300 starts playing are different. For the music or video playback application scenario, the audio data after the current timestamp can be obtained in advance. Because the electronic device 100 downloads the entire file corresponding to the audio data locally, the timestamps of the audio data when the audio playback device 200 stops playing and the audio playback device 300 starts playing are the same. To address the real-time call scenario, the audio data timestamps of the last audio playback device 200 stopping and the audio playback device 300 starting are different, and the audio data segments played by audio playback devices 200 and 300 overlap, and the volume of audio playback device 200 gradually decreases while the volume of audio playback device 300 gradually increases. These two different situations require different strategies and need to be handled separately.

[0303] In some embodiments, the electronic device 100 may also first determine the type of audio data, and then select a corresponding strategy according to the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300.

[0304] S1305 : At the Mth moment (the second moment), the electronic device 100 sends a stop playback instruction and the audio data (the first audio frame) corresponding to the first timestamp to the audio playback device 200 (the first audio playback device).

[0305] The Mth moment can be Figure 10 or Figure 12 The 640ms moment is shown.

[0306] Since the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 needs to first send a stop playback instruction to the audio playback device 200 so that the audio playback device 200 just stops playing and the audio playback device 300 just starts playing.

[0307] That is, at the Mth moment, the electronic device 100 sends a stop playback instruction to the audio playback device 200. At the Mth moment, the timestamp of the audio data played by the electronic device 100 is the first timestamp, and the electronic device 100 also needs to send the audio data corresponding to the first timestamp to the audio playback device 200.

[0308] It should be noted that the Mth moment is the system time of the electronic device 100. The first timestamp is the playing progress of the audio data played by the electronic device 100.

[0309] S1306 : At the Nth moment (the third moment), the electronic device 100 sends a start playback instruction and the audio data (the second audio frame) corresponding to the second timestamp to the audio playback device 300 (the second audio playback device).

[0310] The Nth moment can be Figure 10 or Figure 12 The 720ms moment is shown.

[0311] The Nth moment is greater than the Mth moment, and the difference between the Nth moment and the Mth moment is the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300.

[0312] At the Mth moment, after the electronic device 100 sends the stop playback instruction and the audio data corresponding to the first timestamp to the audio playback device 200, after the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300 has passed, that is, at the Nth moment, the electronic device 100 sends the start playback instruction and the audio data corresponding to the second timestamp to the audio playback device 300.

[0313] S1307: The audio playback device 200 stops playing the audio data at time P (the fourth time).

[0314] The Pth moment can be Figure 10 or Figure 12 The 880ms moment is shown.

[0315] S1308: At time P, the audio playback device 300 starts playing the audio data, and the timestamp is the second timestamp.

[0316] The Pth moment can be Figure 10 or Figure 12 The 880ms moment is shown.

[0317] The first timestamp of the audio data can be as follows Figure 10 or Figure 12 The audio data shown has a timestamp of 2'30"00.

[0318] The second time stamp of the audio data can be as follows Figure 10 or Figure 12 The timestamps shown are audio data of the timestamps immediately following 2'30"00.

[0319] That is, in Figure 10 or Figure 12 In the embodiment, the audio data with the timestamp of 2'30"00 sent by the electronic device 100 to the audio playing device 300 may also be audio data with the timestamp of 2'30"00 or adjacent thereto.

[0320] The difference between the Pth moment and the Mth moment is the playback delay of the audio playback device 200 .

[0321] The audio playback device 200 receives the audio data corresponding to the first timestamp sent by the electronic device 100 at time M. After the playback delay of the audio playback device 200, that is, at time 3, the timestamp of the last audio data played by the audio playback device 200 is the first timestamp. Thereafter, the electronic device 100 stops playing the audio data.

[0322] The difference between time 3 and time 2 is the playback delay of the audio playback device 300 .

[0323] The audio playback device 300 receives the audio data corresponding to the second timestamp sent by the electronic device 100 at time N. After the playback delay of the audio playback device 300, that is, at time 3, the audio data played by the audio playback device 300 begins with the timestamp of the second timestamp. The electronic device 100 then plays the audio data starting with and after the second timestamp.

[0324] From the above analysis, it can be seen that when audio playback device 200 just stops playing audio data, audio playback device 300 just starts playing audio data. In addition, the timestamp when audio playback device 200 just stops playing audio data coincides with the timestamp when audio playback device 300 just starts playing audio data. This solves the problem of audio data interruption when electronic device 100 switches Bluetooth devices and improves the user experience.

[0325] S1301-S1308 can be referenced Figure 10 and Figure 12 The embodiments shown in this application will not be described in detail here.

[0326] In some embodiments, due to transmission network and hardware issues, the moment when the audio playback device 200 stops playing the audio data and the moment when the audio playback device 300 starts playing the audio data are not the same moment (e.g., moment P), that is, S1308 can be executed before S1307, S1307 can be executed after S1308, and S1301 and S1308 can be executed together. As long as the difference between the moment when the audio playback device 200 stops playing the audio data and the moment when the audio playback device 300 starts playing the audio data is within a certain threshold (e.g., 50ms), the user will not feel the existence of the delay.

[0327] In some embodiments, S1304-S1308 may be replaced by:

[0328] S1304: At the second moment, the electronic device 100 sends a stop playback instruction and the first audio frame to the audio playback device 200.

[0329] S1305 : At the third moment, the electronic device 100 sends a start playback instruction and a second audio frame to the audio playback device 300 .

[0330] S1306: After receiving the stop playback instruction and the first audio frame sent by the electronic device 100, the audio playback device 200 stops playing the audio data after playing the first audio frame at the first moment.

[0331] S1307 : After the electronic device 100 sends the start playing instruction and the second audio frame, the audio playing device 300 starts playing the second audio frame at the first moment.

[0332] The difference between the first moment and the second moment is the first playback delay of the audio playback device 200, and the difference between the first moment and the third moment is the second playback delay of the audio playback device 300.

[0333] The difference between the second moment and the third moment is the first value, and the delay difference between the first playback delay and the second playback delay is the first value.

[0334] When the first playback delay is greater than the second playback delay, the first moment is earlier than the second moment; when the first playback delay is less than the second playback delay, the second moment is earlier than the first moment.

[0335] When the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the first moment may be Figure 9 The 880ms shown, the second moment can be Figure 9 The third moment can be 720ms as shown. Figure 9 640ms as shown.

[0336] When the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the first moment may be Figure 9 The 880ms shown, the second moment can be Figure 9 The third moment can be 640ms as shown. Figure 9 720ms shown

[0337] The second audio frame is the next audio data frame adjacent to the first audio frame.

[0338] S1308: When the first audio playback device stops playing the audio data after playing the first audio frame, the electronic device disconnects from the first audio playback device.

[0339] In this way, the electronic device does not disconnect from the first audio playback device while establishing a connection with the second audio data. When the second audio playback device starts playing audio data and the first audio playback device stops playing audio data after playing the first audio frame, the electronic device disconnects from the first audio playback device, thereby enabling seamless playback of audio data.

[0340] In some embodiments, after the electronic device establishes a communication connection with the second audio playback device, before the electronic device starts sending a stop instruction to the first audio playback device or a start instruction to the second audio playback device, the electronic device also needs to calculate the playback delay between the first audio playback device and the second audio playback device. Specifically, the electronic device sends first test data to the first audio playback device and sends second test data to the second audio playback device. The electronic device receives first information sent by the first audio playback device, which includes a fourth moment and a fifth moment; wherein the fourth moment is the moment when the first test data leaves the electronic device, and the fifth moment is the moment when the first audio playback device plays the first test data; the electronic device receives second information sent by the second audio playback device, which includes a sixth moment and a seventh moment; wherein the sixth moment is the moment when the second test data leaves the electronic device, and the seventh moment is the moment when the second audio playback device plays the second test data; the electronic device determines a first playback delay, which is the difference between the fifth moment and the fourth moment; the electronic device determines a second playback delay, which is the difference between the seventh moment and the sixth moment.

[0341] In one possible implementation, if the electronic device has previously calculated the playback delay of the first audio playback device and the playback delay of the second audio playback device, the electronic device can save the playback delay of the first audio playback device and the playback delay of the second audio playback device in the electronic device. Thereafter, the electronic device does not need to recalculate the playback delay of the first audio playback device and the playback delay of the second audio playback device each time.

[0342] S1309: Does the electronic device 100 determine that the audio data is predictable audio data? If so, execute S1310-S1313; if not, execute S1314-S1319.

[0343] Exemplarily, the predictable audio data may be audio data played in a music or video application.

[0344] Exemplarily, the unpredictable audio data may be audio data in a real-time call, such as a voice call, a video call, and the like.

[0345] Because when the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, for unpredictable audio data, the electronic device 100 cannot obtain the audio data after the current timestamp in advance, so the audio playback device 200 and the audio playback device 300 will repeatedly play a section of audio data. In order to solve the problem of repeatedly playing a section of audio data, the volume of the audio playback device 200 gradually decreases when playing the repeated audio data segment, and the volume of the audio playback device 300 gradually increases when playing the repeated audio data segment, thereby solving the problem of repeated playback.

[0346] For predictable audio data, the electronic device 100 can obtain the audio data after the current timestamp in advance, so under ideal circumstances, the audio playback device 200 and the audio playback device 300 can be seamlessly connected.

[0347] From the above analysis, it can be seen that when the playback delay of the audio playback device 200 is smaller than that of the audio playback device 300, the types of audio data need to be classified because different types of audio data have different processing strategies.

[0348] This application can execute S1310-S1313 first and then execute S1314-S1319; it can also execute S1314-S1319 first and then execute S1310-S1313. Please do not make any limitations here.

[0349] In some embodiments, the electronic device 100 may not determine the type of audio data, and may process the audio data of all scenarios as real-time call application scenarios, and S1309 may not be executed.

[0350] S1310 : At the Mth moment (the sixth moment), the electronic device 100 sends a start playback instruction and the audio data (first audio frame) corresponding to the second timestamp to the audio playback device 300 .

[0351] S1311 : At the Nth moment (fifth moment), the electronic device 100 sends a stop playback instruction and the audio data corresponding to the first timestamp to the audio playback device 200 .

[0352] The Nth moment can be Figure 9 The 720ms moment is shown.

[0353] The Nth moment is greater than the Mth moment, and the difference between the Nth moment and the Mth moment is the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300.

[0354] At the Mth moment, after the electronic device 100 sends the start playback instruction and the audio data corresponding to the second timestamp to the audio playback device 300, after the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300 has passed, that is, at the Nth moment, the electronic device 100 sends the stop playback instruction and the audio data corresponding to the first timestamp to the audio playback device 200.

[0355] S1312: The audio playback device 200 stops playing the audio data at time P (the fourth time).

[0356] S1313: At the Pth moment (the fourth moment), the audio playback device 300 starts playing the audio data, and the timestamp is the second timestamp.

[0357] The Pth moment can be Figure 9 The 880ms moment is shown.

[0358] The difference between time 3 and time 2 is the playback delay of the audio playback device 200 .

[0359] The audio playback device 200 receives the audio data corresponding to the first timestamp sent by the electronic device 100 at time N. After the playback delay of the audio playback device 200, that is, at time 3, the timestamp of the last audio data played by the audio playback device 200 is the first timestamp. Thereafter, the electronic device 100 stops playing the audio data.

[0360] The difference between the Pth moment and the Mth moment is the playback delay of the audio playback device 300 .

[0361] The audio playback device 300 receives the audio data corresponding to the second timestamp sent by the electronic device 100 at time M. After the playback delay of the audio playback device 300, that is, at time 3, the audio data played by the audio playback device 300 begins with the timestamp of the second timestamp. Thereafter, the electronic device 100 plays the audio data starting with and after the second timestamp.

[0362] From the above analysis, it can be seen that when audio playback device 200 just stops playing audio data, audio playback device 300 just starts playing audio data. In addition, the timestamp when audio playback device 200 just stops playing audio data coincides with the timestamp when audio playback device 300 just starts playing audio data. This solves the problem of audio data interruption when electronic device 100 switches Bluetooth devices and improves the user experience.

[0363] S1310-S1313 can be referenced Figure 9 The embodiments shown in this application will not be described in detail here.

[0364] In some embodiments, due to transmission network and hardware issues, the moment when the audio playback device 200 stops playing the audio data and the moment when the audio playback device 300 starts playing the audio data are not the same moment (e.g., moment P), that is, S1313 can be executed before S1312, S1312 can be executed after S1313, or S1312 and S1313 can be executed together. As long as the difference between the moment when the audio playback device 200 stops playing the audio data and the moment when the audio playback device 300 starts playing the audio data is within a certain threshold (e.g., 50ms), the user will not feel the existence of the delay.

[0365] S1314 . At the Mth moment (the third moment), the electronic device 100 sends a start playback instruction, the audio data corresponding to the first timestamp (the first audio frame), and a volume gradually increasing instruction to the audio playback device 300 .

[0366] The Mth moment can be Figure 11 The 640ms moment is shown.

[0367] Since the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the electronic device 100 needs to first send a start playback instruction to the audio playback device 300 so that the audio playback device 200 just stops playing and the audio playback device 300 just starts playing.

[0368] That is, at the Mth moment, the electronic device 100 sends a start playback instruction to the audio playback device 300. At the Mth moment, the timestamp of the audio data played by the electronic device 100 is the first timestamp. The electronic device 100 also needs to send the audio data corresponding to the first timestamp and the volume gradually increasing instruction to the audio playback device 300.

[0369] It should be noted that the Mth moment is the system time of the electronic device 100. The first timestamp is the playing progress of the audio data played by the electronic device 100.

[0370] S1315 : At the Mth moment (the third moment), the electronic device 100 sends the audio data corresponding to the first timestamp and the volume gradually decreasing instruction to the audio playback device 200 .

[0371] The Mth moment can be Figure 11 The 640ms moment is shown.

[0372] Since the audio data is unpredictable, at the Mth moment, the electronic device 100 also needs to send the audio data corresponding to the first timestamp and the volume gradually decreasing instruction to the audio playback device 200.

[0373] It should be noted that the electronic device 100 may first execute S1315 and then execute S1314, or the electronic device 100 may first execute S1314 and then execute S1315, or the electronic device 100 may simultaneously execute S1314 and S1315, and this application does not limit this.

[0374] S1316: At time N, the electronic device 100 sends a stop playback instruction and audio data (a second audio frame) corresponding to a second timestamp to the audio playback device 200, where the second timestamp is greater than the first timestamp.

[0375] The Nth moment can be Figure 11 The 720ms moment is shown.

[0376] The audio data corresponding to the second timestamp can be Figure 11 The audio data shown has a timestamp of 2'30"80.

[0377] The Nth moment is greater than the Mth moment, and the difference between the Nth moment and the Mth moment is the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300.

[0378] At the Mth moment, after the electronic device 100 sends the start playback instruction and the audio data corresponding to the first timestamp to the audio playback device 300, after the difference between the playback delay of the audio playback device 200 and the playback delay of the audio playback device 300 has passed, that is, at the Nth moment, the electronic device 100 sends the stop playback instruction and the audio data corresponding to the second timestamp to the audio playback device 200.

[0379] Since the audio data is unpredictable, at the Nth moment, the electronic device 100 needs to send the audio data corresponding to the second timestamp to the audio playback device 300 .

[0380] S1317: The audio playback device 200 plays the audio data corresponding to the first timestamp at the Pth moment (the first moment).

[0381] The Pth moment can be Figure 11 The 800ms moment is shown.

[0382] The difference between time P and time M is the playback delay of the audio playback device 200. That is, at time M, the electronic device 100 sends the audio data corresponding to the first timestamp to the audio playback device 200. After the playback delay of the audio playback device 200, at time P, the audio playback device 200 plays the audio data corresponding to the first timestamp.

[0383] If the codec in the first Bluetooth device 100 stops working at time P, the timestamp of the audio data last decoded by the audio playback device 200 at time P is the second timestamp. The difference between time P and time N is the Bluetooth transmission delay and codec delay of the first Bluetooth device 100.

[0384] S1318. At the Qth moment (the second moment), the timestamp of the audio data last played by the audio playback device 200 is the second timestamp.

[0385] The Qth moment can be Figure 11 The 880ms moment is shown.

[0386] The difference between the Qth moment and the Nth moment is the playback delay of the audio playback device 200 , and the difference between the Qth moment and the Pth moment is the hardware delay of the audio playback device 200 .

[0387] It can be seen from S1317 that at time P, the timestamp of the audio data finally decoded by the audio playback device 200 is the second timestamp. After the hardware delay of the audio playback device 200, that is, at time Q, the timestamp of the audio data finally played by the audio playback device 200 is the second timestamp.

[0388] S1319: At the Qth moment (the second moment), the audio playback device 300 starts playing the audio data with the first timestamp.

[0389] The Qth moment can be Figure 11 The 880ms moment is shown.

[0390] The difference between the Qth moment and the Mth moment is the playback delay of the audio playback device 300. It can be seen from S1315 that at the Mth moment, the electronic device 100 sends the audio data corresponding to the first timestamp to the audio playback device 200. After the playback delay of the audio playback device 300, the Qth moment is recorded. The timestamp of the audio data that the audio playback device 300 just starts to play is the first timestamp.

[0391] As can be seen from S1318 and S1319, the timestamp of the audio data last played by the audio playback device 200 is the second timestamp, and the timestamp of the audio data just started to be played by the audio playback device 300 is the first timestamp. Therefore, the audio playback device 300 will repeatedly play the audio data between the first timestamp and the second timestamp that the first Bluetooth device 300 has already played. To solve the problem of repeated playback, the electronic device 100 sends a volume reduction instruction to the audio playback device 200 while sending the audio data with the first timestamp to the audio playback device 200. The electronic device 100 also sends a volume increase instruction to the audio playback device 300 while sending the audio data with the first timestamp to the audio playback device 300. In this way, when the audio playback device 200 plays the audio data between timestamps 1 and 2, the volume of the played audio data gradually decreases, and when the audio playback device 300 plays the audio data between timestamps 1 and 2, the volume of the played audio data gradually increases, thus solving the problem of the two Bluetooth devices repeatedly playing audio data.

[0392] S1314-S1319 can be referenced Figure 11 The embodiments shown in this application will not be described in detail here.

[0393] In some embodiments, when the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, S1309 and S1319 can be replaced by:

[0394] When the playback delay of the audio playback device 200 is less than the playback delay of the audio playback device 300, the electronic device does not need to determine the type of audio data and processes both predictable audio data and unpredictable audio data as unpredictable audio data.

[0395] S1309 : At the third moment, the electronic device 100 sends the first instruction and the first audio frame to the audio playback device 200 .

[0396] S1310: At a third moment, the electronic device 100 sends a second instruction and a first audio frame to the audio playback device 300.

[0397] S1311: After receiving the first instruction and the first audio frame sent by the electronic device, the audio playback device 200 plays the first audio frame with decreasing volume at a first moment, and stops playing the audio data at a second moment.

[0398] S1312: After receiving the second instruction and the first audio frame sent by the electronic device, the audio playback device 300 plays the first audio frame with increasing volume at a second moment.

[0399] The second instruction includes a volume increase instruction and a start play instruction.

[0400] At the third moment, the electronic device 100 sends a first instruction and the first audio frame to the audio playback device 200; at the third moment, it sends a second instruction and the first audio frame to the audio playback device 300; wherein, the difference between the first moment and the third moment is the first playback delay of the audio playback device 200, and the difference between the second moment and the third moment is the second playback delay of the audio playback device 300; the difference between the second moment and the first moment is the first value, and the delay difference between the first playback delay and the second playback delay is the first value.

[0401] The first playback delay of the first audio playback device is the time from the moment the first audio frame leaves the electronic device until the first audio playback device plays the first audio frame, and the time is stopped. This period is the first playback delay of the first audio playback device. The second playback delay of the second audio playback device is the time from the moment the first audio frame leaves the electronic device until the second audio playback device plays the first audio frame, and the time is stopped. This period is the second playback delay of the second audio playback device. The first audio frame can be audio data for a real-time call, music, or video.

[0402] The first playback delay includes the Bluetooth transmission delay of the first audio device, the decoding delay of the first audio device, and the hardware delay of the first audio device. The second playback delay includes the Bluetooth transmission delay of the second audio device, the decoding delay of the second audio device, and the hardware delay of the second audio device.

[0403] The electronic device 100 also sends a second audio frame to the audio playback device 200. The first instruction is used to instruct the audio playback device 200 to play the first audio frame with the volume reduced at a first moment after receiving the first instruction and the first audio frame sent by the electronic device, and to stop playing the audio data after playing the second audio frame at a second moment.

[0404] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0405] The first instruction includes a volume reduction instruction and a stop playing instruction.

[0406] The first moment can be Figure 11 The 800ms moment shown, the second moment can be as follows Figure 11 The 880ms moment shown, the third moment can be as follows Figure 11 The 640ms moment is shown.

[0407] In some embodiments, before the electronic device begins sending a stop command to the first audio playback device or a start command to the second audio playback device, it also calculates the playback delay between the first and second audio playback devices. Specifically, the electronic device sends first test data to the first audio playback device and second test data to the second audio playback device. The electronic device receives first information from the first audio playback device, including the seventh and eighth times; the seventh time is the time when the first test data leaves the electronic device, and the eighth time is the time when the first audio playback device plays the first test data. The electronic device receives second information from the second audio playback device, including the ninth and tenth times; the ninth time is the time when the second test data leaves the electronic device, and the tenth time is the time when the second audio playback device plays the second test data. The electronic device determines a first playback delay, which is the difference between the eighth and seventh times. The electronic device determines a second playback delay, which is the difference between the tenth and ninth times. In this way, the electronic device calculates the playback delay between the first and second audio playback devices, enabling seamless playback of audio data when switching between the first and second audio playback devices.

[0408] In one possible implementation, if the electronic device has previously calculated the playback delay of the first audio playback device and the playback delay of the second audio playback device, the electronic device can save the playback delay of the first audio playback device and the playback delay of the second audio playback device in the electronic device. Thereafter, the electronic device does not need to recalculate the playback delay of the first audio playback device and the playback delay of the second audio playback device each time.

[0409] In some embodiments, before the electronic device begins sending a stop command to the first audio playback device or a start command to the second audio playback device, it also calculates the playback delay between the first and second audio playback devices. Specifically, the electronic device sends first test data to the first audio playback device and second test data to the second audio playback device. The electronic device receives first information from the first audio playback device, including the seventh and eighth times; the seventh time is the time when the first test data leaves the electronic device, and the eighth time is the time when the first audio playback device plays the first test data. The electronic device receives second information from the second audio playback device, including the ninth and tenth times; the ninth time is the time when the second test data leaves the electronic device, and the tenth time is the time when the second audio playback device plays the second test data. The electronic device determines a first playback delay, which is the difference between the eighth and seventh times. The electronic device determines a second playback delay, which is the difference between the tenth and ninth times. In this way, the electronic device calculates the playback delay between the first and second audio playback devices, enabling seamless playback of audio data when switching between the first and second audio playback devices.

[0410] In one possible implementation, if the electronic device has previously calculated the playback delay of the first audio playback device and the playback delay of the second audio playback device, the electronic device can save the playback delay of the first audio playback device and the playback delay of the second audio playback device in the electronic device. Thereafter, the electronic device does not need to recalculate the playback delay of the first audio playback device and the playback delay of the second audio playback device each time.

[0411] In some embodiments, when the playback delay of the audio playback device 200 is greater than the playback delay of the audio playback device 300, the electronic device 100 further performs the following steps:

[0412] When the first playback delay of audio playback device 200 is greater than the second playback delay of audio playback device 300, at a fifth moment, a first instruction and a first audio frame are sent to audio playback device 200. At a sixth moment, electronic device 100 sends a second instruction and a first audio frame to audio playback device 300. After receiving the first instruction and the first audio frame sent by the electronic device, the first audio playback device plays the first audio frame at a decreasing volume at a fourth moment and stops playing the audio data after playing the first audio frame. After receiving the second instruction and the first audio frame sent by the electronic device, the second audio playback device plays the first audio frame at a increasing volume at a fourth moment.

[0413] The volume reduction may be a linear reduction of the volume, or a gradient reduction of the volume, wherein the volume stops decreasing after decreasing to a preset value, or stops decreasing after decreasing for a certain period of time.

[0414] The volume increase can be a linear increase, a gradient increase, a volume increase to a preset value and then stop increasing, or a volume increase to a certain time and then stop increasing. This application does not limit the volume decrease and volume increase methods.

[0415] When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and the electronic device sends a second instruction and a first audio frame to the second audio playback device. Afterwards, ideally, the first audio playback device stops playing the audio data after playing the first audio frame, and the second audio playback device just starts playing the first audio frame. That is, the audio data repeatedly played by the first audio playback device and the second audio playback device is the first audio frame. In order to ensure an uninterrupted process when the electronic device switches playback devices, the first audio frame is played by the first audio playback device with the volume decreased, and the second audio playback device is played with the volume increased, thereby solving the problem of repeated playback and achieving uninterrupted playback of audio data.

[0416] In one possible implementation, the first instruction includes a volume-down instruction and a stop-play instruction; the second instruction includes a volume-up instruction and a start-play instruction. The volume-down instruction instructs the first audio playback device to play the first audio frame at a reduced volume after receiving the first audio frame; the stop-play instruction instructs the first audio playback device to stop playing the audio data after receiving the second audio frame and completing the second audio frame. The volume-up instruction instructs the second audio playback device to play the first audio frame at a increased volume after receiving the first audio frame.

[0417] In a possible implementation, the electronic device may also send a volume increase instruction and a stop playback instruction to the first audio playback device respectively.

[0418] Among them, the fourth moment can be Figure 10 or Figure 12 The first audio frame can be Figure 10 or Figure 12 The audio data at the 880ms moment with a timestamp of 2'30"00 is shown.

[0419] The fifth moment can be Figure 10 or Figure 12 The sixth moment can be Figure 10 or Figure 12 The 720ms moment is shown.

[0420] The first instruction includes a volume decrease instruction and a stop playing instruction. The second instruction includes a volume increase instruction and a start playing instruction.

[0421] When the first playback delay of the first audio playback device is greater than the second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and then sends a second instruction and a first audio frame to the second audio playback device. The first audio playback device receives the first instruction and the first audio frame at a fourth moment, and the second audio playback device receives the second instruction and the second audio frame at a fifth moment. The fourth moment precedes the fifth moment, and the difference between the fifth moment and the fourth moment is the difference between the first playback delay and the second playback delay. Ideally, the first audio playback device stops playing the audio data after playing the first audio frame, and the second audio playback device just begins playing the first audio frame. That is, the audio data repeatedly played by the first and second audio playback devices is the first audio frame. To ensure an uninterrupted process when the electronic device switches playback devices, the first audio playback device plays the first audio frame at a decreasing volume, while the second audio playback device plays the first audio frame at a increasing volume. This resolves the issue of repeated playback and ensures uninterrupted audio playback.

[0422] Figure 14 A schematic structural diagram of the electronic device 100 is shown.

[0423] The embodiment will be described in detail below using the electronic device 100 as an example. It should be understood that Figure 14 The electronic device 100 shown is only one example, and the electronic device 100 may have more Figure 14 The more or less components shown in the figure can be combined with two or more components, or can have different component configurations. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0424] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0425] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0426] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0427] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0428] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0429] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include 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.

[0430] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C bus lines. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, and the like via different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K via the I2C interface, enabling communication between the processor 110 and the touch sensor 180K via the I2C bus interface, thereby implementing the touch function of the electronic device 100.

[0431] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface, enabling the function of answering calls through a Bluetooth headset.

[0432] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0433] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface, enabling the function of playing music through Bluetooth headphones.

[0434] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display 194 and the camera 193. MIPI interfaces include the camera serial interface (CSI) and the display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the camera function of the electronic device 100. The processor 110 and the display 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0435] The GPIO interface can be configured via software. The GPIO interface can be configured as either a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to the camera 193, display 194, wireless communication module 160, audio module 170, sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0436] The USB interface 130 is an interface that complies with USB standards and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, or to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices, such as augmented reality devices.

[0437] It is understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

[0438] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device via the power management module 141.

[0439] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0440] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0441] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0442] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0443] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0444] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0445] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0446] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0447] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0448] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.

[0449] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.

[0450] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0451] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0452] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.

[0453] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, speech recognition, and text comprehension.

[0454] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0455] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0456] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0457] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.

[0458] The speaker 170A, also called a "speaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.

[0459] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be heard by placing the receiver 170B close to the human ear.

[0460] Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to realize sound signal collection, noise reduction, and identification of sound sources, and realize directional recording function, etc.

[0461] The headphone jack 170D is used to connect a wired headphone and can be the USB interface 130 or a 3.5mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0462] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be located on display screen 194. There are many types of pressure sensors 180A, such as resistive, inductive, and capacitive. A capacitive pressure sensor can include at least two parallel plates made of conductive material. When force acts on pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the intensity of the pressure based on this change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the touch intensity based on pressure sensor 180A. Electronic device 100 can also calculate the touch location based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch location but with different touch intensities can correspond to different operation instructions. For example, when a touch operation with an intensity less than a first pressure threshold is applied to a short message application icon, a command to view short messages is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to a short message application icon, a command to create a new short message is executed.

[0463] The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and somatosensory game scenes.

[0464] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude using the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.

[0465] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover based on the magnetic sensor 180D. Based on the detected opening and closing status of the case or flip cover, features such as automatic unlocking of the flip cover can be configured.

[0466] Accelerometer 180E can detect the magnitude of acceleration of electronic device 100 in all directions (generally three axes). It can also detect the magnitude and direction of gravity when electronic device 100 is stationary. It can also be used to identify the electronic device's posture, enabling applications such as switching between landscape and portrait modes and pedometers.

[0467] The distance sensor 180F is used to measure distance. The electronic device 100 can measure distance using infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure distance to achieve fast focusing.

[0468] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user is holding the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0469] Ambient light sensor 180L is used to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display screen 194 based on the perceived ambient light. Ambient light sensor 180L can also be used to automatically adjust white balance when taking photos. Ambient light sensor 180L can also work with proximity light sensor 180G to detect whether electronic device 100 is in a pocket to prevent accidental touches.

[0470] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0471] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to prevent the electronic device 100 from shutting down abnormally due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to prevent abnormal shutdown due to low temperature.

[0472] The touch sensor 180K is also called a "touch panel." The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen." The touch sensor 180K is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operations can be provided via the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, in a location different from that of the display screen 194.

[0473] The bone conduction sensor 180M can obtain vibration signals. In some embodiments, the bone conduction sensor 180M can obtain vibration signals from the vibrating bones of the human body. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure pulse signals. In some embodiments, the bone conduction sensor 180M can also be set in headphones to form bone conduction headphones. The audio module 170 can parse out voice signals based on the vibration signals of the vibrating bones of the human body obtained by the bone conduction sensor 180M to implement voice functions. The application processor can parse heart rate information based on the blood pressure pulse signals obtained by the bone conduction sensor 180M to implement heart rate detection functions.

[0474] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.

[0475] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0476] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power level changes, messages, missed calls, notifications, etc.

[0477] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0478] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.

[0479] Figure 15 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.

[0480] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0481] The application layer can include a series of application packages.

[0482] like Figure 15 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0483] The application framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0484] like Figure 15 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0485] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.

[0486] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0487] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.

[0488] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering, hanging up, etc.).

[0489] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0490] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0491] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.

[0492] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0493] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0494] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0495] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0496] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0497] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0498] A 2D graphics engine is a drawing engine for 2D drawings.

[0499] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.

[0500] The following describes the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0501] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, touch operation timestamp, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture a still image or video through the camera 193.

[0502] like Figure 16 As shown, Figure 16 The schematic diagram of the hardware structure of the audio playback device is shown as an example.

[0503] Figure 16 The structural diagram of the audio playback device (eg, the audio playback device 200 and the audio playback device 300 ) provided in the embodiments of the present application is exemplarily shown.

[0504] It should be understood that Figure 16 The audio playback device shown is only an example and the audio playback device may have more Figure 16 The more or less components shown in the figure can be combined with two or more components, or can have different component configurations. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0505] like Figure 16 As shown, the audio playback device may include: a processor 201, a memory 202, a wireless communication processing module 203, a power switch 205, a USB communication processing module 206, and an audio module 207.

[0506] Processor 201 can be used to read and execute computer-readable instructions. In a specific implementation, processor 201 may primarily include a controller, an arithmetic unit (ALU), and registers. The controller is primarily responsible for decoding instructions and issuing control signals for operations corresponding to the instructions. The ALU is primarily responsible for storing register operands and intermediate operation results temporarily stored during instruction execution. In a specific implementation, the hardware architecture of processor 201 may be an application-specific integrated circuit (ASIC), MIPS, ARM, or NP architecture, among others.

[0507] In some embodiments, the processor 201 may be configured to parse signals received by the Bluetooth communication processing module 203A, such as a pairing mode modification request sent by the electronic device 100, etc. The processor 201 may be configured to perform corresponding processing operations based on the parsing results, such as generating a pairing mode modification response, etc.

[0508] The memory 202 is coupled to the processor 201 and is used to store various software programs and / or multiple sets of instructions. In a specific implementation, the memory 202 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. The memory 202 may store an operating system, such as an embedded operating system such as uCOS, VxWorks, or RTLinux. The memory 202 may also store a communication program that can be used to communicate with the electronic device 100, one or more servers, or other devices.

[0509] The wireless communication processing module 203 may include one or more of a Bluetooth (BT) communication processing module 203A and a WLAN communication processing module 203B.

[0510] In some embodiments, one or more of the Bluetooth (BT) communication processing module and the WLAN communication processing module can monitor signals transmitted by other devices (such as the electronic device 100), such as detection requests, scanning signals, etc., and can send response signals, such as detection responses, scanning responses, etc., so that other devices (such as the electronic device 100) can discover the audio playback device and establish a wireless communication connection with other devices (such as the electronic device 100), and communicate with other devices (such as the electronic device 100) through one or more wireless communication technologies in Bluetooth or WLAN.

[0511] In other embodiments, one or more of the Bluetooth (BT) communication processing module and the WLAN communication processing module may also transmit signals, such as broadcast Bluetooth signals and beacon signals, so that other devices (such as electronic device 100) can discover the audio playback device and establish wireless communication connections with other devices (such as electronic device 100), and communicate with other devices (such as electronic device 100) through one or more wireless communication technologies in Bluetooth or WLAN.

[0512] The wireless communication processing module 203 may further include a cellular mobile communication processing module (not shown). The cellular mobile communication processing module may communicate with other devices (such as a server) via cellular mobile communication technology.

[0513] In some embodiments, the Bluetooth communication processing module may have one or more antennas. The antennas may be used to transmit and receive electromagnetic wave signals. Each antenna in the audio playback device may be used to cover a single or multiple communication frequency bands.

[0514] The power switch 205 may be used to control the power supply to the audio playback device.

[0515] The USB communication processing module 206 may be used to communicate with other devices via a USB interface (not shown). In some embodiments, the audio playback device may not include the USB communication processing module 206.

[0516] The audio module 207 can be used to output audio signals through the audio output interface, so that the audio playback device can support audio playback. The audio module can also be used to receive audio data through the audio input interface. The audio playback device can be a media playback device such as a Bluetooth headset.

[0517] In some embodiments, the audio playback device may further include a display screen (not shown), wherein the display screen may be used to display images, prompt information, etc. The display screen may be a liquid crystal display (LCD), an organic light-emitting diode (OLED) display screen, an active-matrix organic light-emitting diode (AMOLED) display screen, a flexible light-emitting diode (FLED) display screen, a quantum dot light-emitting diode (QLED) display screen, and the like.

[0518] In some embodiments, the audio playback device may further include a serial interface such as an RS-232 interface. The serial interface may be connected to other devices, such as an audio player such as a speaker, so that the Bluetooth device and the audio player can collaborate to play audio and video.

[0519] It is understandable that Figure 16 The illustrated structure does not constitute a specific limitation on the Bluetooth device. In other embodiments of the present application, the Bluetooth device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0520] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.< / videoview> < / imgview> < / textview>

Claims

1. An audio data playback system, characterized in that: The system includes an electronic device, a first audio playback device, and a second audio playback device; The electronic device is configured to send audio data to a first audio playback device; The first audio playback device is configured to play the audio data; The electronic device is further used for: Establishing a communication connection with the second audio playback device; Sending a stop playback instruction and a first audio frame to the first audio playback device; Sending a start playback instruction and a second audio frame to the second audio playback device; The first audio playback device is further configured to, after receiving the stop playback instruction and the first audio frame sent by the electronic device, stop playing the audio data after playing the first audio frame at a first moment; the second audio playback device, configured to start playing the second audio frame at the first moment after receiving the start playing instruction and the second audio frame sent by the electronic device; The second audio frame is an adjacent frame following the first audio frame.

2. The system according to claim 1, wherein: The electronic device is specifically used for: At a second moment, sending the stop playback instruction and the first audio frame to the first audio playback device; At a third moment, sending the start playback instruction and the second audio frame to the second audio playback device; The difference between the first moment and the second moment is the first playback delay of the first audio playback device, and the difference between the first moment and the third moment is the second playback delay of the second audio playback device; The difference between the second moment and the third moment is a first value, and the delay difference between the first playback delay and the second playback delay is the first value.

3. An audio data playback system, characterized in that: The system includes an electronic device, a first audio playback device, and a second audio playback device; The electronic device is configured to send audio data to a first audio playback device; The first audio playback device is configured to play the audio data; The electronic device is further used for: Establishing a communication connection with the second audio playback device; When a first playback delay of the first audio playback device is less than a second playback delay of the second audio playback device, sending a first instruction and a first audio frame to the first audio playback device; Sending a second instruction and the first audio frame to the second audio playback device; The first audio playback device is further configured to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame with decreasing volume at a first moment, and stop playing the audio data at a second moment; The second audio playback device is configured to play the first audio frame at a gradually increased volume at the second moment after receiving the second instruction and the first audio frame sent by the electronic device.

4. The system according to claim 3, characterized in that When a first playback delay of the first audio playback device is greater than a second playback delay of the second audio playback device, the electronic device is further configured to: Sending a first instruction and a first audio frame to the first audio playback device; Sending a second instruction and the first audio frame to the second audio playback device; The first audio playback device is further configured to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame with the volume reduced at a fourth moment, and stop playing the audio data after playing the first audio frame; The second audio playback device is further configured to play the first audio frame with increasing volume at the fourth moment after receiving the second instruction and the first audio frame sent by the electronic device.

5. A method for playing audio data, characterized in that: The method comprises: The electronic device sends the audio data to the first audio playback device, and plays the audio data through the first audio playback device; The electronic device establishes a communication connection with the second audio playback device; The electronic device sends a stop playback instruction and a first audio frame to the first audio playback device; wherein the stop playback instruction is used to instruct the first audio playback device to stop playing audio data after playing the first audio frame at a first moment after receiving the stop playback instruction and the first audio frame sent by the electronic device; The electronic device sends a start playing instruction and a second audio frame to the second audio playback device; wherein the start playing instruction is used to instruct the second audio playback device to start playing the second audio frame at the first time after receiving the start playing instruction and the second audio frame sent by the electronic device; The second audio frame is an adjacent frame following the first audio frame.

6. The method according to claim 5, characterized in that The electronic device sending a stop playback instruction and a first audio frame to the first audio playback device specifically includes: At a second moment, the electronic device sends the stop playback instruction and the first audio frame to the first audio playback device; The electronic device sending a start playback instruction and a second audio frame to the second audio playback device specifically includes: At a third moment, the electronic device sends the start playing instruction and the second audio frame to the second audio playing device; The difference between the first moment and the second moment is the first playback delay of the first audio playback device, and the difference between the first moment and the third moment is the second playback delay of the second audio playback device; The difference between the second moment and the third moment is a first value, and the delay difference between the first playback delay and the second playback delay is the first value.

7. The method according to claim 5, characterized in that The method further comprises: When the first audio playback device stops playing audio data after playing the first audio frame, the electronic device disconnects from the first audio playback device.

8. The method according to claim 6, characterized in that When the first playback delay is greater than the second playback delay, the first moment is earlier than the second moment; When the first playback delay is less than the second playback delay, the second moment is earlier than the first moment.

9. The method according to any one of claims 5 to 8, characterized in that: After the electronic device establishes a communication connection with the second audio playback device, the method further includes: The electronic device sends first test data to the first audio playback device and sends second test data to the second audio playback device; The electronic device receives first information including a fourth time and a fifth time sent by the first audio playback device, wherein the fourth time is the time when the first test data leaves the electronic device, and the fifth time is the time when the first audio playback device plays the first test data; The electronic device receives second information including a sixth time and a seventh time sent by the second audio playback device, wherein the sixth time is the time when the second test data leaves the electronic device, and the seventh time is the time when the second audio playback device plays the second test data; The electronic device determines a first playback delay, where the first playback delay is a difference between the fifth moment and the fourth moment; The electronic device determines a second playback delay, where the second playback delay is a difference between the seventh moment and the sixth moment.

10. A method for playing audio data, characterized in that: The method comprises: The electronic device sends the audio data to the first audio playback device, and plays the audio data through the first audio playback device; The electronic device establishes a communication connection with the second audio playback device; When a first playback delay of the first audio playback device is less than a second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and sends a second instruction and the first audio frame to the second audio playback device; The first instruction is used to instruct the first audio playback device to play the first audio frame at a decreasing volume at a first moment after receiving the first instruction and the first audio frame sent by the electronic device, and to stop playing the audio data at a second moment; The second instruction is used to instruct the second audio playback device to play the first audio frame with increasing volume at the second moment after receiving the second instruction and the first audio frame sent by the electronic device.

11. The method according to claim 10, characterized in that The method comprises: The electronic device sends a second audio frame to the first audio playback device; The first instruction is used to instruct the first audio playback device to play the first audio frame at a decreasing volume at a first moment after receiving the first instruction and the first audio frame sent by the electronic device, and to stop playing the audio data at a second moment. Specifically includes: The first instruction is used to instruct the first audio playback device to, after receiving the first instruction and the first audio frame sent by the electronic device, play the first audio frame with the volume reduced at a first moment, and stop playing audio data after playing the second audio frame at a second moment.

12. The method according to claim 10, characterized in that The electronic device sending a first instruction and a first audio frame to the first audio playback device specifically includes: At a third moment, the electronic device sends the first instruction and the first audio frame to the first audio playback device; The electronic device sending a second instruction and the first audio frame to the second audio playback device specifically includes: At the third moment, the electronic device sends the second instruction and the first audio frame to the second audio playback device; The difference between the first moment and the third moment is the first playback delay of the first audio playback device, and the difference between the second moment and the third moment is the second playback delay of the second audio playback device; The difference between the second moment and the first moment is a first value, and the delay difference between the first playback delay and the second playback delay is the first value.

13. The method according to claim 10, characterized in that The method further comprises: When a first playback delay of the first audio playback device is greater than a second playback delay of the second audio playback device, the electronic device sends a first instruction and a first audio frame to the first audio playback device, and sends a second instruction and the first audio frame to the second audio playback device; The first instruction is used to instruct the first audio playback device to play the first audio frame with the volume reduced at a fourth moment after receiving the first instruction and the first audio frame sent by the electronic device, and to stop playing the audio data after playing the first audio frame; The second instruction is used to instruct the second audio playback device to play the first audio frame with increasing volume at the fourth moment after receiving the second instruction and the first audio frame sent by the electronic device.

14. The method according to claim 13, characterized in that The electronic device sending a first instruction and a first audio frame to the first audio playback device specifically includes: At a fifth moment, the electronic device sends the first instruction and the first audio frame to the first audio playback device; The electronic device sending a second instruction and the first audio frame to the second audio playback device specifically includes: At a sixth moment, the electronic device sends the second instruction and the first audio frame to the second audio playback device; The difference between the fourth moment and the fifth moment is the first playback delay of the first audio playback device, and the difference between the fourth moment and the sixth moment is the second playback delay of the second audio playback device. A difference between the sixth moment and the fifth moment is a first value, and the first playback delay and the second playback delay are the first value.

15. The method according to any one of claims 10 to 14, characterized in that: After the electronic device establishes a communication connection with the second audio playback device, the method further includes: The electronic device sends first test data to the first audio playback device and sends second test data to the second audio playback device; The electronic device receives first information including a seventh time and an eighth time sent by the first audio playback device, wherein the seventh time is the time when the first test data leaves the electronic device, and the eighth time is the time when the first audio playback device plays the first test data; The electronic device receives second information including a ninth time and a tenth time sent by the second audio playback device, wherein the ninth time is the time when the second test data leaves the electronic device, and the tenth time is the time when the second audio playback device plays the second test data; The electronic device determines the first playback delay, where the first playback delay is a difference between the eighth moment and the seventh moment; The electronic device determines the second playback delay, where the second playback delay is the difference between the tenth moment and the ninth moment.

16. An electronic device, characterized in that: The electronic device comprises one or more processors and one or more memories; the one or more memories are coupled to the one or more processors, the one or more memories are used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method as described in any one of claims 5 to 15.

Citation Information

Patent Citations

  • Audio playing method, audio playing apparatus, electronic device and computer readable storage medium

    CN109379491A

  • Audio playing method and device, electronic device and computer-readable medium

    CN109445739A