Coder Social home page Coder Social logo

cosven / feeluown-core Goto Github PK

View Code? Open in Web Editor NEW
30.0 4.0 3.0 13.03 MB

提供音乐播放器的一些常见组成模块(已经合并到 feeluown 项目中)

Home Page: https://feeluown-core.readthedocs.io

License: MIT License

Python 99.77% Makefile 0.23%
netease xiami player mpv python feeluown

feeluown-core's Issues

将一首歌从播放列表移除后,播放下一首歌就会报错

[ERROR] [__init__ exec_cmd 75] : handle cmd(action:status args:()) error
Traceback (most recent call last):
  File "/home/cosven/.local/lib/python3.5/site-packages/fuocore/protocol/handlers/__init__.py", line 71, in exec_cmd
    cmd_rv = handler.handle(cmd)
  File "/home/cosven/.local/lib/python3.5/site-packages/fuocore/protocol/handlers/__init__.py", line 119, in handle
    'song:      {}'.format(show_song(player.current_song, brief=True)),  # noqa
  File "/home/cosven/.local/lib/python3.5/site-packages/fuocore/protocol/handlers/helpers.py", line 15, in show_song
    artists = song.artists or []
AttributeError: 'NoneType' object has no attribute 'artists'

声卡选择

这个可以选择播放的声卡吗?怎么操作呢?

当扫描到一些不是视频文件的时候出错

我有一些MV视频在歌曲文件夹里面。当运行 fuo --debug的时候报错:

[INFO] [__main__ main 17] : Release mode.
Traceback (most recent call last):
  File "/home/stardiviner/.virtualenvs/python3.6/bin/fuo", line 11, in <module>
    sys.exit(main())
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/__main__.py", line 20, in main
    local_provider = LocalProvider()
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/local/provider.py", line 48, in __init__
    self.library_paths = library_paths
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/local/provider.py", line 57, in library_paths
    self._songs = self.scan()
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/decorators.py", line 13, in wrapper
    result = func(*args, **kwargs)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/local/provider.py", line 84, in scan
    songs = [self.model_from_fpath(fpath) for fpath in media_files]
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/local/provider.py", line 84, in <listcomp>
    songs = [self.model_from_fpath(fpath) for fpath in media_files]
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/fuocore/local/provider.py", line 93, in model_from_fpath
    metadata = EasyMP3(fpath)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/mutagen/_file.py", line 49, in __init__
    self.load(*args, **kwargs)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/mutagen/_util.py", line 140, in wrapper
    return func(self, h, *args, **kwargs)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/mutagen/id3/_file.py", line 406, in load
    self.info = self._Info(fileobj, offset)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/mutagen/_util.py", line 169, in wrapper
    return func(*args, **kwargs)
  File "/home/stardiviner/.virtualenvs/python3.6/lib/python3.6/site-packages/mutagen/mp3/__init__.py", line 403, in __init__
    raise HeaderNotFoundError("can't sync to MPEG frame")
mutagen.mp3.HeaderNotFoundError: can't sync to MPEG frame

改进player.playlist的数据结构

player.playlist 里使用list来存放歌曲, 在查询/添加/删除歌曲的时候复杂度均为O(n). 如果想要支持衍生的一些想法中几万张专辑这样的大歌单, 应该会非常低效.

目前有两个想法:

  1. linked list: 利用一个链表来存放歌曲, 然后用一个dict索引 song->linked list node, 从而维护歌单的有序结构.
  2. list with empty slots: 同样利用list和dict存放歌曲, 删除歌曲的时候设为None保留空位, 然后当歌曲小于2/3 list长度的时候resize.

3种方案比较:

operation raw list linked list list with empty slots
append O(N) O(1) O(1)
search O(N) O(1) O(1)
remove O(N) O(1) Amortized O(1)
memory song size song size + dict size + references x N song size + dict size
drawback too slow can't directly access by index insertion after a song is O(N)

目前利用整数代替歌曲测试, 添加100000整数, 然后随机删除:

  • raw list: append 95.6s, remove 70.2s ;
  • linked list: append 0.35s, remove 0.26s;
  • list with empty slots: append 0.05s, remove 0.12s.

可以看到第三种方案相当迅速(linked list需要在nodes 之间跳转), 但缺点在于插入歌曲时的效率依然较差.

另外, 我觉得在playlist里不必要维护 good songs和bad songs, 在 player播放有误的时候跳过就好了.

music player DSL?

音乐播放有什么操作

以前的磁带、复读机:快退,暂停/播放,停止,快进
MP3:复读机的所有功能,曲库管理,选择某一首播放,上一首,下一首;

> resume 
> pause
> stop
> play 晴天
> seek 2:34

TODO list.

  • bugfix Restart failed, "Address already in use"
  • refactor code structure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.