Audio playback method and electronic device

By automatically switching the audio playback mode and adjusting the volume by detecting the direction of movement of the electronic device, the problem of low switching efficiency of audio playback mode in the prior art is solved, and more efficient user experience adaptation is achieved.

WO2025091892A1PCT designated stage expired Publication Date: 2025-05-08HUAWEI TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/096444
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-30
Filing Date
2024-05-30
Publication Date
2025-05-08

AI Technical Summary

Technical Problem

In the prior art, electronic devices require manual operation of the user when they need to switch the audio playback mode, resulting in low switching efficiency, especially when the user cannot free up his hands to operate.

Method used

By detecting the movement of the electronic device in a direction close to or away from the user's head, the audio playback mode is automatically switched and the volume is gradually adjusted during the switch to ensure that the user experience is not affected.

Benefits of technology

It realizes that electronic devices automatically switch audio playback modes in different scenarios, improves switching efficiency, adapts to users' needs in different situations, and avoids the problem of affecting user experience due to sudden volume changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024096444_08052025_PF_FP_ABST
    Figure CN2024096444_08052025_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses an audio playback method and an electronic device. The method is executed by the electronic device. In the method, the electronic device can automatically switch an audio playback mode, solving the problem in the prior art that the efficiency is too low due to a need of switching the audio playback mode by means of manual operation. In addition, in embodiments of the present application, the electronic device can adaptively adjust an audio playback state or audio playback volume when it is determined that a user has the intent of switching the audio playback mode (e.g., the electronic device moves close to or away from the head of a user), for example, when the audio playback mode is switched (e.g., switching from a first audio playback mode to a second audio playback mode), playback of an audio is paused, or the volume when the audio is played back in the first audio playback mode is gradually reduced and the volume when the audio is played back in the second audio playback mode is gradually reduced, so that the user experience is not affected due to the sudden change of the audio playback volume when the audio playback mode is switched, meeting the requirements of the user.
Need to check novelty before this filing date? Find Prior Art

Description

Audio playing method and electronic device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of the People's Republic of China on October 30, 2023, with application number 202311428672.8 and invention name "A Method and Electronic Device for Audio Playback", the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the technical field of electronic devices, and in particular to an audio playback method and electronic device. Background Art

[0004] Currently, electronic devices (such as mobile phones) have two audio playback modes: receiver mode and speaker mode. Depending on different audio playback scenarios, the electronic device may need to switch between the two audio playback modes. For example, when a user is holding something and a call comes in, they may need to switch from receiver mode to speaker mode to answer the call.

[0005] Existing switching methods primarily rely on specific gestures (e.g., a user tapping the speaker button within a call interface). However, since this requires manual operation, switching the audio playback mode cannot be completed when the user cannot free their hands to do so (e.g., while driving). Therefore, existing switching methods suffer from low switching efficiency.

[0006] Summary of the Invention

[0007] Embodiments of the present application provide an audio playback method and an electronic device for improving the switching efficiency of audio playback modes.

[0008] In a first aspect, an embodiment of the present application provides an audio playback method, which is applicable to an electronic device, and the method includes: receiving a playback instruction for a first audio; playing the first audio in a first audio playback mode, the first audio playback mode including a speaker mode or an earpiece mode; detecting that the electronic device is moving in a direction closer to or away from the user's head; pausing playback of the first audio, or gradually reducing the volume of the first audio when played in the first audio playback mode, and playing the first audio in a second audio playback mode and gradually increasing the volume of the first audio when played in the second audio playback mode; wherein the second audio playback mode is different from the first audio playback mode.

[0009] In the above solution, the electronic device can automatically switch the audio playback mode, which solves the problem of low efficiency caused by the need to manually switch the audio playback mode in the prior art. In addition, in an embodiment of the present application, the electronic device can adaptively adjust the audio playback state or audio playback volume when it determines that the user has the intention to switch the audio playback mode (for example, the electronic device is close to or away from the user's head). For example, when switching the audio playback mode (for example, switching from the first audio playback mode to the second audio playback mode), the audio is paused, or the volume of the audio when playing in the first audio playback mode and the volume of the audio when playing in the second audio playback mode are gradually reduced, so that when switching the audio playback mode, the user experience is not affected by the sudden change of the audio playback volume, and the user's needs are adapted.

[0010] In one possible implementation, the detecting that the electronic device is moving toward or away from the user's head includes: detecting that the electronic device is moving toward or away from the user's head at a first moment, the duration between the first moment and the second moment is less than a preset duration, and the second moment is the moment when the electronic device receives a play instruction for the first audio.

[0011] In this implementation, the electronic device can determine the user's intention, that is, whether the user is ready to switch the audio playback mode, based on whether the electronic device is detected moving toward or away from the user's head at the first moment. For example, within 2 seconds after playing the voice message in speaker mode, if the electronic device is detected moving toward the user's head, it can be determined that the user is ready to play the voice message in earpiece mode.

[0012] In one possible implementation, the first audio playback mode is a speaker mode, the second audio mode is an earpiece mode, and the distance between the electronic device and the user's head is greater than the first distance; when it is detected that the electronic device is moving in a direction close to the user's head, the playback of the first audio is paused, or the volume of the first audio when played in the speaker mode is gradually reduced, and the first audio is played in the earpiece mode and the volume of the first audio when played in the earpiece mode is gradually increased.

[0013] In one possible implementation, the method further includes: when it is detected that the electronic device is moving in a direction away from the user's head, pausing the playing of the first audio, or gradually reducing the volume of the first audio when played in earpiece mode, and playing the first audio in speaker mode and gradually increasing the volume of the first audio when played in the speaker mode.

[0014] In this implementation, taking the example of an electronic device being away from the user's head and playing the first audio in speaker mode, when the electronic device gradually approaches the user's head, the electronic device can switch to earpiece mode, that is, play the first audio in earpiece mode, and the first audio can be paused when switching, or the volume of the first audio when played in speaker mode can be gradually reduced and the volume of the first audio when played in earpiece mode can be gradually increased. When the electronic device approaches the user's head and then gradually moves away from the user's head again, the electronic device can switch to speaker mode again, that is, play the first audio in speaker mode, and the first audio can be paused when switching, or the volume of the first audio when played in earpiece mode can be gradually reduced and the volume of the first audio when played in speaker mode can be gradually increased. Therefore, when switching the audio playback mode, the user experience will not be affected by the sudden change in the audio playback volume, which adapts to the needs of the user.

[0015] In one possible implementation, the first audio playback mode is a speaker mode, the second audio mode is an earpiece mode, and the distance between the electronic device and the user's head is less than the second distance; when it is detected that the electronic device is moving in a direction away from the user's head, the playback of the first audio is paused, or the volume of the first audio when played in the speaker mode is gradually increased.

[0016] In one possible implementation, the method further includes: when it is detected that the electronic device is moving in a direction close to the user's head, pausing the playback of the first audio, or gradually reducing the volume of the first audio when played in speaker mode, and playing the first audio in earpiece mode and gradually increasing the volume of the first audio when played in the earpiece mode.

[0017] In this implementation, taking the example of an electronic device being close to the user's head and playing the first audio in speaker mode, when the electronic device gradually moves away from the user's head, the electronic device may not switch to earpiece mode, that is, continue to play the first audio in speaker mode, but may pause playing the first audio, or may gradually increase the volume of the first audio when playing in speaker mode. When the electronic device gradually approaches the user's head again after moving away from the user's head, the electronic device may switch to earpiece mode, that is, play the first audio in earpiece mode, and may pause playing the first audio when switching, or may gradually reduce the volume of the first audio when playing in speaker mode and gradually increase the volume of the first audio when playing in earpiece mode. Therefore, when switching the audio playback mode, the user experience will not be affected by the sudden change in the audio playback volume, which adapts to the needs of the user.

[0018] In one possible implementation, the first audio playback mode is an earpiece mode, the second audio mode is a speaker mode, and the distance between the electronic device and the user's head is greater than the first distance; when it is detected that the electronic device is moving in a direction close to the user's head, the playback of the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced.

[0019] In one possible implementation, the method further includes: when it is detected that the electronic device is moving in a direction away from the user's head, pausing the playing of the first audio, or gradually reducing the volume of the first audio when played in earpiece mode, and playing the first audio in speaker mode and gradually increasing the volume of the first audio when played in the speaker mode.

[0020] In this implementation, taking the example of an electronic device being away from the user's head and playing the first audio in earpiece mode, when the electronic device gradually approaches the user's head, the electronic device may not switch to speaker mode, that is, continue to play the first audio in earpiece mode, but may pause playing the first audio, or may gradually reduce the volume of the first audio when played in earpiece mode (or gradually increase the volume of the first audio when played in earpiece mode, or keep the volume of the first audio when played in earpiece mode unchanged). When the electronic device approaches the user's head and then gradually moves away from the user's head again, the electronic device may switch to speaker mode, that is, play the first audio in speaker mode, and may pause playing the first audio when switching, or may gradually reduce the volume of the first audio when played in earpiece mode and gradually increase the volume of the first audio when played in speaker mode. Therefore, when switching the audio playback mode, the user experience will not be affected by the sudden change in the audio playback volume, which adapts to the needs of the user.

[0021] In one possible implementation, the first audio playback mode is an earpiece mode, the second audio mode is a speaker mode, and the distance between the electronic device and the user's head is less than the second distance; when it is detected that the electronic device is moving in a direction away from the user's head, the playback of the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced, and the first audio is played in the speaker mode and the volume of the first audio when played in the speaker mode is gradually increased.

[0022] In one possible implementation, the method further includes: when it is detected that the electronic device is moving in a direction close to the user's head, pausing the playback of the first audio, or gradually reducing the volume of the first audio when played in speaker mode, and playing the first audio in earpiece mode and gradually increasing the volume of the first audio when played in the earpiece mode.

[0023] In this implementation, taking the example of an electronic device being close to the user's head and playing the first audio in earpiece mode, when the electronic device gradually moves away from the user's head, the electronic device can switch to speaker mode, that is, play the first audio in speaker mode, and pause the first audio when switching, or gradually reduce the volume of the first audio when playing in earpiece mode and gradually increase the volume of the first audio when playing in speaker mode. When the electronic device moves away from the user's head and gradually approaches the user's head again, the electronic device can switch to earpiece mode again, that is, play the first audio in earpiece mode, and pause the first audio when switching, or gradually reduce the volume of the first audio when playing in speaker mode and gradually increase the volume of the first audio when playing in earpiece mode. Therefore, when switching the audio playback mode, the user experience will not be affected by the sudden change in the audio playback volume, which adapts to the needs of the user.

[0024] In one possible implementation, after pausing the playback of the first audio, the method further includes: detecting that the distance between the electronic device and the user's head is greater than a third distance or less than a fourth distance, starting playback of the first audio and playing the first audio in the second audio playback mode.

[0025] In this implementation, if the electronic device pauses playing the first audio before switching the audio playback mode, the electronic device detects that the electronic device is close to or away from the user's head, starts playing the first audio and switches the audio playback mode, so that the user experience is not affected by pausing the audio playback after switching the audio playback mode.

[0026] In a possible implementation, the first audio includes at least one of an incoming call ringtone, multimedia audio, call voice, and a voice message.

[0027] In one possible implementation, receiving a play instruction for a first audio signal includes: receiving an incoming call; playing the first audio signal in a first audio playback mode includes: playing an incoming call ringtone in speaker mode; upon detecting that the electronic device is moving toward a user's head, gradually reducing the volume of the incoming call ringtone in speaker mode; answering the call when determining that the distance between the electronic device and the user's head is less than a fourth distance, and playing the call audio in receiver mode. In this implementation, the electronic device can answer calls without pressing a button.

[0028] In the second aspect, an embodiment of the present application further provides an audio playback device. The audio playback device has the function of implementing the behavior in the method embodiment described in the first aspect or any possible design of the first aspect. The audio playback device may be the electronic device described in the first aspect, or a functional module (such as a chip system) configured in the electronic device, or a larger device including the electronic device. The first device includes corresponding means (means) or modules for executing the above method. For example, the audio playback device may include a processing unit (sometimes also referred to as a processing module) and a transceiver unit (sometimes also referred to as a transceiver module).

[0029] Optionally, a processing unit is used to receive a playback instruction for a first audio; play the first audio in a first audio playback mode, the first audio playback mode including a speaker mode or an earpiece mode; detect that the electronic device is moving toward or away from the user's head; pause playback of the first audio, or gradually reduce the volume of the first audio when played in the first audio playback mode, and play the first audio in a second audio playback mode and gradually increase the volume of the first audio when played in the second audio playback mode; wherein the second audio playback mode is different from the first audio playback mode.

[0030] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions, which, when executed by the processor, enable the electronic device to perform the method described in the first aspect or any possible design of the first aspect.

[0031] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which is used to store a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect or any possible design of the first aspect.

[0032] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program, which, when run on a computer, enables the computer to execute the method described in the first aspect or any possible design of the first aspect.

[0033] In a sixth aspect, an embodiment of the present application also provides a chip system, comprising a processor and an interface, wherein the processor is used to call and run instructions from the interface so that the chip system executes the method described in the first aspect or any possible design of the first aspect.

[0034] The beneficial effects of the second to sixth aspects and their possible designs can refer to the description of the beneficial effects of the method described in the first aspect and any possible design thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] FIG1 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0036] FIG2 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;

[0037] FIG3 is a schematic diagram of an interface for starting audio playback provided in an embodiment of the present application;

[0038] FIG4 is a schematic diagram of an audio playback scenario provided in an embodiment of the present application;

[0039] FIG5 is a schematic diagram of another audio playback scenario provided in an embodiment of the present application;

[0040] FIG6 is a schematic diagram of another audio playback scenario provided in an embodiment of the present application;

[0041] FIG7 is a schematic diagram of another audio playback scenario provided in an embodiment of the present application;

[0042] FIG8 is a schematic diagram of a volume curve provided in an embodiment of the present application;

[0043] FIG9 is a schematic diagram of the hardware structure of another electronic device provided in an embodiment of the present application;

[0044] FIG10 is a flow chart of an audio playback method according to an embodiment of the present application;

[0045] FIG11 is a schematic diagram of a flow chart of another audio playback method provided in an embodiment of the present application;

[0046] FIG12 is a schematic diagram of the hardware structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] Below, some terms used in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0048] The at least one involved in the embodiments of the present application includes one or more; wherein, more than one means greater than or equal to two. In addition, it should be understood that, in the description of this specification, words such as "first" and "second" are only used for the purpose of distinguishing the description, and cannot be understood as expressing or implying relative importance, nor can they be understood as expressing or implying order. For example, the first operation and the second operation do not represent the importance of the two or the order of the two, but are only for distinguishing the description. In the embodiments of the present application, "and / or" is only a description of the association relationship, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects related to each other are in an "or" relationship.

[0049] In the description of the embodiments of the present application, it should be noted that, unless otherwise clearly specified and limited, the terms "installation" and "connection" should be understood in a broad sense. For example, "connection" can be a detachable connection or a non-detachable connection; it can be a direct connection or an indirect connection through an intermediate medium. The directional terms mentioned in the embodiments of the present application, such as "up", "down", "left", "right", "inside", "outside", etc., are only reference to the directions of the accompanying drawings. Therefore, the directional terms used are for better and clearer explanation and understanding of the embodiments of the present application, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the embodiments of the present application.

[0050] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the specification. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0051] At present, general electronic devices (such as mobile phones) have two audio playback modes: receiver mode and speaker mode. In receiver mode, the user needs to put the receiver of the mobile phone close to the user's ear to hear the audio, while the speaker mode is just the opposite. The user can hear the audio without putting the receiver of the mobile phone close to the user's ear. The speaker mode is sometimes also called hands-free mode or external speaker mode. For different audio playback scenarios, the electronic device may need to switch from one audio playback mode to another. For example, when the user is holding something in his hand and a call comes in, he needs to switch the receiver mode to the speaker mode to answer the call. The existing method of switching audio playback modes is mainly through specific gestures. However, since manual operation is required by the user, when the user cannot free his hands to perform the operation (for example, while driving), the audio playback mode cannot be switched.

[0052] In view of this, an embodiment of the present application provides an audio playback method for improving the switching efficiency of audio playback modes. In this method, the electronic device can automatically switch the audio playback mode, which solves the problem of low efficiency caused by the need to switch the audio playback mode manually in the prior art. In addition, in an embodiment of the present application, the electronic device can adaptively adjust the audio playback state or audio playback volume when it is determined that the user has the intention to switch the audio playback mode (for example, the electronic device is close to or away from the user's head). For example, when switching the audio playback mode (for example, switching from a first audio playback mode to a second audio playback mode), the audio is paused, or the volume of the audio when playing in the first audio playback mode and the volume of the audio when playing in the second audio playback mode are gradually reduced, so that when switching the audio playback mode, the user experience is not affected by the sudden change in the audio playback volume, and the user's needs are adapted.

[0053] The audio playback method provided in the embodiment of the present application is applicable to electronic devices. The electronic device has an audio playback function. In some embodiments, the electronic device can be a portable electronic device such as a mobile phone, a tablet computer, or a laptop computer; it can also be a wearable device such as a watch or a bracelet; or it can also be a smart home device such as a television set or a refrigerator; or it can also be a car-mounted device, etc., or it can also be a virtual reality (VR) device, an augmented reality (AR) device, a mixed reality (MR) device, etc. In short, the embodiment of the present application does not limit the specific type of electronic device.

[0054] Figure 1 shows a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. As shown in Figure 1, 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, an earpiece 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 194, and a subscriber identification module (SIM) card interface 195. 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.

[0055] 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, 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. The controller may serve as the nerve center and command center of the electronic device 100. The controller may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. The processor 110 may also include memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a high-speed cache memory. This memory may store instructions or data that have just been used or are being recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids duplicate accesses, reduces the processor 110's waiting time, and thus improves system efficiency. The execution of the audio playback method in the embodiment of the present application can be controlled by the processor 110 or called by other components to complete, such as calling the processing program of the embodiment of the present application stored in the internal memory 121, or calling the processing program of the embodiment of the present application stored in a third-party device through the external memory interface 120, so that the electronic device 100 can automatically switch the audio playback mode, solving the problem of low efficiency caused by the need to switch the audio playback mode by manual operation in the prior art. In addition, in the embodiment of the present application, the electronic device 100 can adaptively adjust the audio playback state or audio playback volume when determining that the user has the intention to switch the audio playback mode (for example, the electronic device 100 is close to or away from the user's head), for example, when switching the audio playback mode (for example, from the first audio playback mode to the second audio playback mode), pause the audio playback, or gradually reduce the volume of the audio when playing in the first audio playback mode and gradually reduce the volume of the audio when playing in the second audio playback mode, so that when switching the audio playback mode, the user experience will not be affected by the sudden change of the audio playback volume, thereby adapting to the needs of the user.

[0056] 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, and software code of at least one application (such as iQiyi application, WeChat application, etc.). The data storage area can store data (such as images, videos, etc.) generated during the use of the electronic device 100. 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.

[0057] 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 pictures and videos can be stored on the external memory card.

[0058] 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 USB interface 130, among others.

[0059] 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.

[0060] 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.

[0061] 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.

[0062] 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.

[0063] 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.

[0064] 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.

[0065] 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.

[0066] 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.

[0067] The wireless communication functionality of electronic device 100 can be implemented using antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, a modem processor, and a baseband processor. 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.

[0068] 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.

[0069] 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 technology (NFC), infrared technology (IR), etc. 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.

[0070] 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 a network and other devices through wireless communication technologies. The wireless communication technologies 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).

[0071] The display screen 194 is used to display the display interface of the application, such as displaying the display page of the application installed on the electronic device 100. The 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0072] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display 194, and an application processor. The ISP is used to process data fed back by the 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 transmitted to the ISP for processing and converted into an image visible to the naked eye. The ISP can also perform algorithmic optimization on image noise, brightness, and skin color. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

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

[0074] The audio module 170 is used to convert digital audio signals into analog audio signals for output, and is also used to convert analog audio signals 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.

[0075] 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 listen to external speaker scenarios such as hands-free calls through one or more speakers 170A.

[0076] Earpiece 170B, also known as a "receiver," can be one or more devices and is used to convert audio signals into sound signals. When electronic device 100 receives a call or voice message, the user can hold earpiece 170B close to their ear to listen to the voice. Generally, the sound from earpiece 170B is quieter than that from speaker 170A to ensure privacy during calls or voice messages.

[0077] In some embodiments, the speaker 170A and / or the earpiece 170B may include a single channel or multiple channels. In some embodiments, multiple channels are used to provide a stereo effect. In other embodiments, multiple channels can be combined. For example, in a dual-channel configuration, the left and right channels can play the same sound, which can increase the volume. A possible scenario involves a user answering a call in a noisy place and having difficulty hearing the caller's voice due to the loud ambient sound. In this case, the user can enable the "mono audio" feature in the phone, which combines multiple channels to increase the volume. There are various ways to enable "mono audio," such as by enabling it in the settings app. In other embodiments, when answering a call in a noisy place, the user can also enable the "call noise cancellation" feature. This feature uses the noise-canceling microphone on the back of the phone to filter out surrounding noise when answering a call through the speaker 170A or earpiece 170B, improving call clarity and quality. There are several ways to start the "Phone Noise Cancellation" function, such as voice wake-up or turning on the function in the Settings app.

[0078] 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, 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 to realize sound signal collection, noise reduction, and identification of sound sources, and realize directional recording function, etc.

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

[0080] The pressure sensor 180A is used to sense the pressure signal and convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194 .

[0081] The gyro sensor 180B can be used to determine the motion posture of the electronic device. In some embodiments, the gyro sensor 180B can be used to determine the angular velocity of the electronic device around three axes (i.e., the x, y, and z axes). The gyro sensor 180B can also be used for anti-shake photography.

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

[0083] The magnetic sensor 180D includes a Hall sensor. The electronic device can use the magnetic sensor 180D to detect the opening and closing of a flip case. In some embodiments, when the electronic device is a flip phone, the electronic device 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.

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

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

[0086] 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 emits infrared light outward through the light emitting diode. The electronic device 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. When insufficient reflected light is detected, the electronic device can determine that there is no object near the electronic device. The electronic device can use the proximity light sensor 180G to detect when the user holds the electronic device 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.

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

[0088] Fingerprint sensor 180H is used to collect fingerprints. Electronic devices can use the collected fingerprint characteristics to achieve fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc.

[0089] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device uses the temperature detected by the temperature sensor 180J to implement a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 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 heats the battery 142 to prevent the electronic device from shutting down abnormally due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device boosts the output voltage of the battery 142 to prevent abnormal shutdown due to low temperature.

[0090] 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 on or near the touch sensor. 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 operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device, in a location different from that of the display screen 194.

[0091] Bone conduction sensor 180M can acquire vibration signals. In some embodiments, bone conduction sensor 180M can acquire vibration signals from vibrating bones in the human body. Bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals.

[0092] The buttons 190 include a power button, a volume button, etc. The button 190 can be a mechanical button. It can also be a touch button. The electronic device can receive button input and generate key signal input related to the user settings and function control of the electronic device. The motor 191 can generate a vibration prompt. The 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. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power changes, and can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect the SIM card. The SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the electronic device.

[0093] It is understood that the components shown in FIG1 do not constitute a specific limitation on the electronic device. The electronic device in the embodiment of the present invention may include more or fewer components than those shown in FIG1. ​​In addition, the combination / connection relationship between the components in FIG1 can also be adjusted and modified.

[0094] Figure 2 shows a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application. As shown in Figure 2, the software structure of the electronic device can be a layered architecture. For example, the software can be divided into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer (framework, FWK), the runtime (runtime) and system library, and the kernel layer.

[0095] The application layer includes a series of application packages. As shown in Figure 2, the application layer can include the camera, settings, skin modules, user interface (UI), and third-party applications. Among them, third-party applications can include gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0096] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer may include some predefined functions. As shown in Figure 2, the application framework layer may include a window manager, content provider, view system, telephony manager, resource manager, and notification manager.

[0097] The window manager manages windowed applications. It can determine the display size, determine whether a status bar is present, lock the screen, and take screenshots. Content providers store and retrieve data and make it accessible to applications. This data can include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and phone books.

[0098] 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.

[0099] The phone manager is used to provide communication functions for electronic devices, such as call status management (including answering, hanging up, etc.).

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

[0101] 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.

[0102] The runtime includes the core library and the virtual machine. The runtime is responsible for the scheduling and management of the operating system.

[0103] The core library consists of two parts: one containing the Java language's callable functions and the other containing the operating system's core libraries. The application layer and application framework layer run in a virtual machine. The virtual machine executes the 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.

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

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

[0106] 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.

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

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

[0109] 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.

[0110] The hardware layer can include various sensors, such as accelerometers, gravity sensors, touch sensors, etc.

[0111] The audio playback method provided in the embodiment of the present application will be further introduced below in combination with the hardware architecture of the electronic device shown in FIG1 and the software architecture of the electronic device shown in FIG2 .

[0112] The execution process of the audio playback method provided in the embodiment of the present application includes at least two stages: starting audio playback and adjusting audio playback configuration. The methods of each stage are described in detail below.

[0113] 1. Start audio playback

[0114] In an embodiment of the present application, the electronic device may receive a play instruction for a first audio and play the first audio in a first audio playback mode. The first audio may include, but is not limited to, one or more of the following: an incoming call ringtone; multimedia audio (e.g., sound output by a music application, a video application, etc.); a call voice; or a voice message. The first audio playback mode may include a speaker mode or an earpiece mode.

[0115] For example, an electronic device can receive an incoming call and play the incoming call ringtone in speaker mode or receiver mode. For another example, Figure 3 is a schematic diagram of an interface for starting audio playback provided in an embodiment of the present application. As shown in Figure 3, the electronic device can display two voice message bubbles on the display screen, namely voice message 1 and voice message 2. Among them, the total duration of voice message 1 is 30 seconds, and the total duration of voice message 2 is 50 seconds. The user can start playing voice message 1 or voice message 2 by clicking on bubble 301 of voice message 1 or bubble 302 of voice message 2. When the electronic device detects the user's operation of clicking on bubble 301 of voice message 1, in response to the operation, the electronic device can play voice message 1 in speaker mode or receiver mode.

[0116] During the specific implementation process, the electronic device can determine the first audio playback mode based on the user's historical settings. For example, the user's historical settings are to play the incoming call ringtone in speaker mode when receiving an incoming call. Alternatively, the electronic device can also determine the first audio playback mode based on the distance between the electronic device and the user's head. For example, when the electronic device receives an incoming call, if it is detected that the distance between the electronic device and the user's head is greater than a first distance (for example, 30 cm), the incoming call ringtone is played in speaker mode; if it is detected that the distance between the electronic device and the user's head is less than a second distance (for example, 5 cm), the incoming call ringtone is played in receiver mode, wherein the first distance and the second distance can be default values, or can also be values ​​set by the user as needed. The embodiments of the present application do not specifically limit this.

[0117] The volume of the first audio when the electronic device plays the first audio in the first audio playback mode can be a user's historical setting. For example, if the first audio playback mode is speaker mode, the user's historical setting can be that the volume when playing the audio in speaker mode is 50 decibels (dB). Alternatively, the volume of the first audio when the electronic device plays the first audio in the first audio playback mode can also be a default value. For example, if the first audio playback mode is speaker mode, the default value can be the maximum volume or minimum volume when playing the audio in speaker mode. This embodiment of the present application does not specifically limit this.

[0118] 2. Adjust audio playback configuration

[0119] In an embodiment of the present application, after the electronic device receives a play instruction for a first audio and plays the first audio in a first audio playback mode, the electronic device can detect whether the electronic device is moving toward or away from the user's head. After detecting that the electronic device is moving toward or away from the user's head, the electronic device can adjust the audio playback configuration. The audio playback configuration includes one or more of the audio playback state, the audio playback volume, and the audio playback mode.

[0120] In one possible embodiment, after detecting at a first moment that the electronic device is moving in a direction close to or away from the user's head, the electronic device may adjust the audio playback configuration. The duration between the first moment and the second moment is less than a preset duration (e.g., 2 seconds, 3 seconds), and the second moment is the moment when the electronic device receives a play instruction for the first audio. The movement of the electronic device in a direction close to or away from the user's head may include the electronic device translating a third distance in a direction close to or away from the user's head and / or the electronic device rotating a first angle in a direction close to or away from the user's head. The third distance may be greater than a first threshold, for example, the first threshold may be 10 centimeters, and the first angle may be greater than a second threshold, for example, the second threshold may be 30 degrees. The first threshold and the second threshold may be default values, or may be values ​​set by the user as needed. The embodiments of the present application do not specifically limit this.

[0121] For example, the preset duration is 2 seconds. If, within 2 seconds after the electronic device plays a voice message 1 in speaker mode or earpiece mode, it is detected that the electronic device is translated by 15 cm and / or rotated by 40 degrees in a direction closer to or away from the user's head, due to the short detection time, the electronic device can determine that the user is more likely to intend to adjust the audio playback configuration of playing the voice message 1, and then the electronic device can adjust the audio playback configuration of playing the voice message 1; if, within 10 seconds after the electronic device starts playing the voice message 1, it is detected that the electronic device is translated by 15 cm and / or rotated by 40 degrees in a direction closer to or away from the user's head, due to the long detection time, the electronic device can determine that the user is less likely to intend to adjust the audio playback configuration, and then the electronic device may adjust the audio playback configuration or not.

[0122] During a specific implementation, if it is detected that the electronic device is moving in a direction close to or away from the user's head, the electronic device may pause playing the first audio (ie, adjust the audio playing state).

[0123] Among them, after the electronic device pauses playing the first audio, if it detects that the distance between the electronic device and the user's head is greater than the third distance or less than the fourth distance, the electronic device can start playing the first audio and play the first audio in the second audio playback mode (i.e., adjust the audio playback state and audio playback mode), wherein the second audio playback mode is different from the first audio playback mode. The third distance and the fourth distance can be default values, or values ​​set by the user as needed. The third distance and the above-mentioned first distance can be different values, the fourth distance and the above-mentioned second distance can be different values, the third distance and the fourth distance can be the same value, or different values. The embodiments of the present application do not specifically limit this.

[0124] When the electronic device starts playing the first audio, it may continue to play the content not played by the first audio, or it may replay the first audio, which is not specifically limited in the embodiments of the present application. For example, the electronic device pauses playing the voice message after playing the voice message for 2 seconds. When the electronic device starts playing the voice message again, it may continue to play the content after 2 seconds of the voice message, or it may replay the voice message from the 1st second of the voice message.

[0125] The volume of the first audio when the electronic device plays the second audio playback mode can be a user's historical setting. For example, if the second audio playback mode is earpiece mode, the user's historical setting can be that the volume when playing audio in earpiece mode is 25dB. Alternatively, the volume of the first audio when the electronic device plays the second audio playback mode can also be a default value. For example, if the second audio playback mode is earpiece mode, the default value can be the maximum volume or minimum volume when playing audio in earpiece mode. This embodiment of the application does not specifically limit this.

[0126] Alternatively, if it is detected that the electronic device is moving toward or away from the user's head, the electronic device may also gradually lower the volume of the first audio when it is played in the first audio playback mode, and play the first audio in the second audio playback mode and gradually increase the volume of the first audio when it is played in the second audio playback mode (i.e., adjust the audio playback volume and the audio playback mode).

[0127] Among them, the electronic device switches from playing the first audio in the second audio playback mode to playing the first audio in the second audio playback mode only when it determines that the electronic device is close to the user's head, or, when the electronic device is close to the user's head, switches from playing the first audio in the second audio playback mode to playing the first audio in the second audio playback mode. The embodiment of the present application does not make specific restrictions on this.

[0128] In one possible implementation, if the electronic device receives a playback instruction for a first audio and plays the first audio in a first audio playback mode, that is, receives an incoming call and plays the incoming ringtone in speaker mode, then when it is detected that the electronic device is moving in a direction close to the user's head, the electronic device can gradually reduce the volume of the incoming ringtone when played in speaker mode (i.e., adjust the audio playback volume), and when it is determined that the distance between the electronic device and the user's head is less than a fourth distance, the call is connected, and the call voice is played in receiver mode (i.e., adjust the audio playback mode).

[0129] The following describes in detail the implementation of adjusting the audio playback configuration using a specific example:

[0130] Scenario 1: Take the case where the first audio playback mode is the speaker mode, the second audio mode is the earpiece mode, and the distance between the electronic device and the user's head is greater than the first distance. When the electronic device is playing the first audio in the speaker mode, if it is detected that the electronic device is moving in a direction close to the user's head, the electronic device may pause playing the first audio, or the electronic device may gradually reduce the volume of the first audio when it is played in the speaker mode, and play the first audio in the earpiece mode with the volume gradually increasing when the first audio is played in the earpiece mode. If it is further detected that the electronic device is moving in a direction away from the user's head, the electronic device may pause playing the first audio, or the electronic device may gradually reduce the volume of the first audio when it is played in the earpiece mode, and play the first audio in the speaker mode with the volume gradually increasing when the first audio is played in the speaker mode.

[0131] For example, FIG4 is a schematic diagram of an audio playback scenario provided by an embodiment of the present application. As shown in FIG4 , the mobile phone is away from the user's head and plays a voice message in speaker mode. When the mobile phone gradually approaches the user's head, the mobile phone can switch to receiver mode, that is, play the voice message in receiver mode, and pause the voice message when switching, or gradually reduce the volume of the voice message when playing in speaker mode, and gradually increase the volume of the voice message when playing in receiver mode. When the mobile phone approaches the user's head and then gradually moves away from the user's head again, the mobile phone can switch to speaker mode again, that is, play the voice message in speaker mode, and pause the voice message when switching, or gradually reduce the volume of the voice message when playing in receiver mode, and gradually increase the volume of the voice message when playing in speaker mode.

[0132] Scenario 2: Take the case where the first audio playback mode is the speaker mode, the second audio mode is the earpiece mode, and the distance between the electronic device and the user's head is less than the second distance. When the electronic device is playing the first audio in the speaker mode, if it is detected that the electronic device is moving in a direction away from the user's head, the electronic device may pause playing the first audio, or the electronic device may gradually increase the volume of the first audio when playing in the speaker mode. If it is further detected that the electronic device is moving in a direction close to the user's head, the electronic device may pause playing the first audio, or gradually reduce the volume of the first audio when playing in the speaker mode, and play the first audio in the earpiece mode with the volume of the first audio gradually increasing when playing in the earpiece mode.

[0133] For example, FIG5 is a schematic diagram of another audio playback scenario provided by an embodiment of the present application. As shown in FIG5 , the mobile phone is close to the user's head and plays a voice message in speaker mode. When the mobile phone gradually moves away from the user's head, the mobile phone may not switch to receiver mode, that is, continue to play the voice message in speaker mode, but may pause playing the voice message, or may gradually increase the volume of the voice message when playing in speaker mode. When the mobile phone moves away from the user's head and then gradually approaches the user's head again, the mobile phone may switch to receiver mode, that is, play the voice message in receiver mode, and may pause playing the voice message when switching, or may gradually reduce the volume of the voice message when playing in speaker mode, and gradually increase the volume of the voice message when playing in receiver mode.

[0134] Scenario three: Take the case where the first audio playback mode is the handset mode, the second audio mode is the speaker mode, and the distance between the electronic device and the user's head is greater than the first distance. When the electronic device plays the first audio in the handset mode, if it is detected that the electronic device is moving in a direction close to the user's head, the electronic device may pause playing the first audio, or gradually reduce the volume of the first audio when played in the handset mode (or gradually increase the volume of the first audio when played in the handset mode, or keep the volume of the first audio when played in the handset mode unchanged). If it is further detected that the electronic device is moving in a direction away from the user's head, the electronic device may pause playing the first audio, or gradually reduce the volume of the first audio when played in the handset mode, and play the first audio in the speaker mode with the volume of the first audio gradually increasing when played in the speaker mode.

[0135] For example, FIG6 is a schematic diagram of another audio playback scenario provided by an embodiment of the present application. As shown in FIG6 , the mobile phone is away from the user's head, and the mobile phone plays a voice message in receiver mode. When the mobile phone gradually approaches the user's head, the mobile phone may not switch to speaker mode, that is, continue to play the voice message in receiver mode, but may pause playing the voice message, or may gradually reduce the volume of the voice message when played in receiver mode (or gradually increase the volume of the voice message when played in receiver mode, or keep the volume of the voice message when played in receiver mode unchanged). When the mobile phone approaches the user's head and then gradually moves away from the user's head again, the mobile phone may switch to speaker mode, that is, play the voice message in speaker mode, and may pause playing the voice message when switching, or may gradually reduce the volume of the voice message when played in receiver mode, and gradually increase the volume of the voice message when played in speaker mode.

[0136] Scenario 4: Take the case where the first audio playback mode is the handset mode, the second audio mode is the speaker mode, and the distance between the electronic device and the user's head is less than the second distance as an example. When the electronic device is playing the first audio in the handset mode, if it is detected that the electronic device is moving in a direction away from the user's head, the electronic device may pause playing the first audio, or gradually reduce the volume of the first audio when playing in the handset mode, and play the first audio in the speaker mode with the volume gradually increasing when playing in the speaker mode. If it is further detected that the electronic device is moving in a direction close to the user's head, the electronic device may pause playing the first audio, or gradually reduce the volume of the first audio when playing in the speaker mode, and play the first audio in the handset mode with the volume gradually increasing when playing in the handset mode.

[0137] For example, FIG7 is a schematic diagram of another audio playback scenario provided by an embodiment of the present application. As shown in FIG7 , the mobile phone is close to the user's head and plays a voice message in receiver mode. When the mobile phone gradually moves away from the user's head, the mobile phone can switch to speaker mode, that is, play the voice message in speaker mode, and pause the voice message when switching, or gradually reduce the volume of the voice message when playing in receiver mode, and gradually increase the volume of the voice message when playing in speaker mode. When the mobile phone moves away from the user's head and gradually approaches the user's head again, the mobile phone can switch to receiver mode again, that is, play the voice message in receiver mode, and pause the voice message when switching, or gradually reduce the volume of the voice message when playing in speaker mode, and gradually increase the volume of the voice message when playing in receiver mode.

[0138] The following describes in detail the specific implementation of gradually reducing or increasing the volume of the first audio when it is played in the speaker mode and gradually increasing or decreasing the volume of the first audio when it is played in the earpiece mode with reference to specific examples:

[0139] In the above-mentioned scenarios one, two, three and four, after the electronic device detects that the electronic device is moving toward or away from the user's head, it gradually reduces or increases the volume of the first audio when it is played in speaker mode. It can be understood that the volume of the first audio when it is played in speaker mode will change with the change of the movement trajectory of the electronic device. Similarly, gradually increasing or reducing the volume of the first audio when it is played in earpiece mode can be understood as the volume of the first audio when it is played in earpiece mode and the volume of the first audio when it is played in earpiece mode will change with the change of the movement trajectory of the electronic device.

[0140] Among them, when gradually increasing or gradually decreasing the volume of the first audio when playing in speaker mode or earpiece mode, the target volume of the first audio when playing in speaker mode or earpiece mode can be the user's historical setting. For example, the user's historical setting can be that the volume when playing audio in earpiece mode is 25dB. When gradually increasing the volume of the first audio when playing in earpiece mode, the starting volume of the first audio when playing in earpiece mode is 0dB. As the volume gradually increases, the target volume of the first audio when playing in earpiece mode is finally 25dB. Alternatively, the target volume of the first audio when playing in speaker mode or earpiece mode can also be a default value. For example, the minimum volume when playing audio in speaker mode is 30dB. When gradually increasing the volume of the first audio when playing in speaker mode, the starting volume of the first audio when playing in speaker mode is 0dB. As the volume gradually increases, the target volume of the first audio when playing in speaker mode is finally 30dB. The embodiments of the present application do not specifically limit this.

[0141] In a specific implementation, the correspondence between the volume of the first audio when played in the speaker mode and the volume of the first audio when played in the earpiece mode and the motion trajectory of the electronic device can be as shown in Table 1 below:

[0142] The motion trajectory of the electronic device The volume of the first audio when it is played in speaker mode The volume of the first audio when it is played in earpiece mode

[0143] Table 1

[0144] Among them, in the above Table 1, the movement trajectory of the electronic device includes 6 positions as an example, namely from position 1 to position 2, position 2 to position 3, position 3 to position 4, position 4 to position 5, and position 5 to position 6. It should be understood that the movement trajectory of the electronic device can also include more or fewer positions, and the number of positions included in the movement trajectory of the electronic device can be a default value, or it can also be a value set by the user as needed. The embodiment of the present application does not specifically limit this. As the electronic device moves between any two positions, the volume of the first audio when played in speaker mode will gradually decrease or increase, and the volume of the first audio when played in earpiece mode will gradually increase or decrease.

[0145] In the above Table 1, it is taken as an example that the difference between the volumes of the first audio corresponding to two adjacent positions when played in the speaker mode or the earpiece mode is equal. For example, the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode is 5dB, that is, the starting position of the electronic device is position 1, and the destination position is position 2. When the electronic device gradually moves from position 1 to position 2, the movement trajectory of the electronic device is from position 1 to position 2. The volume of the first audio when played in speaker mode can be gradually increased by 5dB and the volume of the first audio when played in earpiece mode can be gradually decreased by 5dB, or the volume of the first audio when played in speaker mode can be gradually decreased by 5dB and the volume of the first audio when played in earpiece mode can be gradually increased by 5dB; after the electronic device gradually moves from position 1 to position 2, the initial position of the electronic device becomes position 2, and the destination position becomes position 3. When the electronic device gradually moves from position 2 to position 3, the movement trajectory of the electronic device becomes position 2 to position 3. The volume of the first audio when played in speaker mode can be gradually increased by 5dB and the volume of the first audio when played in earpiece mode can be gradually decreased by 5dB, or the volume of the first audio when played in speaker mode can be gradually decreased by 5dB and the volume of the first audio when played in earpiece mode can be gradually increased by 5dB.

[0146] It should be understood that the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode may not be equal. For example, the difference between the volumes of the first audio corresponding to position 1 and position 2 when played in speaker mode or earpiece mode is 4dB, and the difference between the volumes of the first audio corresponding to position 2 and position 3 when played in speaker mode or earpiece mode is 6dB, and so on. This is not limited in the embodiments of the present application. The difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode may be related to the volume of the first audio when played in speaker mode or earpiece mode before the electronic device moves (i.e., the starting volume of the first audio when played in speaker mode or earpiece mode), the volume of the first audio when played in speaker mode or earpiece mode after the electronic device moves (i.e., the target volume of the first audio when played in speaker mode or earpiece mode), and the number of positions included in the movement trajectory of the electronic device. For example, before the electronic device moves, the starting volume of the first audio when played in speaker mode is 25dB, and after the electronic device moves, the target volume of the first audio when played in speaker mode is 0dB. The number of positions included in the movement trajectory of the electronic device is 6, then the volume difference of the first audio when played in speaker mode corresponding to two adjacent positions can be equal, which is 25dB / 5=5dB, or, the volume difference of the first audio when played in speaker mode corresponding to two adjacent positions can also be unequal, which are 7dB, 6dB, 5dB, 4dB, and 3dB respectively, so that when the electronic device moves from position 1 to position 2, position 2 to position 3, position 3 to position 4, position 4 to position 5, and position 5 to position 6, the volume of the first audio when played in speaker mode can gradually decrease from 25dB to 0dB.

[0147] It should be understood that the correspondence between the volume of the first audio when played in the speaker mode and the volume of the first audio when played in the earpiece mode and the motion trajectory of the electronic device can be in the form of a function or a curve, in addition to the form of the above-mentioned Table 1. For example, the correspondence between the volume of the first audio when played in the speaker mode or the earpiece mode and the motion trajectory of the electronic device can be respectively the volume curve 1 and the volume curve 2 shown in (1) of Figure 8, wherein the volume curve 1 and the volume curve 2 are located in the XY coordinate system, X represents the position, and Y represents the volume value (in dB as an example). The volume curve 1 takes the example that the volume of the first audio when played in the speaker mode gradually increases as the electronic device moves between any two positions, and the volume curve 2 takes the example that the volume of the first audio when played in the earpiece mode gradually decreases as the electronic device moves between any two positions. Alternatively, the correspondence between the volume of the first audio when played in speaker mode or earpiece mode and the movement trajectory of the electronic device can be volume curve 3 and volume curve 4 as shown in (2) of Figure 8, respectively, wherein volume curve 3 and volume curve 4 are located in an XY coordinate system, X represents position, and Y represents volume value (unit is dB, for example). Volume curve 3 takes the example that the volume of the first audio when played in earpiece mode gradually increases as the electronic device moves between any two positions, and volume curve 4 takes the example that the volume of the first audio when played in speaker mode gradually decreases as the electronic device moves between any two positions.

[0148] In the embodiments shown in (1) and (2) of Figure 8 , the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode may be related to the volume of the first audio when played in speaker mode or earpiece mode before the electronic device moves (i.e., the starting volume of the first audio when played in speaker mode or earpiece mode), the volume of the first audio when played in speaker mode or earpiece mode after the electronic device moves (i.e., the target volume of the first audio when played in speaker mode or earpiece mode), and the number of positions included in the movement trajectory of the electronic device. Taking the example that the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode is equal, the starting volume of the first audio when played in speaker mode before the electronic device moves as shown in (1) of Figure 8 is 0dB, and the starting volume of the first audio when played in earpiece mode is 30dB, and the number of positions included in the movement trajectory of the electronic device is 7 (for example, position 0-position 6), then the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode is 30dB / 6=5dB; as shown in (2) of Figure 8 , the starting volume of the first audio when played in earpiece mode before the electronic device moves is 0dB, and the starting volume of the first audio when played in speaker mode is 30dB, and the number of positions included in the movement trajectory of the electronic device is 7 (for example, position 0-position 6), then the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or earpiece mode is 30dB / 6=5dB. It should be understood that in other embodiments, the difference between the volumes of the first audio corresponding to two adjacent positions when played in speaker mode or receiver mode may also be unequal, and this is not limited in this embodiment of the present application. In the embodiments shown in (1) and (2) of Figure 8 , volume curve 1 and volume curve 2 are taken as a straight line. It should be understood that in other embodiments, volume curve 1 and volume curve 2 may also be curved lines with a certain curvature, and this is not limited in this embodiment of the present application.

[0149] In a specific implementation, the speaker and earpiece of an electronic device can be independent. For example, the electronic device can include a speaker 1 and an earpiece 1, or the speaker and earpiece of the electronic device can be independent. For example, as shown in Figure 9, the electronic device can include a speaker 2 and a speaker 3, where speaker 2 has a speaker mode and an earpiece mode, and speaker 3 has a speaker mode, wherein the lowest volume of the speaker mode of speaker 2 is higher than the highest volume of the earpiece mode. It can be understood that when the volume of the audio played by speaker 2 is between 0dB and 25dB, speaker 2 is in earpiece mode, and when the volume of the audio played by speaker 2 is greater than 25dB, speaker 2 is in speaker mode.

[0150] If the speaker and earpiece of the electronic device are not independent, that is, the electronic device includes speaker 2 and speaker 3, then the above-mentioned gradually increasing the volume of the first audio when played in speaker mode and gradually decreasing the volume of the first audio when played in earpiece mode can be understood as gradually increasing the volume of the first audio played by speaker 2 to the speaker mode of speaker 2, and gradually increasing the volume of the first audio when played by speaker 3. The above-mentioned gradually decreasing the volume of the first audio when played in speaker mode and gradually increasing the volume of the first audio when played in earpiece mode can be understood as gradually decreasing the volume of the first audio when played by speaker 2 to the earpiece mode, and gradually decreasing the volume of the first audio when played by speaker 3.

[0151] For example, as shown in FIG4 , the mobile phone is away from the user's head, and the mobile phone plays a voice message in the speaker mode of speaker 2 and speaker 3. The starting volume of the voice message played by the mobile phone is: the volume of the voice message played in the speaker mode of speaker 2 is 45dB and the volume of the voice message played by speaker 3 is 25dB.

[0152] As the phone gradually approaches the user's head, the phone can switch to handset mode on speaker 2, i.e., play the voice message in handset mode on speaker 2, and gradually reduce the volume of the voice message played on speakers 2 and 3 during the switch. For example, the target volume for playing voice messages on the phone is 20dB for handset mode on speaker 2 and 0dB for speaker 3 (based on the user's historical settings), and the phone's motion trajectory includes six positions. When the mobile phone gradually moves from position 1 to position 2, the volume of the voice message played by speaker 2 and speaker 3 gradually decreases by 5dB, so that when the mobile phone reaches position 2, the volume of the voice message played by speaker 2 becomes 40dB and the volume of the voice message played by speaker 3 becomes 20dB; when the mobile phone gradually moves from position 2 to position 3, the volume of the voice message played by speaker 2 and speaker 3 gradually decreases by 5dB, so that when the mobile phone reaches position 3, the volume of the voice message played by speaker 2 becomes 35dB and the volume of the voice message played by speaker 3 becomes 15dB; and so on, when the mobile phone reaches position 6, the volume of the voice message played by speaker 2 becomes 20dB and the volume of the voice message played by speaker 3 becomes 0dB.

[0153] When the phone approaches the user's head and then gradually moves away from the user's head again, the phone can switch back to speaker mode of speaker 2 and speaker 3, that is, the voice message can be played through speaker mode of speaker 2 and speaker 3, and the volume of the voice message played through speaker 2 and speaker 3 can be gradually increased during the switch. For example, the target volume for playing voice messages on the phone is: the volume of voice messages played through speaker 2 in receiver mode is 45dB and the volume of voice messages played through speaker 3 is 25dB (based on the user's historical settings), and the movement trajectory of the phone includes 6 positions. When the mobile phone gradually moves from position 6 to position 5, the volume of the voice message played by speaker 2 and speaker 3 gradually increases by 5dB, so that when the mobile phone reaches position 5, the volume of the voice message played by speaker 2 becomes 25dB and the volume of the voice message played by speaker 3 becomes 5dB; when the mobile phone gradually moves from position 5 to position 4, the volume of the voice message played by speaker 2 and speaker 3 gradually increases by 5dB, so that when the mobile phone reaches position 3, the volume of the voice message played by speaker 2 becomes 30dB and the volume of the voice message played by speaker 3 becomes 10dB; and so on, when the mobile phone reaches position 1, the volume of the voice message played by speaker 2 becomes 45dB and the volume of the voice message played by speaker 3 becomes 25dB.

[0154] Based on the above embodiments, the electronic device can automatically switch the audio playback mode, which solves the problem of low efficiency caused by the need to manually switch the audio playback mode in the prior art. In addition, in the embodiments of the present application, the electronic device can adaptively adjust the audio playback state or audio playback volume when it is determined that the user has the intention to switch the audio playback mode (for example, the electronic device is close to or away from the user's head). For example, when switching the audio playback mode (for example, switching from the first audio playback mode to the second audio playback mode), the audio is paused, or the volume of the audio when playing in the first audio playback mode and the volume of the audio when playing in the second audio playback mode are gradually reduced, so that when switching the audio playback mode, the user experience is not affected by the sudden change of the audio playback volume, and the user's needs are adapted.

[0155] Based on the above embodiments and the same concept, the present application further provides an audio playback method, which can be executed by the electronic device shown in FIG1-FIG2.

[0156] Figure 10 is a flow chart of an audio playback method provided in an embodiment of the present application. As shown in Figure 10, the electronic device can start playing the first audio. The specific manner in which the electronic device starts playing the first audio is described in "I. Start audio playback", which will not be repeated here. After starting to play the first audio, the electronic device can also determine whether it is detected that the electronic device is moving in a direction close to or away from the user's head. If it is detected that the electronic device is moving in a direction close to or away from the user's head, the electronic device can adjust the audio playback configuration of the first audio; if it is not detected that the electronic device is moving in a direction close to or away from the user's head, the electronic device may not adjust the audio playback configuration of the first audio. If the electronic device detects that the electronic device is moving in a direction close to or away from the user's head, the specific manner in which the electronic device adjusts the audio playback configuration of the first audio is described in "II. Adjust audio playback configuration", which will not be repeated here.

[0157] FIG11 is a flow chart of another audio playback method provided by an embodiment of the present application. Referring to FIG11 , the method includes the following steps:

[0158] S1101: Receive a play instruction for a first audio.

[0159] S1102: Play the first audio in the first audio playback mode.

[0160] The first audio playback mode includes a speaker mode or a handset mode. Detailed descriptions of S1101 and S1102 can be found in "1. Starting Audio Playback" and will not be repeated here.

[0161] S1103: Detecting that the electronic device is moving toward or away from the user's head.

[0162] S1104: Pause the first audio, or gradually reduce the volume of the first audio when it is played in the first audio playback mode, and play the first audio in the second audio playback mode and gradually increase the volume of the first audio when it is played in the second audio playback mode.

[0163] The second audio playback mode is different from the first audio playback mode. Detailed descriptions of S1103 and S1104 are given in “II. Adjusting Audio Playback Configuration” and are not repeated here.

[0164] It should be noted that the specific implementation process provided in the above example is only an example of the method process applicable to the embodiment of the present application. The execution order of each step can be adjusted accordingly according to actual needs, and other steps can be added or some steps can be reduced.

[0165] Based on the above embodiments and the same concept, an embodiment of the present application further provides an electronic device, which is used to implement the method performed by the electronic device provided in the embodiment of the present application.

[0166] As shown in Figure 12, electronic device 1200 may include: memory 1201, one or more processors 1202, and one or more computer programs (not shown). The above-mentioned components may be coupled via one or more communication buses 1203. Optionally, when electronic device 1200 is used to implement the method performed by the electronic device provided in the embodiments of the present application, electronic device 1200 may also include a display screen 1204.

[0167] The memory 1201 stores one or more computer programs (codes), each of which includes computer instructions. The one or more processors 1202 invoke the computer instructions stored in the memory 1201, causing the electronic device 1200 to execute the audio playback method provided in the embodiments of the present application. The display screen 1204 is used to display images, videos, application interfaces, and other related user interfaces.

[0168] In a specific implementation, the memory 1201 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 1201 can store an operating system (hereinafter referred to as system), such as ANDROID, IOS, WINDOWS, or embedded operating systems such as LINUX. The memory 1201 can be used to store the implementation program of the embodiment of the present application. The memory 1201 can also store a network communication program, which can be used to communicate with one or more additional devices, one or more user devices, or one or more network devices. The one or more processors 1202 can be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0169] It should be noted that FIG12 is only one implementation of the electronic device 1200 provided in an embodiment of the present application. In actual applications, the electronic device 1200 may also include more or fewer components, which is not limited here.

[0170] Based on the above embodiments and the same concept, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a computer, the computer executes the method performed by the electronic device in the method provided in the above embodiment.

[0171] Based on the above embodiments and the same concept, an embodiment of the present application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer executes the method performed by the electronic device in the method provided in the above embodiments.

[0172] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0173] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each flow and / or box in the flow chart and / or block diagram, as well as the combination of the flow chart and / or box in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more flow charts and / or one or more boxes in the block diagram.

[0174] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0176] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. An audio playback method, characterized in that: Used in electronic equipment, including: Receiving a play instruction for the first audio; Play the first audio in a first audio playback mode, where the first audio playback mode includes a speaker mode or a receiver mode; Detecting that the electronic device moves toward or away from the user's head; Pause the first audio, or gradually reducing the volume of the first audio when it is played in the first audio playback mode, and playing the first audio in the second audio playback mode and gradually increasing the volume of the first audio when it is played in the second audio playback mode; The second audio playback mode is different from the first audio playback mode.

2. The method according to claim 1, characterized in that The detecting that the electronic device moves toward or away from the user's head includes: At a first moment, it is detected that the electronic device moves towards or away from the user's head, the duration between the first moment and the second moment is less than a preset duration, and the second moment is the moment when the electronic device receives a play instruction for the first audio.

3. The method according to claim 1 or 2, characterized in that: The first audio playback mode is a speaker mode, the second audio mode is a receiver mode, and the distance between the electronic device and the user's head is greater than the first distance; When it is detected that the electronic device is moving in a direction close to the user's head, the first audio is paused, or the volume of the first audio when played in speaker mode is gradually reduced, and the first audio is played in earpiece mode and the volume of the first audio when played in the earpiece mode is gradually increased.

4. The method according to claim 3, characterized in that The method further comprises: When it is detected that the electronic device is moving in a direction away from the user's head, the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced, and the first audio is played in the speaker mode and the volume of the first audio when played in the speaker mode is gradually increased.

5. The method according to claim 1 or 2, characterized in that: The first audio playback mode is a speaker mode, the second audio mode is a receiver mode, and the distance between the electronic device and the user's head is less than a second distance; When it is detected that the electronic device moves in a direction away from the user's head, the playing of the first audio is paused, or the volume of the first audio when played in speaker mode is gradually increased.

6. The method according to claim 5, characterized in that The method further comprises: When it is detected that the electronic device is moving in a direction close to the user's head, the first audio is paused, or the volume of the first audio when played in speaker mode is gradually reduced, and the first audio is played in earpiece mode and the volume of the first audio when played in the earpiece mode is gradually increased.

7. The method according to claim 1 or 2, characterized in that: The first audio playback mode is a handset mode, the second audio mode is a speaker mode, and the distance between the electronic device and the user's head is greater than the first distance; When it is detected that the electronic device moves in a direction close to the user's head, the playing of the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced.

8. The method according to claim 7, characterized in that The method further comprises: When it is detected that the electronic device is moving in a direction away from the user's head, the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced, and the first audio is played in the speaker mode and the volume of the first audio when played in the speaker mode is gradually increased.

9. The method according to claim 1 or 2, characterized in that: The first audio playback mode is a handset mode, the second audio mode is a speaker mode, and the distance between the electronic device and the user's head is less than a second distance; When it is detected that the electronic device is moving in a direction away from the user's head, the first audio is paused, or the volume of the first audio when played in the earpiece mode is gradually reduced, and the first audio is played in the speaker mode and the volume of the first audio when played in the speaker mode is gradually increased.

10. The method according to claim 9, characterized in that The method further comprises: When it is detected that the electronic device is moving in a direction close to the user's head, the first audio is paused, or the volume of the first audio when played in speaker mode is gradually reduced, and the first audio is played in earpiece mode and the volume of the first audio when played in the earpiece mode is gradually increased.

11. The method according to any one of claims 1 to 10, characterized in that: After pausing the playing of the first audio, the method further includes: It is detected that the distance between the electronic device and the user's head is greater than the third distance or less than the fourth distance, and the first audio is started to be played and the first audio is played in the second audio playback mode.

12. The method according to any one of claims 1 to 11, characterized in that: The first audio includes at least one of an incoming call ringtone, multimedia audio, call voice, and voice message.

13. The method according to any one of claims 1 to 12, characterized in that: The receiving of a play instruction for the first audio includes: receiving an incoming call; Playing the first audio in the first audio playback mode includes: playing an incoming call ringtone in a speaker mode; When it is detected that the electronic device is moving in a direction close to the user's head, the volume of the incoming call ringtone when played in the speaker mode is gradually reduced, and when it is determined that the distance between the electronic device and the user's head is less than a fourth distance, the call is answered and the call voice is played in the handset mode.

14. An electronic device, characterized in that: The electronic device comprises: a processor, a memory, and one or more programs; The one or more programs are stored in the memory, and the one or more programs include instructions, and when the instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-13.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and when the computer program is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Method and device for automatically regulating audio playing in handhold verbal equipment

    CN101964844A

  • Mobile phone and method for automatically answering call of mobile phone

    CN104301460A

  • Volume adjusting method and device and terminal equipment

    CN106534541A

  • Method, mobile terminal and system for automatically answering call in emergency

    CN107580144A

  • Automatic sound volume regulating device for mobile terminal and mobile terminal

    CN201369757Y