telethon - 如何使用 Telethon 发送音频文件,以便可以在移动应用内媒体播放器中播放音频?
问题描述
我尝试使用这两个功能,音频仍然无法在应用媒体播放器中播放
await client.send_file(chat, '/my/songs/song.mp3', voice_note=True)
await client.send_file(chat, '/my/songs/song.mp3', attributes=[DocumentAttributeFilename(file_name=fileName + '.mp3'), DocumentAttributeAudio(duration=100, voice=True)])
解决方案
我正在寻找可以使用应用内音频播放器播放的音频。
好的,您只需要在此处send_file
的库文档中使用 , 参考。
import asyncio
from telethon import TelegramClient
client = TelegramClient('SESSION_NAME', 'YOUR_API_ID', 'YOUR_API_HASH')
client.start(phone=+xxxxxxxxxxxx)
async def main():
await client.send_file('me', 'test.mp3')
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
推荐阅读
- javascript - 进入新部分后旋转徽标
- c# - 使用 LINQ 转换带有索引的 for 循环
- git - 在同一文件中自动合并修改
- javascript - JS合并数组并划分合并值
- cassandra - Cassandra 有时会跳过 SELECT 查询中的记录
- angular - 如何等待谷歌地理编码返回响应?
- javascript - 使用键盘 (JS) 更改页面上的内容(使用图像)
- python - 使用 Vader-AttributeError 进行情绪分析:'float' 对象没有属性 'encode'
- visual-studio-code - vscode omnisharp 不适用于解决方案,但适用于项目
- ios - 如何通过 Observable 属性对项目数组进行排序?