Comments (17)
你能给我说,改哪里吗?或者有没有可参考的资料。我会一点python。
from feeluown-core.
已经完成了
from feeluown-core.
main.py
def main():
debug = '--debug' in sys.argv
setup_logger(debug=debug)
logger = logging.getLogger(__name__)
logger.info('{} mode.'.format('Debug' if debug else 'Release'))
import re
audio = ''
for arg in sys.argv:
matchobj = re.match('--mpv-audio-device=',arg)
if matchobj:
print(matchobj.group())
audio = bytes(arg[19:],'utf-8')
print(audio)
break
pubsub_gateway, pubsub_server = run_pubsub() # runs in another thread
app = App()
app.initialize(audio)
from feeluown-core.
`main.py
class App(object):
def __init__(self):
self.player = MpvPlayer()
self.playlist = self.player.playlist
self.source = Source()
def initialize(self,audio=''):
self.player.initialize(audio)
from feeluown-core.
player.py
from mpv import MPV, MpvEventID, MpvEventEndFile, _mpv_set_property_string
........
.......
def initialize(self,audio=''):
self._mpv.observe_property(
'time-pos',
lambda name, position: self._on_position_changed(position)
)
self._mpv.observe_property(
'duration',
lambda name, duration: self._on_duration_changed(duration)
)
if audio: _mpv_set_property_string(self._mpv.handle, b'audio-device', audio)
from feeluown-core.
目前还没有考虑 “选择声卡” 的功能。
不过乍一听,感觉操作系统自身应该会提供这个功能。 🤔
from feeluown-core.
我在树莓派上的tty1下使用,调了默认声卡,也切换不过去;能像aplay -D一样选择声卡吗?
from feeluown-core.
ummm,这个项目的音乐播放是基于 (libmpv) mpv,由于我这边没有树莓派,有些测试我这边也不是很方便进行。
你可以先测试一下 mpv 在树莓派上能不能正常播放音乐?能不能选择声卡?如果可以的话,我们应该也能让这个项目支持相关功能。
from feeluown-core.
就是不能选择声卡,每次调用的都是系统的[bcm2835 ALSA]我想用的是[seeed-2mic-voicecard]。
下面是我的声卡信息
card 0: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
from feeluown-core.
你可以先测试一下: mpv 是否支持选择一个声卡播放音乐?
具体的测试方法:
mpv --audio-device=help # List of detected audio devices
mpv --audio-device=xxx filepath # 指定为你的声卡,播放音乐
如果这个测试是成功的,我们或许也就有办法让 feeluown-core 支持类似的配置
from feeluown-core.
List of detected audio devices:
'auto' (Autoselect device)
'pulse/alsa_output.platform-soc_audio.analog-stereo' (bcm2835 ALSA Analog Stereo)
'pulse/alsa_output.platform-soc_sound.analog-stereo' (seeed-2mic-voicecard Analog Stereo)
'alsa' (Default (alsa))
'alsa/playback' (playback)
'alsa/capture' (capture)
'alsa/dmixed' (dmixed)
'alsa/array' (array)
'alsa/plughw:CARD=ALSA,DEV=0' (bcm2835 ALSA, bcm2835 ALSA/Hardware device with all software conversions)
'alsa/plughw:CARD=ALSA,DEV=1' (bcm2835 ALSA, bcm2835 IEC958/HDMI/Hardware device with all software conversions)
'alsa/plughw:CARD=seeed2micvoicec,DEV=0' (seeed-2mic-voicecard, /Hardware device with all software conversions)
'jack' (Default (jack))
'sdl' (Default (sdl))
'sndio' (Default (sndio))
'alsa/plughw:CARD=seeed2micvoicec,DEV=0' (seeed-2mic-voicecard, /Hardware device with all
from feeluown-core.
mpv --audio-device=alsa/plughw:CARD=seeed2micvoicec,DEV=0 2.mp3
没有问题,可以播放
from feeluown-core.
棒!我这周看看怎么支持这个东西 ~
from feeluown-core.
谢谢,用专用声卡的,效果是要nice一些,谢谢了。我在树莓派上和ubuntu上使用的时候,修改了一点源代码,才用起来的
from feeluown-core.
大概的思路是这样子
from mpv import _mpv_get_property_string
from mpv import _mpv_set_property_string
player = MPV()
url = '' # 给一个可以播放的 url
player.play(url)
# 可以查看当前 audio device,默认应该是 `auto`
_mpv_get_property_string(player.handle, b'audio-device')
# 可以看到所有的 audio device
_mpv_get_property_string(player.handle, b'audio-device-list')
# 设置 audio device,这时候注意听声音是否正常
_mpv_set_property_string(player.handle, b'audio-device', b'xxx')
参考的资料主要是:
- mpv player 文档: https://mpv.io/manual/stable/#command-interface-audio-device-list
- mpv.py 源码 https://github.com/cosven/feeluown-core/blob/master/mpv.py
对应的 feeluown-core 代码的地方是: https://github.com/cosven/feeluown-core/blob/master/fuocore/core/player.py#L295
之后我想把这个设置加入到命令参数设置中去,大概类似:
fuo -d # 原来是这样启动
fuo -d --mpv-audio-device=xxx # 之后支持启动时给 mpv 播放器配置参数 --mpv-xx=value
from feeluown-core.
赞,我今天晚上集成一下 ~
改成明早 =。=
from feeluown-core.
最新代码应该可以支持了 --mpv-audio-device
的选项 ~
(过一两天,会给这个包发个新的 alpha 版本
from feeluown-core.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feeluown-core.