简体   繁体   English

在Android中通过蓝牙发送音频文件(到耳机)

[英]Sending an audio file (to headset) through Bluetooth in Android

Well I read many threads in Stack overflow about file transfer by bluetooth in android and they have mentioned that sending "any" file is same whether its a *.txt file or a song. 好吧,我通过蓝牙在android中读取了关于文件传输的堆栈溢出中的许多线程,并且他们已经提到发送“任何”文件是相同的,无论是* .txt文件还是歌曲。 But I am using a headset on which i want a music to play by bluetooth. 但我正在使用耳机,我希望通过蓝牙播放音乐。 It requires such protocols 它需要这样的协议

Audio/video data transport protocol (AVDTP) Used by the advanced audio distribution profile to stream music to stereo headsets over an L2CAP channel. 音频/视频数据传输协议(AVDTP)由高级音频分发配置文件用于通过L2CAP通道将音乐流式传输到立体声耳机。 Intended to be used by video distribution profile. 拟用于视频分发配置文件。 In the protocol stack, AVDTP is bound to L2CAP. 在协议栈中,AVDTP绑定到L2CAP。

We have to use this protocol to stream the data. 我们必须使用此协议来传输数据。 So I don't think any normal file transfer would work. 所以我认为任何正常的文件传输都不会起作用。 Can some redirect me to tutorial wherin I can code for such an application or help me by any ways or link? 有些人可以将我重定向到教程我可以编写这样的应用程序代码或通过任何方式或链接帮助我吗? Thank you in advance 先感谢您

Are you just trying to play music from the device to a bluetooth headset? 您是否只是尝试将音乐从设备播放到蓝牙耳机?

If so, you don't need to do anything to get it to play on the headset. 如果是这样,您无需做任何事情就可以在耳机上播放。 Simply play the music as you normally would (with MediaPlayer or AudioTrack) and pair the bluetooth headset in android settings and it will play fine 只需像往常一样播放音乐(使用MediaPlayer或AudioTrack),并在Android设置中配对蓝牙耳机,它就可以正常播放

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM