Device networking and audio channel configuration method, and electronic device
This application provides example device networking and audio channel configuration methods, applied to a system including a first electronic device and at least one audio device. One example method includes sending, by an audio device of the at least one audio device, a networking packet in response to detecting a first gesture. The first electronic device receives the networking packet. The first electronic device establishes a correspondence between the audio device corresponding to the networking packet and an audio channel indicated by a direction corresponding to the first gesture, the established correspondence allowing the audio device corresponding to the networking packet to be configured to play audio of the audio channel indicated by the direction corresponding to the first gesture. The first electronic device establishes a networking connection to the audio device.
1 . A device networking and audio channel configuration method, applied to a system comprising a first electronic device and at least one audio device, wherein the method comprises:
sending, by an audio device of the at least one audio device, a networking packet in response to detecting a first gesture, wherein the first gesture is a waving gesture;
receiving, by the first electronic device, the networking packet;
determining, by the first electronic device, a direction of the waving gesture;
determining an audio channel of the audio device to be an audio channel having a spatial orientation that is the same as the direction of the waving gesture;
establishing, by the first electronic device, a correspondence between the audio device corresponding to the networking packet and the audio channel, the established correspondence allowing the audio device corresponding to the networking packet to be configured to play audio of the audio channel; and
establishing, by the first electronic device, a networking connection to the audio device.
2 . The method according to claim 1 , wherein the determining, by the first electronic device, a direction of the waving gesture comprises at least one of:
determining, by the first electronic device, the direction corresponding to the first gesture through gesture recognition; or
before the first electronic device establishes the correspondence:
sending, by the first electronic device, prompt information that is used to prompt a user to wave toward the audio device; and
determining, by the first electronic device, the direction corresponding to the first gesture based on the prompt information.
3 . The method according to claim 1 , wherein the audio device comprises a speaker and a microphone, the speaker is configured to send an ultrasonic wave, the microphone is configured to receive an ultrasonic echo corresponding to the ultrasonic wave, and the detecting, by the audio device, a first gesture comprises:
detecting, by the audio device, the first gesture based on the ultrasonic wave and the ultrasonic echo according to a Doppler frequency shift principle.
4 . The method according to claim 1 , wherein the first electronic device and the audio device are located in a same local area network, and the sending, by the audio device, a networking packet comprises:
broadcasting, by the audio device, the networking packet in the local area network.
5 . The method according to claim 1 , wherein the method further comprises:
sending, by the first electronic device, to-be-played audio to the audio device through the networking connection.
6 . The method according to claim 1 , wherein the networking packet carries at least one of a device type identifier or an internet protocol (IP) address of the audio device.
7 . The method according to claim 1 , wherein the determining an audio channel of the audio device to be an audio channel having a spatial orientation that is the same as the direction of the waving gesture comprises:
when the direction of the waving gesture is left, determining that the audio channel of the audio device is a left audio channel; or
when the direction of the waving gesture is right, determining that the audio channel of the audio device is a right audio channel.
8 . The method according to claim 1 , wherein the determining, by the first electronic device, a direction of the waving gesture comprises:
determining the direction of the waving gesture by using an ultrasonic gesture recognition technology.
9 . A device networking and audio channel configuration method, applied to a system comprising at least a first electronic device, a first audio device, and a second audio device, wherein the method comprises:
broadcasting, by the first audio device, a first networking packet in response to detecting a first approaching gesture;
receiving, by the first electronic device, the first networking packet;
determining, by the first electronic device, that the first approaching gesture is a gesture toward a first direction, wherein the first direction corresponds to a first audio channel, wherein the first approaching gesture is a waving gesture;
determining an audio channel of the first audio device to be an audio channel having a spatial orientation that is the same as the first direction;
establishing, by the first electronic device, a correspondence between the first audio device and the first audio channel to allow the first audio device to be configured to play audio of the first audio channel;
establishing, by the first electronic device, a first networking connection to the first audio device;
broadcasting, by the second audio device, a second networking packet in response to detecting a second approaching gesture;
receiving, by the first electronic device, the second networking packet;
determining, by the first electronic device, that the second approaching gesture is a gesture toward a second direction, wherein the second direction corresponds to a second audio channel;
establishing, by the first electronic device, a correspondence between the second audio device and the second audio channel to allow the second audio device to be configured to play audio of the second audio channel; and
establishing, by the first electronic device, a second networking connection to the second audio device.
10 . The method according to claim 9 , wherein the method further comprises:
sending, by the first electronic device, the audio of the first audio channel to the first audio device through the first networking connection; and
sending, by the first electronic device, the audio of the second audio channel to the second audio device through the second networking connection.
11 . The method according to claim 9 , wherein the method further comprises:
sending, by the first electronic device, a first indication message to the first audio device, wherein the first indication message indicates the first audio device to play the audio of the first audio channel; and
sending, by the first electronic device, a second indication message to the second audio device, wherein the second indication message indicates the second audio device to play the audio of the second audio channel.
12 . The method according to claim 9 , wherein
when the first audio device is placed on a left side of the first electronic device and the second audio device is placed on a right side of the first electronic device,
the first approaching gesture is a gesture of waving toward the first audio device, the second approaching gesture is a gesture of waving toward the second audio device, the first direction is left, the second direction is right, the first audio channel is a left audio channel, and the second audio channel is a right audio channel.
13 . The method according to claim 9 , wherein the determining an audio channel of the first audio device to be an audio channel having a spatial orientation that is the same as the first direction comprises:
when the first direction is left, determining that the audio channel of the first audio device is a left audio channel; or
when the first direction is right, determining that the audio channel of the first audio device is a right audio channel.
14 . The method according to claim 9 , wherein the determining, by the first electronic device, that the first approaching gesture is a gesture toward a first direction comprises:
determining the first direction by using an ultrasonic gesture recognition technology.
15 . An electronic device, comprising:
at least one processor; and
one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to:
detect a waving gesture, and monitor whether a networking packet in a preset format exists in a local area network;
determine a direction of the waving gesture; and
when a first networking packet conforming to the preset format is received from an audio device after the waving gesture is detected;
determine an audio channel of an audio device to be an audio channel having a spatial orientation that is the same as the direction of the waving gesture; and
configure the audio device that sends the first networking packet to play audio of the audio channel.
16 . The electronic device according to claim 15 , wherein determining the audio channel of the audio device to be the audio channel having the spatial orientation that is the same as the direction of the waving gesture comprises:
when the direction of the waving gesture is left, determining that the audio channel of the audio device is a left audio channel; or
when the direction of the waving gesture is right, determining that the audio channel of the audio device is a right audio channel.
17 . The electronic device according to claim 15 , wherein determining the direction of the waving gesture comprises:
determining the direction of the waving gesture by using an ultrasonic gesture recognition technology.
18 . An audio device, comprising:
at least one processor; and
one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to:
detect an approaching gesture, and broadcast a networking packet in a preset format after the approaching gesture is detected, wherein a direction of the approaching gesture is determined, and wherein an audio channel of the audio device is determined to be an audio channel having a spatial orientation that is the same as the direction of the approaching gesture;
establish a networking connection to an electronic device that receives the networking packet in the preset format; and
receive audio of the audio channel sent by the electronic device, and play the audio of the audio channel.
19 . The audio device according to claim 18 , wherein:
when the direction of the approaching gesture is left, the audio channel of the audio device is determined to be a left audio channel; or
when the direction of the approaching gesture is right, the audio channel of the audio device is determined to be a right audio channel.
20 . The audio device according to claim 18 , wherein the direction of the approaching gesture is determined by using an ultrasonic gesture recognition technology.