Patent Description:
Currently, a mobile phone supports increasingly more functions. In addition to a basic call answering function, most mobile phones can play multimedia files such as an audio and a video. However, to facilitate carrying by users, most mobile phones have a relatively small size, and therefore have a relatively small display screen. In this case, when a multimedia file is played by using a mobile phone, user experience is relatively poor.

To improve user experience, in a current implementation, a mobile phone having a relatively small display screen is connected to another device having a relatively large display screen (for ease of description, the device is briefly referred to as a large-screen device below). In this way, a multimedia file on the mobile phone can be played by using the large-screen device.

During research, the inventor finds that such an application scenario exists: In the prior art, when audios from different multimedia applications are to be played at the same time, the to-be-played audios of these multimedia applications are all played by using a same device (for example, a large-screen device or a mobile phone), and therefore, user experience is relatively poor. For example, in a multi-party conference scenario, in a process of playing an audio by using a speaker of a large-screen device, if a user plays voice messages from privacy applications such as WeChat and QQ on a mobile phone, these voice messages are played by using the speaker of the large-screen device, and consequently, user privacy is leaked.

<CIT>discloses an electronic device including an audio module, a Bluetooth module, and a processor. If an audio output mode is a mode in which the audio module and the Bluetooth module are activated at the same time and if playback of audio data is requested while the Bluetooth module is connected with an external device, the processor is configured to determine whether the audio data is call data or media data, to send the audio data through a first path if the audio data is the call data, and to send the audio data through a second path if the audio data is the media data.

<CIT> discloses a microprocessor is used for converting a touch sensing signal to an operational order, it transmits said operational order to a television signal processing unit, drives the television signal processing unit to generate a video signal and an audio signal, transmits said video signal to a LCD and/or external display device to display, and transmits said audio signal to a speaker and/or external speaker device to play.

Embodiments of this application provide an audio playing method and an electronic device, so as to resolve a prior-art problem of privacy leakage caused because audios from different multimedia applications are all played by using a speaker of an external audio device.

The following terms "first" and "second" are merely intended for a purpose of description, and shall not be understood as an indication or implication of relative importance or an implicit indication of a quantity of indicated technical features. Therefore, a feature limited by "first" or "second" may explicitly or implicitly include one or more features. In the descriptions of the embodiments of this application, unless otherwise specified, "a plurality of" means two or more than two.

An embodiment of this application provides an audio playing method. The method may be applied to a scenario in which an electronic device is connected to an external audio device. The electronic device may be any device such as a mobile phone, a wearable device, an augmented reality (Augmented Reality, AR)/virtual reality (Virtual Reality, VR) device, a tablet computer, a notebook computer, an ultra-mobile personal computer (Ultra-mobile Personal Computer, UMPC), a netbook, or a personal digital assistant (Personal Digital Assistant, PDA). This is not limited in this embodiment of this application. The external audio device is any device having an audio playing function. For example, the external audio device may be an acoustic device. For another example, the external audio device may further have a display. For example, the external audio device may be a device such as a personal computer or a television. The electronic device may establish a connection to the external audio device in a wired communication mode or a wireless communication mode. After the electronic device establishes the connection to the external audio device, it may be understood that the electronic device has two audio playing devices. The electronic device is a control device, and the external audio device is a slave device. The electronic device may play an audio by using an audio output device of the electronic device, or may play an audio by using the external audio device.

For example, the electronic device is a mobile phone, and the external audio device is a large-screen device having both an audio playing function and a display function.

Referring to <FIG>, the mobile phone <NUM> may establish a connection to a large-screen device <NUM> in a wired communication mode. The wired communication mode may be specifically a mode in which the mobile phone is connected to the large-screen device through a universal serial bus (Universal Serial Bus, USB) interface or a high definition multimedia interface (High Definition Multimedia Interface, HDMI) interface.

Referring to <FIG>, the mobile phone <NUM> may establish a connection to a large-screen device <NUM> in a wireless communication mode. The wireless communication mode may be specifically a Bluetooth (Bluetooth, BT) connection, a wireless fidelity (Wireless Fidelity, Wi-Fi) connection, or the like.

During research, the inventor finds that if an audio playing policy is predefined in a mobile phone system, and an audio device is specified, according to the audio playing policy, as a device for playing an audio, all audios are played by using the specified audio device. For example, most mobile phones have audio devices such as earphones and speakers. A mobile phone may alternatively be connected to another external audio device. For example, if the mobile phone is connected to earphones, the earphones may also be used as an external audio device of the mobile phone. Alternatively, if the mobile phone is connected to a large-screen device, an audio device of the large-screen device may also be used as an external audio device of the mobile phone. Therefore, the foregoing earphones, speakers, and external audio devices may all be considered as audio devices of the mobile phone. At present, a voice policy defined for most mobile phones is specifically as follows: When a mobile phone is not connected to another device, an audio is played by using earphones by default. In some cases, if a user chooses to play an audio by using a speaker, the mobile phone plays the audio by using the speaker based on the selection of the user. If it is detected that earphones are connected to the mobile phone, an audio is played by using the earphones by default. If it is detected that the mobile phone is connected to another device, an audio is played, by default, by using an audio device of the another device connected to the mobile phone. Referring to this audio playing policy, in a scenario shown in <FIG>, if the audio playing policy defined for the mobile phone is setting the audio device of the large-screen device to a default audio device, all audios are played by using the audio device of the large-screen device.

Specifically, referring to <FIG>, specific technical implementation of the audio playing policy is as follows: During audio processing, an operating system of the mobile phone may be divided into an application layer (Application Layer), a framework layer (Framework Layer), an audio hub service layer (Audio Flinger), a hardware abstraction layer (Hardware Abstraction Layer, HAL), and kernel space (kernel space) based on logic for processing an audio service. To-be-played audios on the mobile phone include an audio <NUM> from an upper-layer application and a telephony voice signal <NUM>, and a process in which the mobile phone processes the audios includes the following content.

When the audio <NUM> from the upper-layer application (for example, an audio of a video playing application) is detected, the framework layer initializes an audio player on the mobile phone (this is shown as a process <NUM> in <FIG>), decodes the audio <NUM> (the decoding process is a software decoding process, therefore may be referred to as software decoding, and is shown as a process <NUM> in <FIG>), to obtain a decoded audio <NUM>, and transfers the decoded audio <NUM> to the audio hub service layer. The audio hub service layer performs the following processing process on the decoded audio (the processing is shown as a process <NUM> in <FIG>): resampling (resample), applying an effect (apply effect), adjusting a volume (adjust volume), and audio mixing (mixer), and then forwards, by using the hardware abstraction layer, a processed audio to the kernel space for processing.

The telephony voice signal <NUM> from a modem is directly decoded by a digital signal processor (Digital Signal Processor, DSP) located in the kernel space (the decoding process is referred to as hardware decoding, and is shown as a process <NUM> in <FIG>), to obtain a decoded telephony voice signal <NUM>. To meet a playing requirement of the mobile phone, the DSP may further perform a processing process such as resampling on the decoded telephony voice signal <NUM>.

After the DSP in the kernel space performs audio mixing on the decoded audio <NUM> and audio mixing on the decoded telephony voice signal <NUM>, the DSP sends a mixed audio <NUM> to the large-screen device, and the large-screen device plays the mixed audio <NUM>.

It can be learned that in the foregoing process, after the mobile phone performs, by using the DSP, audio mixing on all audios (the audio <NUM> from the upper-layer application and the telephony voice signal <NUM> are used as an example in <FIG>) that are currently to be played, the audio device of the large-screen device plays mixed audios. Consequently, it is relatively inconvenient for the user to use. For example, in a multi-party conference scenario, the user plays a multimedia video on the mobile phone by using the large-screen device. In a process of watching an audio/a video by using the large-screen device, if a WeChat voice message is received, the user wants to obtain content of the voice message, and taps the voice message, content of the voice message is played by using a speaker of the large-screen device, and consequently, user privacy is leaked. For another example, if there is a new incoming call when the user is playing the multimedia video on the mobile phone by using the large-screen device, after the user answers the call by using the mobile phone, the audio/the video on the large-screen device is paused, or both a telephony voice and the audio played by the large-screen device are played through audio mixing by the mobile phone. This causes a relatively poor auditory effect.

An embodiment of this application provides an audio playing method. The method provided in this embodiment of this application is applicable to the foregoing scenario.

Referring to <FIG>, the method provided in this embodiment of this application includes the following steps.

An electronic device establishes a connection to an external audio device.

The connection between the electronic device and the external audio device includes a wired connection and a wireless connection. The wired connection mode includes a wired connection between the electronic device and the external audio device through a USB interface or an HDMI interface. The wireless connection mode includes a connection mode such as a Bluetooth connection or a Wi-Fi connection.

The electronic device obtains a to-be-played audio.

The to-be-played audio includes an audio of any type or in any form. Specifically, the to-be-played audio includes an audio from an audio/video application program, for example, an audio of an audio/video application program such as Tencent video, iQIYI video, or Youku video installed on a mobile phone. The to-be-played audio further includes an audio from a game application program, further includes an audio from an alarm, further includes a voice message from a social application program such as WeChat or QQ, further includes a telephony voice, and further includes a voice prompt message such as application update or message push.

In this step, when a device associated with the to-be-played audio is the electronic device, the following step <NUM> is performed to play the to-be-played audio by using only the electronic device. When a device associated with the to-be-played audio is the external audio device, the following steps <NUM> and <NUM> are performed to play the to-be-played audio by using only the external audio device.

The electronic device plays the to-be-played audio by using the electronic device.

The electronic device sends the to-be-played audio to the external audio device.

The electronic device plays the to-be-played audio by using the external audio device.

According to the foregoing method, the electronic device determines the device associated with the to-be-played audio, and plays the to-be-played audio by using the associated device. In this way, audios associated with different electronic devices can be distinguished, and can be played by using different electronic devices.

For example, when the foregoing method is applied to the scenario shown in <FIG>, after the foregoing method provided in this embodiment of this application is used, applications installed on a mobile phone are classified into an application associated with the mobile phone and an application associated with a large-screen device, an audio from the application associated with the mobile phone is played by using an audio device of the mobile phone, and an audio from the application associated with the large-screen device is played by using an audio device of the large-screen device.

Referring to <FIG>, in a possible implementation, when an audio <NUM> from the application associated with the mobile phone is detected, a framework layer initializes an audio player on the mobile phone (this is shown as a process <NUM> in <FIG>), decodes the audio <NUM> (the decoding process is a software decoding process, therefore may be referred to as software decoding, and is shown as a process <NUM> in <FIG>), to obtain a decoded audio <NUM>, and transfers the decoded audio <NUM> to an audio hub service layer. The audio hub service layer performs the following processing process on the decoded audio (the processing is shown as a process <NUM> in <FIG>): resampling (resample), applying an effect (apply effect), adjusting a volume (adjust volume), and audio mixing (mixer), and then forwards, by using a hardware abstraction layer, a processed audio to kernel space for processing. A DSP located in the kernel space plays the audio by using the audio device of the mobile phone.

For an audio <NUM> from the application associated with the large-screen device, the framework layer initializes the audio player on the mobile phone (this is shown as a process <NUM> in <FIG>), decodes the audio <NUM> (the decoding process is a software decoding process, therefore may be referred to as software decoding, and is shown as a process <NUM> in <FIG>), to obtain a decoded audio <NUM>, and transfers the decoded audio <NUM> to the audio hub service layer. The audio hub service layer performs the following processing process on the decoded audio (the processing is shown as a process <NUM> in <FIG>): resampling (resample), applying an effect (apply effect), adjusting a volume (adjust volume), and audio mixing (mixer), and then forwards, by using the hardware abstraction layer, a processed audio to the kernel space for processing. The DSP located in the kernel space sends the audio to the large-screen device, and the large-screen device plays the audio.

It can be learned that in the implementation shown in <FIG>, the audio from the application associated with the mobile phone and the audio from the application associated with the large-screen device are separately processed, and are separately output by using corresponding devices.

In addition, because a telephony voice signal is usually related to personal privacy, a telephony voice is output by using the mobile phone. The DSP detects a telephony voice signal <NUM> from a modem, and the DSP located in the kernel space directly decodes the telephony voice signal <NUM> (this is shown as a process <NUM> in <FIG>), to obtain a decoded telephony voice signal <NUM>. To meet a playing requirement of the mobile phone, the DSP may further perform a processing process such as resampling on the decoded telephony voice signal <NUM>, and then play a processed telephony voice signal by using the audio device of the mobile phone.

It should be noted that in a process of playing a voice by using the mobile phone, an audio of another application program such as WeChat installed on the mobile phone needs to be played at the same time, and a WeChat voice is an audio associated with the mobile phone and needs to be played by using the mobile phone. Another implementation may be: mixing a telephony voice signal and a WeChat voice message for playing. However, to avoid mixing of a telephony voice and an audio voice from WeChat, in this embodiment of this application, a corresponding telephony audio voice and a corresponding WeChat voice may be separately output by using different audio devices of the mobile phone. For example, a telephony voice signal is played by using earphones, and an audio from WeChat is played by using a speaker. In another implementation, to ensure a priority of a telephony voice, in the foregoing scenario, a user is allowed to play only the telephony voice, but is not allowed to play the WeChat voice message. After the telephony voice is played, the WeChat voice is played.

It is considered that in a possible scenario in actual application, before the electronic device obtains the to-be-played audio, the electronic device is playing an audio. For example, after the electronic device establishes the connection to the external audio device, the electronic device plays a first audio, and in a process in which the electronic device plays the first audio, there is a new to-be-played audio (which is described as a second audio below). In this case, a processing procedure in this embodiment of this application is as follows: The electronic device continues to play the first audio, and sends the second audio to the external audio device at the same time when the electronic device plays the first audio, and the external audio device plays the second audio. Optionally, in this step, the electronic device may alternatively send the second audio to the external audio device when the electronic device determines that the second audio is associated with the external audio device.

Therefore, in an implementation, after the electronic device establishes the connection to the external audio device, the electronic device plays the first audio. The electronic device obtains the to-be-played audio (which is described as the second audio herein), and the electronic device sends the second audio to the external audio device, so that the external audio device plays the second audio at the same time when the electronic device plays the first audio.

For example, the first audio is an audio of a first multimedia application installed on the electronic device. The second audio is an audio of a second multimedia application installed on the electronic device.

For example, the first audio is a telephony audio, and the second audio is an audio of a first multimedia application installed on the electronic device. The telephony audio includes an incoming call prompt ringtone, a prompt tone before a call is connected when the call is made, and a voice message in a voice call process after a voice call is established.

For example, the mobile phone is connected to a Bluetooth speaker. When answering a call by using the mobile phone, the user may open a music application on the mobile phone, and an audio from the music application may be played by using the Bluetooth speaker. In a process of playing music by using the Bluetooth speaker, a telephony voice on the mobile phone is not interrupted.

For example, the first audio is an audio of a social application installed on the electronic device, and the audio of the social application includes a voice message. The second audio is an audio of a multimedia application installed on the electronic device.

It is considered that in a possible scenario in actual application, before the electronic device obtains the to-be-played audio, the electronic device has instructed the external audio device to play an audio. For example, after the electronic device establishes the connection to the external audio device, the electronic device sends a first audio to the external audio device, so that the external audio device plays the first audio. In a process of playing the first audio by the external audio device, there is a new to-be-played audio (which is described as a second audio below). In this case, a processing procedure in this embodiment of this application is as follows: The external audio device continues to play the first audio, and the electronic device plays the second audio at the same time when the external audio device plays the first audio. Optionally, in this step, the electronic device may alternatively send the second audio to the external audio device when the electronic device determines that the second audio is associated with the electronic device.

Therefore, in another implementation of the method, after the electronic device establishes the connection to the external audio device, the electronic device sends the first audio to the external audio device over the connection, so that the external audio device plays the first audio. In a process of playing the first audio by the electronic device, the electronic device obtains the to-be-played audio (which is described as the second audio herein), and the electronic device plays the second audio at the same time when the external audio device plays the first audio.

For example, the first audio is an audio of a multimedia application installed on the electronic device. The second audio is a telephony audio, and the telephony audio includes an incoming call prompt ringtone, a prompt tone before a call is connected when the call is made, and a voice message in a voice call process after a voice call is established.

For example, the mobile phone is connected to a Bluetooth speaker. When music on the mobile phone is played by using the Bluetooth speaker, there is a new incoming call on the mobile phone, a ringtone of the new incoming call is played by using the mobile phone, and the user can answer the new incoming call by using the mobile phone. In the entire process, the music played by using the Bluetooth speaker is not interrupted when there is the new incoming call on the mobile phone.

For another example, the mobile phone is connected to a Bluetooth speaker. When music on the mobile phone is played by using the Bluetooth speaker, there is a new WeChat voice message on the mobile phone, and the voice message can be played by using the mobile phone. In the entire process, the music played by using the Bluetooth speaker is not interrupted when the WeChat voice message is played on the mobile phone, and the WeChat voice message and the music are played by using different devices and are not mixed.

For example, the first audio is an audio of a multimedia application installed on the electronic device. The second audio is an audio of a social application installed on the electronic device, and the audio of the social application includes a voice message.

In this embodiment of this application, which device is associated with the to-be-played audio may be determined by using the following method.

Optionally, the to-be-played audio is a to-be-played audio of a first application installed on the electronic device. That the to-be-played audio is associated with the electronic device includes: The first application is any one of first-type applications. Correspondingly, that the to-be-played audio is associated with the external audio device includes: The first application is any one of second-type applications.

The first-type applications and the second-type applications are two types of applications preset by a user. For example, based on a requirement of the user, the user sets some applications that are related to privacy and that are installed on the electronic device to the first-type applications, and sets some applications that are not related to privacy and that are installed on the electronic device to the second-type applications. Alternatively, the first-type applications and the second-type applications are two types of applications set by the electronic device based on application attributes. For example, the electronic device automatically sets, based on a result such as big data analysis, applications installed on the electronic device to privacy applications and non-privacy applications.

In this implementation, for a to-be-played audio, after an application is pre-classified, the electronic device can automatically determine which device is used to play the to-be-played audio. In a scenario in which the mobile phone is connected to the large-screen device, after the method in this embodiment of this application is used, an audio of a multimedia application is set to be associated with the large-screen device, and an audio of a social application is set to be associated with the mobile phone. The mobile phone can play the audio of the multimedia application by using a speaker of the large-screen device, and play an audio of an application related to user privacy, for example, a WeChat voice message, by using the mobile phone. This helps protect the user privacy.

For example, the first-type applications are privacy applications, and the second-type applications are non-privacy applications. In specific implementation, the electronic device pre-classifies all installed applications into privacy applications and non-privacy applications. In an implementation, the electronic device automatically classifies, according to a method such as big data statistics collection, application programs installed on the electronic device into privacy applications and non-privacy applications. For example, an audio/video application such as Tencent video, iQIYI video, or Youku video, an alarm application, an office application, and a shopping application are classified into non-privacy applications. A game application, a social application, a telephony application, and a payment application are classified into privacy applications. In another implementation, the user performs setting in a setting option of the electronic device, to classify some applications into privacy applications and classify other applications into non-privacy applications based on a requirement.

In the foregoing implementation, application programs installed on the electronic device are classified into privacy applications and non-privacy applications. When the electronic device determines that the to-be-played audio is from a privacy application, the electronic device determines that the device associated with the to-be-played audio is the electronic device, and plays the to-be-played audio by using the audio device of the electronic device. When the electronic device determines that the to-be-played audio is from a non-privacy application, the electronic device determines that the device associated with the to-be-played audio is the external audio device, and plays the to-be-played audio by using the audio device of the external audio device.

Referring to <FIG>, the user opens a setting interface <NUM> of the mobile phone. The interface displays a setting operation that can be performed by the user on the mobile phone, and includes options such as whether to enable an airplane mode, establish a Wi-Fi connection, select a mobile network type, and set a privacy application. When the user selects the option of "setting a privacy application" in the interface <NUM>, the mobile phone displays an interface <NUM>. The interface <NUM> displays all application programs installed on the mobile phone, and the user may set some of the application programs to privacy applications based on a requirement of the user. In <FIG>, an example in which the user sets "WeChat" and "QQ" to privacy applications is used for description.

Referring to <FIG>, in another implementation, to help the user search for an application program, the user opens a setting interface <NUM> of the mobile phone, and the interface <NUM> displays a setting operation that can be performed by the user on the mobile phone, and includes options such as whether to enable an airplane mode, establish a Wi-Fi connection, select a mobile network type, and set a privacy application. When the user selects the option of "setting a privacy application" in the interface <NUM>, the mobile phone displays an interface <NUM>. The mobile phone displays, in the user interface <NUM>, various types of applications installed on the mobile phone, including a "social application", a "payment application", and a "game application". The user may successively set all types of applications that need to be set to privacy applications. For example, the user taps an option on the right side of the "social application", and the mobile phone loads an interface <NUM>. The interface <NUM> displays all social applications installed on the mobile phone. The user may select all the social applications to set all the social applications to privacy applications, or may select only some of all the social applications. In <FIG>, for example, the user selects "WeChat" and "QQ". When the user taps "OK", the interface <NUM> disappears, and the mobile phone returns to the interface <NUM>. In this case, the user may select, from another type of applications, an application that needs to be set to a privacy application. After the user taps an "OK" operation in the interface <NUM>, setting of the privacy application is completed.

Referring to <FIG>, in another implementation, icons of all application programs installed on the mobile phone are successively displayed in a setting interface <NUM> of the mobile phone. The user may tap the right side of an icon of an application program, to display an option of an operation that can be performed on the application program. The option includes a setting operation that can be performed by the user on the application program. "WeChat" is used as an example. When the user taps the right side of "WeChat", an interface <NUM> is displayed. The interface <NUM> displays a setting operation that can be performed by the user on "WeChat", and includes an option about whether to set "WeChat" to a privacy application. In this option, the user may set "WeChat" to a privacy application.

Referring to <FIG> and <FIG>, as shown by <NUM>, the large-screen device connected to the mobile phone is playing a multimedia file on the mobile phone. In this case, as shown by 901a, the mobile phone does not play any audio, and there is an unread voice message from the WeChat application on the mobile phone. If the user wants to play the voice message from WeChat, as shown by 901b, the mobile phone plays the voice message. At the same time, as shown by <NUM>, the large-screen device does not pause an audio/a video that is being played, but continues to play the audio/the video. In this scenario, in a process of playing the audio/the video by the large-screen device, there is a new to-be-played audio, and the new to-be-played audio is a to-be-played audio from a privacy application. In this case, the to-be-played audio is played by using the mobile phone. In addition, the large-screen device continues to play the audio that is currently being played, at the same time when the mobile phone plays the to-be-played audio. In this way, when playing of the audio/the video by the large-screen device is not affected, an audio of a privacy application is played by using the mobile phone. This helps protect user privacy.

Referring to <FIG>, as shown by 1001a, the mobile phone is in a screen-locked state and does not play any audio. As shown by <NUM>, the large-screen device connected to the mobile phone is playing a multimedia file on the mobile phone. As shown by 1001b, when there is a new incoming call on the mobile phone, the mobile phone plays a ringtone of the incoming call; and the user can answer the call by using the mobile phone, and play a voice message in a call process. At the same time, as shown by <NUM>, the large-screen device connected to the mobile phone still continues to play a previous audio/video. Therefore, in this application scenario, when the external audio device connected to the mobile phone plays an audio, the mobile phone receives a new incoming call, the audio that is being played by the external audio device does not need to be paused, and the user can answer the new incoming call by using the mobile phone. In other words, the mobile phone and the external audio device play different audios at the same time. In this way, when playing of the audio by the external audio device is not affected, the user can answer the call by using the mobile phone.

Referring to <FIG> and <FIG>, as shown by <NUM>, the mobile phone currently does not play any audio, and at the same time, as shown by 1102a, the large-screen device currently does not play any audio, either. When the user wants to play a song, and the mobile phone determines that the song is from a non-privacy application, as shown by 1102b, the song is played by using the large-screen device.

Optionally, the to-be-played audio is a to-be-played audio of a first application installed on the electronic device. Correspondingly, that the to-be-played audio is associated with the electronic device includes: a quantity of historical times of playing the audio of the first application by using the electronic device is greater than or equal to a first threshold. Correspondingly, that the to-be-played audio is associated with the external audio device includes: a quantity of historical times of playing the audio of the first application by using the external audio device is greater than a second threshold.

The first threshold and the second threshold may be the same or may be different.

In this implementation, based on a historical playing record of the user, when the historical playing record indicates that the user frequently uses the electronic device to play an audio of an application or audios of some applications, for a to-be-played audio from the application, the to-be-played audio is still played by using the electronic device. When the historical playing record indicates that the user frequently uses the external audio device to play an audio of an application or audios of some applications, for a to-be-played audio from the application, the audio from the application is still played by using the external audio device. Therefore, in this implementation, for a to-be-played audio, the electronic device can automatically determine which device is used to play the to-be-played audio.

Referring to <FIG> and <FIG>, as shown by 1201a, the mobile phone currently does not play any audio. At the same time, as shown by 1202a, the large-screen device does not play any audio. When the user wants to play a song, and the mobile phone determines that a quantity of historical times of playing an audio of a first application corresponding to the song by using the mobile phone is N2 and N2 is greater than a preset threshold, as shown by 1201b, the mobile phone plays the song. At the same time, as shown by 1202a, the large-screen device still does not play any audio. If the mobile phone determines that a quantity of historical times of playing an audio of a first application corresponding to the song by using the large-screen device is N1 and N1 is greater than a preset threshold, as shown by 1202b, the large-screen device plays the audio. At the same time, as shown by 1201a, the mobile phone still does not play any audio.

Optionally, the to-be-played audio is a to-be-played audio of a first application installed on the electronic device. Correspondingly, that the to-be-played audio is associated with the electronic device includes: The electronic device currently displays an interface of the first application. Correspondingly, that the to-be-played audio is associated with the external audio device includes: The electronic device sends first display data to the external audio device, so that the external audio device currently displays the interface of the first application.

In this implementation, the to-be-played audio belongs to the first application. For the external audio device having a display function, when the interface of the first application is displayed by using the electronic device, it indicates that the user may be currently operating the first application by using the electronic device, and the to-be-played audio from the first application is played by using the electronic device. When the interface of the first application is displayed by using the external audio device, it indicates that the user may be currently operating the first application by using the external audio device, and the to-be-played audio from the first application is played by using the external audio device.

Optionally, in an implementation, that the to-be-played audio is associated with the electronic device includes: obtaining a first instruction entered by the user, where the first instruction is used to instruct to play the to-be-played audio on the electronic device. Correspondingly, that the to-be-played audio is associated with the external audio device includes: obtaining a second instruction entered by the user, where the second instruction is used to instruct to play the to-be-played audio on the external audio device.

In this implementation, a device instructed by the user is selected, according to the instruction of the user, to play the to-be-played audio.

For example, when both the electronic device and the external audio device display the interface of the first application, the electronic device detects, in the interface of the first application on which device, an operation that is triggered by the user to play the to-be-played audio. When the user triggers, in the interface of the first application displayed on the electronic device, to play the to-be-played audio, the to-be-played audio is played by using the electronic device. When the user triggers, in the interface of the first application displayed on the external audio device, to play the to-be-played audio, the to-be-played audio is played by using the external audio device.

For another example, the electronic device presents user prompt information, where the user prompt information is used to prompt the user which device is used to play the to-be-played audio. Correspondingly, according to an instruction triggered by the user for the user prompt information, the to-be-played audio is played by using a device instructed by the instruction.

In this implementation, each time before a to-be-played audio is played, the user is prompted to select a device for playing the to-be-played audio, and the to-be-played audio is played by using the device selected by the user.

After the mobile phone establishes the connection to the large-screen device, the mobile phone maps an icon of an installed application program to the large-screen device. The mobile phone and the large-screen device share an operating system, storage space, and the like of the mobile phone, and the large-screen device is equivalent to another display and audio output device of the mobile phone.

Referring to <FIG> and <FIG>, as shown by <NUM>, the user opens a WeChat interface, and there is an unread voice message, as shown by 1302a. At the same time, as shown by <NUM>, the large-screen device is playing an audio. When the user triggers to play the unread voice message in <NUM>, and the mobile phone detects the operation performed by the user on the mobile phone, it indicates that the user wants to play the voice message by using the mobile phone. As shown by 1302b, the mobile phone plays the voice message. At the same time, as shown by <NUM>, the large-screen device still continues to play the audio that is currently being played.

Alternatively, in another implementation, when the mobile phone detects that the large-screen device is currently playing the audio, a prompt message pops up to query the user whether to play the unread voice message by using the large-screen device. If the user determines to play the unread voice message by using the large-screen device, the voice message is played by using the large-screen device. If the user determines not to play the unread voice message by using the large-screen device, the voice message is played by using the mobile phone by default or not played.

Referring to <FIG> and <FIG>, as shown by <NUM>, an interface currently displayed by the mobile phone is a WeChat interface, and as shown by <NUM>, the mobile phone is playing a voice message from WeChat. At the same time, as shown by 1402a, icons of various application programs are displayed on the large-screen device, and as shown by 1403a, the large-screen device does not play any audio. When the mobile phone detects a trigger operation, triggered by the user in an interface 1402a of the large-screen device, for playing an audio, it indicates that the user wants to play an audio/a video by using the large-screen device. As shown by 1402b, an image is displayed on the large-screen device, and as shown by 1403b, the large-screen device plays the audio. At the same time, the mobile phone continues to play the voice message that is currently being played.

It is considered that the connection between the mobile phone and the large-screen device may be applied to a multi-party scenario, or may be applied to a scenario with few people. Privacy is not leaked. For example, the user may independently stay in a room or stay with a close classmate or friend. The user connects the mobile phone and the large-screen device to obtain good user experience when an audio/a video is played. In this way, privacy is not leaked. In this case, even if a to-be-played audio is from a privacy application, the user may still want to play the to-be-played audio by using the large-screen device.

For example, referring to <FIG>, when the mobile phone displays an unread voice message in a WeChat interface, the mobile phone displays an interface <NUM>. The interface <NUM> displays a query message for querying whether the user wants to play the voice message by using the mobile phone or the large-screen device. When the user instructs to play the voice message by using the mobile phone, the voice message is played by using the mobile phone. When the user instructs to play the voice message by using the large-screen device, the voice message is played by using the large-screen device.

For example, referring to <FIG>, when the mobile phone detects that the user answers a new incoming call, the mobile phone displays an interface <NUM>. Icons of the mobile phone and the large-screen device are displayed in the interface <NUM>, to query whether the user wants to answer the call by using the large-screen device or the mobile phone. When the user instructs to answer the call by using the mobile phone, a voice signal is played by using the mobile phone. When the user instructs to answer the call by using the large-screen device, the voice signal is played by using the large-screen device.

The foregoing mainly describes the solutions provided in the embodiments of this application from a perspective of interaction between network elements. It may be understood that, to implement the foregoing functions, each network element, such as the electronic device, includes a corresponding hardware structure and/or software module for performing each function. A person skilled in the art should easily be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps can be implemented by hardware or a combination of hardware and computer software in this application. Whether a function is performed by hardware or hardware driven by computer software depends on particular applications and design constraints of the technical solutions.

In the embodiments of this application, functional modules in the electronic device may be defined according to the foregoing method examples. For example, each functional module may be defined in a correspondence to each function, or two or more functions may be integrated in one processing module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software functional module. It should be noted that the module division in the embodiments of this application is an example, and is merely logical function division. There may be another division manner in actual implementation.

When each functional module is obtained through division based on each corresponding function, <FIG> is a possible schematic structural diagram of the electronic device in the foregoing embodiment. An electronic device <NUM> includes a connection unit <NUM>, an obtaining unit <NUM>, a playing unit <NUM>, and a sending unit <NUM>. The connection unit <NUM> is configured to establish a connection between the electronic device and an external audio device. The obtaining unit <NUM> is configured to obtain a to-be-played audio. The playing unit <NUM> is configured to play the to-be-played audio when the to-be-played audio obtained by the obtaining unit <NUM> is associated with the electronic device. The sending unit <NUM> is configured to: when the to-be-played audio obtained by the obtaining unit <NUM> is associated with the external audio device, send the to-be-played audio to the external audio device over the established connection, so that the external audio device plays the to-be-played audio.

All related content of each step in the foregoing method embodiments may be cited in function descriptions of a corresponding functional module in content of the present invention.

When an integrated unit is used, <FIG> shows a possible schematic structural diagram of the electronic device in the foregoing embodiment. An electronic device <NUM> includes a processing module <NUM> and a communications module <NUM>. The processing module <NUM> is configured to control and manage an action of the electronic device. For example, the processing module <NUM> is configured to support the electronic device in performing the process <NUM> and the process <NUM> in <FIG>, and/or is configured to perform another process of the technology described in this specification. The communications module <NUM> is configured to support the electronic device in communicating with another network entity, for example, communicating with the external audio device shown in <FIG>. The electronic device may further include a storage module <NUM>, configured to store program code and data of a base station.

The processing module <NUM> may be a processor or a controller, for example, may be a central processing unit (Central Processing Unit, CPU), a general-purpose processor, a digital signal processor (Digital Signal Processing, DSP), an application-specific integrated circuit (Application-Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or another programmable logic device, a transistor logic device, a hardware component, or a combination thereof. The processing module <NUM> may implement or execute various example logical blocks, modules, and circuits described with reference to content disclosed in this application. Alternatively, the processor may be a combination of processors implementing a computing function, for example, a combination of one or more microprocessors, or a combination of a DSP and a microprocessor. The communications module <NUM> may be a transceiver, a transceiver circuit, a communications interface, or the like. The storage module <NUM> may be a memory.

Referring to <FIG>, an embodiment of this application further provides an electronic device <NUM>, configured to perform the foregoing method. The electronic device <NUM> includes components such as a radio frequency (radio frequency, RF) circuit <NUM>, a memory <NUM>, an input unit <NUM>, a communications module <NUM>, a processor <NUM>, a power supply <NUM>, a display unit <NUM>, and an audio circuit <NUM>. A person skilled in the art may understand that a structure of the mobile phone shown in <FIG> constitutes no limitation on the mobile phone. The mobile phone may include more or fewer components than those shown in the figure, may combine some components, or may have different component arrangements.

The following separately describes functional components of the electronic device <NUM>.

The RF circuit <NUM> may be configured to receive and send information, or receive and send a signal in a call process. In particular, after receiving downlink information from a base station, the RF circuit <NUM> sends the downlink information to the processor <NUM> for processing. In addition, the RF circuit <NUM> sends uplink data to the base station. The RF circuit usually includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (low noise amplifier, LNA), a duplexer, and the like. In addition, the RF circuit <NUM> may further communicate with a network and another device through wireless communication provided by the communications module <NUM>. The wireless communication may use any communications standard or protocol, including but is not limited to a global system for mobile communications (global system for mobile communications, GSM), a general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), wideband code division multiple access (wideband code division multiple access, WCDMA), long term evolution (long term evolution, LTE), an email, a short message service (short messaging service, SMS), and the like.

The memory <NUM> may be configured to store a software program and a module, and the processor <NUM> performs various function applications of the electronic device <NUM> and data processing by running the software program and the module that are stored in the memory <NUM>. The memory <NUM> may mainly include a program storage area and a data storage area. The program storage area may store an operating system, an application program (Application, APP) required by at least one function such as a voice playing function or an image playing function. The data storage area may store data (such as audio data, image data, and an address book) that is created based on use of the electronic device <NUM>, and the like. In addition, the memory <NUM> may include a high speed random access memory, or may include a nonvolatile memory, for example, at least one magnetic disk storage device, a flash memory device, or another volatile solid-state storage device.

The input unit <NUM> may be configured to: receive entered number or character information, and generate key signal input related to a user setting and function control of the electronic device <NUM>. Specifically, the input unit <NUM> may include a touchscreen <NUM> and other input devices <NUM>. The touchscreen <NUM> is also referred to as a touch panel, and may collect a touch operation (for example, an operation performed by a user on or near the touchscreen <NUM> by using any proper object or accessory such as a finger or a stylus) performed by the user on or near the touchscreen <NUM>, and drive a corresponding connection apparatus by using a preset program. Optionally, the touchscreen <NUM> may include two parts: a touch detection apparatus and a touch controller. The touch detection apparatus detects a touch orientation of the user, detects a signal brought by the touch operation, and transfers the signal to the touch controller. The touch controller receives touch information from the touch detection apparatus, converts the touch information into touch coordinates, then sends the touch coordinates to the processor <NUM>, and can receive and execute a command sent by the processor <NUM>. In addition, the touchscreen <NUM> may be implemented in various types such as a resistive type, a capacitive type, an infrared type, and a surface acoustic wave type. In addition to the touchscreen <NUM>, the input unit <NUM> may further include the other input devices <NUM>. Specifically, the other input devices <NUM> may include but are not limited to one or more of a physical keyboard, a function key (such as a volume control key or a power on/off key), a trackball, a mouse, a joystick, and the like.

The display unit <NUM> may be configured to display information entered by the user or information provided for the user, and various menus of the electronic device <NUM>. The display unit <NUM> may include a display panel <NUM>. Optionally, the display panel <NUM> may be configured in a form of a liquid crystal display (Liquid Crystal Display, LCD), an organic light-emitting diode (Organic Light-Emitting Diode, OLED), or the like. Further, the touchscreen <NUM> may cover the display panel <NUM>. After detecting a touch operation on or near the touchscreen <NUM>, the touchscreen <NUM> transfers the touch operation to the processor <NUM> to determine a type of a touch event. Then the processor <NUM> provides a corresponding visual output on the display panel <NUM> based on the type of the touch event. Although in <FIG>, the touchscreen <NUM> and the display panel <NUM> are used as two independent components to implement input and output functions of the electronic device <NUM>, in some embodiments, the touchscreen <NUM> and the display panel <NUM> may be integrated to implement the input and output functions of the electronic device <NUM>.

The audio circuit <NUM>, a speaker <NUM>, and a microphone <NUM> may provide audio interfaces between the user and the electronic device <NUM>. The audio circuit <NUM> may transmit, to the speaker <NUM>, an electrical signal converted from received audio data, and the speaker <NUM> converts the electrical signal into a sound signal for outputting. In another aspect, the microphone <NUM> converts a collected sound signal into an electrical signal, and the audio circuit <NUM> converts the electrical signal into audio data after receiving the electrical signal, and then outputs the audio data to the RF circuit <NUM> to send the audio data to, for example, another mobile phone, or outputs the audio data to the memory <NUM> for further processing.

The processor <NUM> is a control center of the electronic device <NUM>, is connected to all parts of the entire mobile phone through various interfaces and lines, and executes, by running or executing the software program and/or the module stored in the memory <NUM> and by invoking data stored in the memory <NUM>, various functions of the electronic device <NUM> and data processing, to perform overall monitoring on the mobile phone. Optionally, the processor <NUM> may include one or more processing units. Optionally, the processor <NUM> may integrate an application processor and a modem processor. The application processor mainly processes an operating system, a user interface, an application program, or the like. The modem processor mainly processes wireless communication. It may be understood that the modem processor may alternatively not be integrated into the processor <NUM>.

The electronic device <NUM> further includes the power supply <NUM> (for example, a battery) that supplies power to each component. Preferably, the power supply may be logically connected to the processor <NUM> by using a power management system, so as to implement a function such as charging, discharging, and power consumption management by using the power management system.

Although not shown, the electronic device <NUM> further includes sensors such as a gravity sensor (gravity sensor), an optical sensor, and an infrared sensor. Specifically, the gravity sensor may detect an acceleration value of the mobile phone in each direction (there are usually three axes), and detect a value and a direction of gravity in a static mode, and may be applied to an application that recognizes a posture of the mobile phone (for example, switching between landscape orientation and portrait orientation, a related game, or magnetometer posture calibration), a function related to vibration recognition (such as a pedometer or a knock), and the like. The optical sensor may include an ambient light sensor and an optical proximity sensor. The ambient light sensor may adjust luminance of the display panel <NUM> based on brightness of ambient light. The optical proximity sensor may detect whether an object approaches or touches the mobile phone, and may turn off and/or backlight the display panel <NUM> when the electronic device <NUM> moves to an ear. In addition, the electronic device <NUM> may be further configured with an antenna, a Wi-Fi module, a near field communication (near field communication, NFC) unit, a Bluetooth module, a speaker, an accelerometer, a gyroscope, a barometer, a hygrometer, and a thermometer. The electronic device <NUM> may be further configured with a sensor configured to implement biometric recognition, such as a fingerprint recognition sensor or an iris recognition sensor.

Claim 1:
An audio playing method, wherein the method comprises:
after the electronic device establishes a connection to an external audio device, sending (<NUM>), by the electronic device, a first audio to the external audio device over the connection, so that the external audio device plays the first audio;
obtaining (<NUM>), by the electronic device, a to-be-played second audio; and
playing (<NUM>), by the electronic device, the second audio at the same time when the external audio device plays the first audio; characterized in that the playing, by the electronic device, the second audio comprises:
when the second audio is associated with the electronic device, playing, by the electronic device, the second audio;
wherein the second audio is a to-be-played audio of a first application installed on the electronic device; and
that the second audio is associated with the electronic device comprises:
a quantity of historical times of playing the audio of the first application by using the electronic device is greater than or equal to a first threshold.