Linux命令行音乐播放器moc

moc(Music On Console,播放器程序是mocp,在Arch Linux的Commity中有个tray版本的moc,启动时会在面板上显示一个图标,能直接启动mocp服务和播放器。甚至还能让osdlyrics加载桌面歌词,不过这很卡.)适用于命令行,在黑乎乎的Linux核心控制台(字符界面)上也能成功启动和播放,但Linux核心控制台默认是没有中文支持的,可以试试能显示中文的fbterm(直接从核心控制台启动,不需要运行X服务)如果需要的话。即便如此,正常使用仍然需要一番手动配置才行,如果全是英文歌曲的话例外。

基本上很多的Linux发行的官方源中已经包含了这个软件包,直接使用软件包管理工具安装。Arch Linux的是pacman。

注:启动mocp之前,如果需要启用更多的音频格式支持,有必要从源上安装解码器

1.mocp配置

在配置mocp之前,可以先从moc的man手册页或者info页获取更多的信息(比如配置文件是什么,应该放到什么位置,格式应该是什么样的......)

$ mocp --help

$ man mocp

$ info mocp

注:

moc的aur版本允许mocp加载歌词(但仅限某些utf-8编码的ascii文本(纯英文)),这个版本会和系统中已经安装的冲突.

虽然osdlyrics理论上也支持moc,然而仅仅只是安装moc然后打开mocp再打开osdlyrics并不会加载音频文件的lyrics的(尽管这也不会导致osdlyrics退出)

要让osdlyrics真正支持moc,还要安装moc-tray这个任务栏小程序并在启动osdlyrics之前启动mocp和moc-tray.

moc-tray可以直接启动mocp并且支持停止/播放/暂停/退出,下一首/上一首等动作,不过某些动作需要在mocp中配置播放列表才能得到正确响应。

aur上的moc构建和安装:

下载PKGBUILD等makepkg需要的脚本.

$ git clone https://aur.archlinux.org/moc-lyrics-git.git

$ pushd mocp-lyrics-git

$ makepkg -sr

编译成功之后会产生一个.pkg.tar.xz包,然后使用pacman -U安装

$ mv moc-lyrics-git-1\:0.2213.c51e02e-1-x86_64.pkg.tar.xz moc-lyrics-git-x86_64.pkg.tar.xz

# pacman -U moc-lyrics-git-x86_64.pkg.tar.xz

拷贝mocp示例配置文件到~/.moc(没有就创建),参数配置可以从示例文件config.example(可以运行locate config.example)中找到

mocp的示例配置文件尽管使用了英文,但解释的很详细.

$ mkdir ~/.moc

$ cp `locate config.example` ~/.moc/config

下面这是从实例配置文件拷过来的,以#号开始的都是注释(尽管注释看起来显得晦涩难懂,但作者解释的很清楚)。

~/.moc/config

   1 # This is a configuration file for the MOC player. It should be named
   2
   3 # ‘config‘ and placed in the ~/.moc directory. As this file can specify
   4
   5 # commands which invoke other applications, MOC will refuse to start if it
   6
   7 # is not owned by either root or the current user, or if it is writable by
   8
   9 # anyone other than its owner. All options are given with their default
  10
  11 # values, and therefore commented.
  12
  13
  14
  15 # Comments begin with ‘#‘.
  16
  17 # You can use quotes and escape (‘\‘) in parameters.
  18
  19 #
  20
  21 # You can have variable values substituted by enclosing the variable name
  22
  23 # as "${...}". (This only applies to the portion of the option following
  24
  25 # the ‘=‘.) Variables are substituted first from the environment then,
  26
  27 # if not found, from the configuration options. (Note that the value of
  28
  29 # a configuration option substituted is that which it has at the time the
  30
  31 # substitution variable is encountered.) If there is a naming conflict
  32
  33 # between an environment and configuration variable, you may be able to
  34
  35 # resolve it by using lowercase as the environment variable matches are
  36
  37 # case-sensitive whereas the configuration variables are not.
  38
  39 #
  40
  41 # You can also use the form "${...:-...}" where the value in the second
  42
  43 # position will be substituted if the variable name given in the first
  44
  45 # position is unset or null.
  46
  47 #
  48
  49 # So, for example:
  50
  51 #
  52
  53 # MusicDir = /music/${USER:-public}
  54
  55 # Fastdir1 = ${MusicDir}/mp3/rock
  56
  57 # Fastdir2 = ${MusicDir}/mp3/electronic
  58
  59 # Fastdir3 = ${MusicDir}/mp3/rap
  60
  61 # Fastdir4 = ${MusicDir}/mp3/etc
  62
  63 #
  64
  65 # Variable names are limited to those accepted by the BASH shell; that
  66
  67 # is, those comprising the upper- and lowercase ASCII characters, digits
  68
  69 # and the underscore.
  70
  71 #
  72
  73 # If you need to use the "${" sequence for any other purpose, write "$${"
  74
  75 # and it will be replaced by "${" and not treated as a substitution.
  76
  77 #
  78
  79 # Some options take lists of strings as their values. The strings are
  80
  81 # separated by colons. Additional strings can be appended to the list
  82
  83 # using "+=" in place of a plain "=" to assign the value. For an example,
  84
  85 # see the XTerms option.
  86
  87 #
  88
  89 # You can override any configuration option when you run MOC using the
  90
  91 # ‘-O‘ command line option:
  92
  93 #
  94
  95 # mocp -O AutoNext=no -O messagelingertime=1 -O XTerms+=xxt:xwt
  96
  97 #
  98
  99 # This command line option can be repeated as many times as needed and
 100
 101 # the configuration option name is not case sensitive. (Note that MOC
 102
 103 # does not perform variable substitution on the value of such overridden
 104
 105 # configuration options.) Most option values are set before the
 106
 107 # configuration file is processed (which allows the new values to be
 108
 109 # picked up by substitutions), however list-valued options are overridden
 110
 111 # afterwards (which gives the choice of whether the configured values are
 112
 113 # replaced or added to).
 114
 115
 116
 117 # Remember that the client and server are separate processes and the
 118
 119 # server will retain the configuration values formed from the environment
 120
 121 # within which it was originally started.
 122
 123
 124
 125 # Show file titles (title, author, album) instead of file names?
 126
 127 # 音频播放器会从音频文件中读取并在播放列表中显示音频文件媒体库元信息(包括标题,歌手,专辑等信息),Windows中的音频文件元信息(ID标签)默认和Linux使用了不同的字符集编码,因此从windows下载的音频文件可能在播放列表中很多元信息显示为乱码。不读取这些元信息只能避免在moc不显示为乱码,但并不能从根本上解决音频文件元信息显示为乱码的问题! 如果确实需要元信息正常显示,可以移步Arch wiki
 128
 129 ReadTags = no
 130
 131 # In which directory do you store your music files? If you specify it
 132
 133 # you will be able to jump straight to this directory with the ‘-m‘
 134
 135 # parameter or the ‘m‘ command. This can also point to a playlist.
 136
 137 #
 138
 139 # Example: MusicDir = "/home/joe/music"
 140
 141 #
 142
 143 #MusicDir =
 144
 145 MusicDir = /media/Others/Audio-Frequency
 146
 147 # Start in the music directory by default? If set to ‘no‘, start
 148
 149 # in the current directory by default. A single directory on
 150
 151 # the command line takes precedence.
 152
 153 StartInMusicDir = yes
 154
 155
 156
 157 # The number of lines which are retained in an in-memory circular logging
 158
 159 # buffer. A value of zero indicates that lines will be written directly
 160
 161 # to the log file, otherwise the latest CircularLogSize lines are retained
 162
 163 # in memory and not written to the log file until the MOC client or server
 164
 165 # are shutdown. If the client or server terminates abnormally then the
 166
 167 # log lines are lost.
 168
 169 #
 170
 171 # This option is intended to help identify problems which occur infrequently
 172
 173 # and for which the amount of disk space consumed by logging would otherwise
 174
 175 # be a limiting factor. Obviously the memory footprint will increase in
 176
 177 # proportion to the value of this option.
 178
 179 #CircularLogSize = 0
 180
 181
 182
 183 # How to sort? FileName is the option‘s only value for now.
 184
 185 #Sort = FileName
 186
 187
 188
 189 # Show errors in the streams (for example, broken frames in MP3 files)?
 190
 191 #ShowStreamErrors = no
 192
 193
 194
 195 # Ignore CRC errors in MP3 files? Most players do that, so the default
 196
 197 # value is ‘yes‘.
 198
 199 MP3IgnoreCRCErrors = yes
 200
 201
 202
 203 # Set playback toggles.
 204
 205 # 设置播放标志
 206
 207 Repeat = yes #是否循环播放
 208
 209 Shuffle = yes #是否开启随机播放
 210
 211 AutoNext = yes #是否自动播放下一首
 212
 213
 214
 215 # Default FormatString:
 216
 217 #
 218
 219 # %n - Track number
 220
 221 # %a - Artist
 222
 223 # %A - Album
 224
 225 # %t - Title
 226
 227 # %(X:TRUE:FALSE) - Ternary expression: if X exists, do TRUE,
 228
 229 # otherwise FALSE. The escape character must
 230
 231 # be doubled (i.e., ‘\\‘). (See zshmisc
 232
 233 # documentation for more information.)
 234
 235 #
 236
 237 #FormatString = "%(n:%n :) %f"
 238
 239
 240
 241 # Input and output buffer sizes (in kilobytes).
 242
 243 #InputBuffer = 512 # Minimum value is 32KB
 244
 245 #OutputBuffer = 512 # Minimum value is 128KB
 246
 247
 248
 249 # How much to fill the input buffer before playing (in kilobytes)?
 250
 251 # This can‘t be greater than the value of InputBuffer. While this has
 252
 253 # a positive effect for network streams, it also causes the broadcast
 254
 255 # audio to be delayed.
 256
 257 #Prebuffering = 64
 258
 259
 260
 261 # Use this HTTP proxy server for internet streams. If not set, the
 262
 263 # environment variables http_proxy and ALL_PROXY will be used if present.
 264
 265 #
 266
 267 # Format: HTTPProxy = PROXY_NAME:PORT
 268
 269 #
 270
 271 #HTTPProxy =
 272
 273
 274
 275 # Sound driver - OSS, ALSA, JACK, SNDIO (on OpenBSD) or null (only for
 276
 277 # debugging). You can enter more than one driver as a colon-separated
 278
 279 # list. The first working driver will be used.
 280
 281 #SoundDriver = JACK:ALSA:OSS
 282
 283 SoundDriver = ALSA:OSS:JACK
 284
 285
 286
 287 # Jack output settings.
 288
 289 #JackClientName = "moc"
 290
 291 #JackStartServer = no
 292
 293 #JackOutLeft = "system:playback_1"
 294
 295 #JackOutRight = "system:playback_2"
 296
 297
 298
 299 # OSS output settings.
 300
 301 #OSSDevice = /dev/dsp
 302
 303 #OSSMixerDevice = /dev/mixer
 304
 305 #OSSMixerChannel1 = pcm # ‘pcm‘, ‘master‘ or ‘speaker‘
 306
 307 #OSSMixerChannel2 = master # ‘pcm‘, ‘master‘ or ‘speaker‘
 308
 309
 310
 311 # ALSA output settings. If you need to dump the audio produced by MOC
 312
 313 # to a file for diagnostic purposes, the following setting of ‘ALSADevice‘
 314
 315 # should do that:
 316
 317 #
 318
 319 # ALSADevice=tee:hw,‘/tmp/out.wav‘,wav
 320
 321 #
 322
 323 #ALSADevice = default
 324
 325 #ALSAMixer1 = PCM
 326
 327 ALSAMixer2 = Master
 328
 329
 330
 331 # Save software mixer state?
 332
 333 # If enabled, a file ‘softmixer‘ will be created in ‘~/.moc/‘ storing the
 334
 335 # mixersetting set when the server is shut down.
 336
 337 # Note that there is a "hidden" ‘Amplification‘ setting in that file.
 338
 339 # Amplification (0-200) is used to scale the mixer setting (0-100). This
 340
 341 # results in a higher signal amplitude but may also produce clipping.
 342
 343 Softmixer_SaveState = yes
 344
 345
 346
 347 # Save equalizer state?
 348
 349 # If enabled, a file ‘equalizer‘ will be created in ‘~/.moc/‘ storing the
 350
 351 # equalizer settings when the server is shut down.
 352
 353 # Note that there is a "hidden" ‘Mixin‘ setting in that file.
 354
 355 # Mixin (0.0-1.0) is used to determine how much of the original signal is
 356
 357 # used after equalizing. 0 means to only use the equalized sound, while 1
 358
 359 # effectively disabled the mixer. The default is 0.25.
 360
 361 #Equalizer_SaveState = yes
 362
 363
 364
 365 # Show files with dot at the beginning?
 366
 367 ShowHiddenFiles = yes
 368
 369
 370
 371 # Hide file name extensions?
 372
 373 HideFileExtension = yes
 374
 375
 376
 377 # Show file format in menu?
 378
 379 ShowFormat = no
 380
 381
 382
 383 # Show file time in menu? Possible values: ‘yes‘, ‘no‘ and ‘IfAvailable‘
 384
 385 # (meaning show the time only when it is already known, which often works
 386
 387 # faster).
 388
 389 #ShowTime = IfAvailable
 390
 391 ShowTime = yes
 392
 393
 394
 395 # Show time played as a percentage in the time progress bar.
 396
 397 ShowTimePercent = yes
 398
 399
 400
 401 # Values of the TERM environment variable which are deemed to be managed by
 402
 403 # screen(1). If you are setting a specific terminal using screen(1)‘s
 404
 405 # ‘-T <term>‘ option, then you will need to add ‘screen.<term>‘ to this list.
 406
 407 # Note that this is only a partial test; the value of the WINDOW environment
 408
 409 # variable must also be a number (which screen(1) sets).
 410
 411 #ScreenTerms = screen:screen-w:vt100
 412
 413
 414
 415 # Values of the TERM environment variable which are deemed to be xterms. If
 416
 417 # you are using MOC within screen(1) under an xterm, then add screen(1)‘s
 418
 419 # TERM setting here as well to cause MOC to update the xterm‘s title.
 420
 421 #XTerms = xterm
 422
 423 #XTerms += xterm-colour:xterm-color
 424
 425 #XTerms += xterm-256colour:xterm-256color
 426
 427 #XTerms += rxvt:rxvt-unicode
 428
 429 #XTerms += rxvt-unicode-256colour:rxvt-unicode-256color
 430
 431 #XTerms += eterm
 432
 433
 434
 435 # Theme file to use. This can be absolute path or relative to
 436
 437 # /usr/share/moc/themes/ (depends on installation prefix) or
 438
 439 # ~/.moc/themes/ .
 440
 441 #
 442
 443 # Example: Theme = laras_theme
 444
 445 #
 446
 447 Theme = user_moca_theme
 448
 449
 450
 451 # The theme used when running on an xterm.
 452
 453 #
 454
 455 # Example: XTermTheme = transparent-background
 456
 457 #
 458
 459 #XTermTheme =
 460
 461
 462
 463 # Should MOC try to autoload the default lyrics file for an audio? (The
 464
 465 # default lyrics file is a text file with the same file name as the audio
 466
 467 # file name with any trailing "extension" removed.)
 468
 469 AutoLoadLyrics = yes
 470
 471
 472
 473 # Should MOC try to autoload the lyrics for an audio from the internet?
 474
 475 # Specify an URL where to fetch lyrics from. %a marks the artist, %t the
 476
 477 # title of the song.
 478
 479 #LyricsUrl = "http://lyrics.wikia.com/wiki/%a:%t?action=raw"
 480
 481
 482
 483 # If the LyricsUrl above does not return raw lyrics, you can specifiy a
 484
 485 # regular expression to match the lyrics part within.
 486
 487 #LyricsRegex = "<lyrics>\n(.*)</lyrics>"
 488
 489
 490
 491 # Timeout in seconds for requesting lyrics. If you set this too high, the
 492
 493 # interface can become unresponive. Set to 0 to disable.
 494
 495 LyricsTimeout = 2
 496
 497
 498
 499 # If lyrics are fetched from the internet, should they be stored to disk?
 500
 501 # The lyrics are stored with the same filename as the audio file without the
 502
 503 # extension.
 504
 505 StoreLyrics = yes
 506
 507
 508
 509 # MOC directory (where pid file, socket and state files are stored).
 510
 511 # You can use ~ at the beginning.
 512
 513 #MOCDir = ~/.moc
 514
 515
 516
 517 # Use mmap() to read files. mmap() is much slower on NFS.
 518
 519 #UseMMap = no
 520
 521
 522
 523 # Use MIME to identify audio files. This can make for slower loading
 524
 525 # of playlists but is more accurate than using "extensions".
 526
 527 #UseMimeMagic = no
 528
 529
 530
 531 # Assume this encoding for ID3 version 1/1.1 tags (MP3 files). Unlike
 532
 533 # ID3v2, UTF-8 is not used here and MOC can‘t guess how tags are encoded.
 534
 535 # Another solution is using librcc (see the next option). This option is
 536
 537 # ignored if UseRCC is set to ‘yes‘.
 538
 539 ID3v1TagsEncoding = WINDOWS-1250
 540
 541
 542
 543 # Use librcc to fix ID3 version 1/1.1 tags encoding.
 544
 545 UseRCC = yes
 546
 547
 548
 549 # Use librcc to filenames and directory names encoding.
 550
 551 #UseRCCForFilesystem = yes
 552
 553
 554
 555 # When this option is set the player assumes that if the encoding of
 556
 557 # ID3v2 is set to ISO-8859-1 then the ID3v1TagsEncoding is actually
 558
 559 # that and applies appropriate conversion.
 560
 561 #EnforceTagsEncoding = no
 562
 563
 564
 565 # Enable the conversion of filenames from the local encoding to UTF-8.
 566
 567 FileNamesIconv = yes
 568
 569
 570
 571 # Enable the conversion of the xterm title from UTF-8 to the local encoding.
 572
 573 NonUTFXterm = yes
 574
 575
 576
 577 # Remember the playlist after exit?
 578
 579 SavePlaylist = yes
 580
 581
 582
 583 # When using more than one client (interface) at a time, do they share
 584
 585 # the playlist?
 586
 587 SyncPlaylist = yes
 588
 589
 590
 591 # moc键盘映射配置
 592
 593 # Choose a keymap file (relative to ‘~/.moc/‘ or using an absolute path).
 594
 595 # An annotated example keymap file is included (‘keymap.example‘).
 596
 597 ## 一个示例文件keymap.example在 $prefix/share/moc下
 598
 599 #
 600
 601 # Example: Keymap = my_keymap
 602
 603 #
 604
 605 Keymap = keymap
 606
 607
 608
 609 # Use ASCII rather than graphic characters for drawing lines. This
 610
 611 # helps on some terminals.
 612
 613 #ASCIILines = no
 614
 615
 616
 617 # FastDirs, these allow you to jump directly to a directory, the key
 618
 619 # bindings are in the keymap file.
 620
 621 #
 622
 623 # Examples: Fastdir1 = /mp3/rock
 624
 625 # Fastdir2 = /mp3/electronic
 626
 627 # Fastdir3 = /mp3/rap
 628
 629 # Fastdir4 = /mp3/etc
 630
 631
 632
 633 # PreferredDecoders allows you to specify which decoder should be used
 634
 635 # for any given audio format. It is a colon-separated list in which
 636
 637 # each entry is of the general form ‘code(decoders)‘, where ‘code‘
 638
 639 # identifies the audio format and ‘decoders‘ is a comma-separated list
 640
 641 # of decoders in order of preference.
 642
 643 #
 644
 645 # The audio format identifier may be either a filename extension or a
 646
 647 # MIME media type. If the latter, the format is ‘type/subtype‘ (e.g.,
 648
 649 # ‘audio/flac‘). Because different systems may give different MIME
 650
 651 # media types, any ‘x-‘ prefix of the subtype is ignored both here and
 652
 653 # in the actual file MIME type (so all combinations of ‘audio/flac‘ and
 654
 655 # ‘audio/x-flac‘ match each other).
 656
 657 #
 658
 659 # For Internet streams the matching is done on MIME media type and on
 660
 661 # actual content. For files the matches are made on MIME media type
 662
 663 # (if the ‘UseMimeMagic‘ option is set) and on filename extension. The
 664
 665 # MIME media type of a file is not determined until the first entry for
 666
 667 # MIME is encountered in the list.
 668
 669 #
 670
 671 # The matching is done in the order of appearance in the list with any
 672
 673 # entries added from the command line being matched before those listed
 674
 675 # here. Therefore, if you place all filename extension entries before
 676
 677 # all MIME entries you will speed up MOC‘s processing of directories
 678
 679 # (which could be significant for remote file systems).
 680
 681 #
 682
 683 # The decoder list may be empty, in which case no decoders will be used
 684
 685 # for files (and files with that audio format ignored) while Internet
 686
 687 # streams will be assessed on the actual content. Any decoder position
 688
 689 # may contain an asterisk, in which case any decoder not otherwise listed
 690
 691 # which can handle the audio format will be used. It is not an error to
 692
 693 # list the same decoder twice, but neither does it make sense to do so.
 694
 695 #
 696
 697 # If you have a mix of audio and non-audio files in your directories, you
 698
 699 # may wish to include entries at top of the list which ignore non-audio
 700
 701 # files by extension.
 702
 703 #
 704
 705 # In summary, the PreferredDecoders option provides fine control over the
 706
 707 # type of matching which is performed (filename extension, MIME media
 708
 709 # type and streamed media content) and which decoder(s) (if any) are used
 710
 711 # based on the option‘s list entries and their ordering.
 712
 713 #
 714
 715 # Examples: aac(aac,ffmpeg) first try FAAD2 for AACs then FFmpeg
 716
 717 # mp3() ignore MP3 files
 718
 719 # wav(*,sndfile) use sndfile for WAV as a last resort
 720
 721 # ogg(vorbis,*):flac(flac,*) try Xiph decoders first
 722
 723 # ogg():audio/ogg() ignore OGG files, and
 724
 725 # force Internet selection by content
 726
 727 # gz():html() ignore some non-audio files
 728
 729 #
 730
 731 # Any unspecified audio formats default to trying all decoders.
 732
 733 # Any unknown (or misspelt) drivers are ignored.
 734
 735 # All names are case insensitive.
 736
 737 # The default setting reflects the historical situation modified by
 738
 739 # the experience of users.
 740
 741 #
 742
 743 #PreferredDecoders = aac(aac,ffmpeg):m4a(ffmpeg)
 744
 745 #PreferredDecoders += mpc(musepack,*,ffmpeg):mpc8(musepack,*,ffmpeg)
 746
 747 #PreferredDecoders += sid(sidplay2):mus(sidplay2)
 748
 749 #PreferredDecoders += wav(sndfile,*,ffmpeg)
 750
 751 #PreferredDecoders += wv(wavpack,*,ffmpeg)
 752
 753 #PreferredDecoders += audio/aac(aac):audio/aacp(aac):audio/m4a(ffmpeg)
 754
 755 #PreferredDecoders += audio/wav(sndfile,*)
 756
 757
 758
 759 # The following PreferredDecoders attempt to handle the ambiguity surrounding
 760
 761 # container types such as OGG for files. The first two entries will force
 762
 763 # a local file to the correct decoder (assuming the .ogg file contains Vorbis
 764
 765 # audio), while the MIME media types will cause Internet audio streams to
 766
 767 # be assessed on content (which may be either Vorbis or Speex).
 768
 769 #
 770
 771 #PreferredDecoders += ogg(vorbis,ffmpeg):oga(vorbis,ffmpeg):ogv(ffmpeg)
 772
 773 #PreferredDecoders += opus(ffmpeg)
 774
 775 #PreferredDecoders += spx(speex)
 776
 777 #PreferredDecoders += application/ogg(vorbis):audio/ogg(vorbis)
 778
 779
 780
 781 # Which resampling method to use. There are a few methods of resampling
 782
 783 # sound supported by libresamplerate. The default is ‘Linear‘) which is
 784
 785 # also the fastest. A better description can be found at:
 786
 787 #
 788
 789 # http://www.mega-nerd.com/libsamplerate/api_misc.html#Converters
 790
 791 #
 792
 793 # but briefly, the following methods are based on bandlimited interpolation
 794
 795 # and are higher quality, but also slower:
 796
 797 #
 798
 799 # SincBestQuality - really slow (I know you probably have an xx GHz
 800
 801 # processor, but it‘s still not enough to not see
 802
 803 # this in the top output :) The worst case
 804
 805 # Signal-to-Noise Ratio is 97dB.
 806
 807 # SincMediumQuality - much faster.
 808
 809 # SincFastest - the fastest bandlimited interpolation.
 810
 811 #
 812
 813 # And these are lower quality, but much faster methods:
 814
 815 #
 816
 817 # ZeroOrderHold - really poor quality, but it‘s really fast.
 818
 819 # Linear - a bit better and a bit slower.
 820
 821 #
 822
 823 #ResampleMethod = Linear
 824
 825
 826
 827 # Always use this sample rate (in Hz) when opening the audio device (and
 828
 829 # resample the sound if necessary). When set to 0 the device is opened
 830
 831 # with the file‘s rate.
 832
 833 #ForceSampleRate = 0
 834
 835
 836
 837 # By default, even if the sound card reports that it can output 24bit samples
 838
 839 # MOC converts 24bit PCM to 16bit. Setting this option to ‘yes‘ allows MOC
 840
 841 # to use 24bit output. (The MP3 decoder, for example, uses this format.)
 842
 843 # This is disabled by default because there were reports that it prevents
 844
 845 # MP3 files from playing on some soundcards.
 846
 847 Allow24bitOutput = no
 848
 849
 850
 851 # Use realtime priority for output buffer thread. This will prevent gaps
 852
 853 # while playing even with heavy load. The user who runs MOC must have
 854
 855 # permissions to set such a priority. This could be dangerous, because it
 856
 857 # is possible that a bug in MOC will freeze your computer.
 858
 859 #UseRealtimePriority = no
 860
 861
 862
 863 # The number of audio files for which MOC will cache tags. When this limit
 864
 865 # is reached, file tags are discarded on a least recently used basis (with
 866
 867 # one second resolution). You can disable the cache by giving it a size of
 868
 869 # zero. Note that if you decrease the cache size below the number of items
 870
 871 # currently in the cache, the number will not decrease immediately (if at
 872
 873 # all).
 874
 875 #TagsCacheSize = 256
 876
 877
 878
 879 # Number items in the playlist.
 880
 881 # 显示播放列表文件编号
 882
 883 PlaylistNumbering = yes
 884
 885
 886
 887
 888
 889 # mocp播放界面布局配置
 890
 891 # Main window layouts can be configured. You can change the position and
 892
 893 # size of the menus (directory and playlist). You have three layouts and
 894
 895 # can switch between then using the ‘l‘ key (standard mapping). By default,
 896
 897 # only two layouts are configured.
 898
 899 #
 900
 901 # The format is as follows:
 902
 903 #
 904
 905 # - Each layout is described as a list of menu entries.
 906
 907 # - Each menu entry is of the form:
 908
 909 #
 910
 911 # menu(position_x, position_y, width, height)
 912
 913 #
 914
 915 # where ‘menu‘ is either ‘directory‘ or ‘playlist‘.
 916
 917 # - The parameters define position and size of the menu. They can
 918
 919 # be absolute numbers (like 10) or a percentage of the screen size
 920
 921 # (like 45%).
 922
 923 # - ‘width‘ and ‘height‘ can have also value of ‘FILL‘ which means
 924
 925 # fill the screen from the menu‘s position to the border.
 926
 927 # - Menus may overlap.
 928
 929 #
 930
 931 # You must describe at least one menu (default is to fill the whole window).
 932
 933 # There must be at least one layout (Layout1) defined; others can be empty.
 934
 935 #
 936
 937 # Example: Layout1 = playlist(50%,50%,50%,50%)
 938
 939 # Layout2 = ""
 940
 941 # Layout3 = ""
 942
 943 #
 944
 945 # Just one layout, the directory will occupy the whole
 946
 947 # screen, the playlist will have 1/4 of the screen size
 948
 949 # and be positioned at lower right corner. (Note that
 950
 951 # because the playlist will be hidden by the directory
 952
 953 # you will have to use the TAB key to make the playlist
 954
 955 # visible.)
 956
 957 #
 958
 959 # Example: Layout1 = playlist(0,0,100%,10):directory(0,10,100%,FILL)
 960
 961 #
 962
 963 # The screen is split into two parts: playlist at the top
 964
 965 # and the directory menu at the bottom. Playlist will
 966
 967 # occupy 10 lines and the directory menu the rest.
 968
 969 #
 970
 971 #Layout1 = palylist(0,0,100%,FILL)
 972
 973 Layout1 = playlist(0,0,FILL,100%)
 974
 975 #Layout2 = directory(0,0,100%,100%):playlist(0,0,100%,100%)
 976
 977 #Layout3 = ""
 978
 979
 980
 981 # When the song changes, should the menu be scrolled so that the currently
 982
 983 # played file is visible?
 984
 985 FollowPlayedFile = yes
 986
 987
 988
 989 # What to do if the interface was started and the server is already playing
 990
 991 # something from the playlist? If CanStartInPlaylist is set to ‘yes‘, the
 992
 993 # interface will switch to the playlist. When set to ‘no‘ it will start
 994
 995 # from the last directory.
 996
 997 CanStartInPlaylist = yes
 998
 999
1000
1001 # Executing external commands (1 - 10) invoked with key commands (F1 - F10
1002
1003 # by default).
1004
1005 #
1006
1007 # Some arguments are substituted before executing:
1008
1009 #
1010
1011 # %f - file path
1012
1013 # %i - title made from tags
1014
1015 # %S - start block mark (in seconds)
1016
1017 # %E - end block mark (in seconds)
1018
1019 #
1020
1021 ……..
1022
1023 # Display full paths instead of just file names in the playlist.
1024
1025 # 是否显示播放列表文件全路径
1026
1027 PlaylistFullPaths = no
1028
1029 ……….. 

Mocp Configure

2.mocp键盘映射配置

mocp键盘映射自定义,示例键盘映射可以从$prefix/share/moc/keymap.example找到

$ vim ~/.moc/keymap

menu_up            = k UP

menu_down        = j DOWN

menu_page_up            = ^b PAGE_UP

menu_page_down        = ^d PAGE_DOWN

menu_first_item        = M-b HOME

menu_last_item        = M-d END

3.mocp主题

mocp主题默认安装到$prefix/share/moc/themes目录下,可以自定义主题只对用户生效(放到~/.moc/themes目录下).

mocp启动时指定的主题或者在用户级配置文件~/.moc/config中指定的主题可以自动从$prefix/share/moc/themes和~/.moc/themes中读取.(没有就要在~/.moc/config的Theme 使用绝对路径来指定)

创建~/.moc/themes目录

$ mkdir -pv ~/.moc/themes

$ cp /usr/share/moc/themes/moca_theme ~/.moc/themes/user_moca_theme

~/.moc/themes/ user_moca_theme

 1 background        = white    default bold
 2
 3 frame            = white    default bold
 4
 5 window_title        = yellow    default    bold
 6
 7 directory        = white        default
 8
 9 selected_directory    = white        default bold
10
11 playlist        = white default
12
13 selected_playlist    = cyan        default    bold
14
15 file            = green default bold
16
17 #selected_file        = yellow    red    bold
18
19 selected_file        = white black bold
20
21 ……. 

mocp User themes

这是我的mocp最终的样子:

fbterm显示出来也是这个样子的,不过桌面歌词就没有了。

注:在fbterm中将TERM变量一直设为fbterm时会让一些基于ncursers库的命令行程序界面(比如mc和alsamixer,mocp)变得乱七八糟。而只有在将TERM变量值设置为fbterm的时候才可以让vim在fbterm上支持更多的颜色。

时间: 2024-12-24 11:25:16

Linux命令行音乐播放器moc的相关文章

命令行音乐播放器CMus

自从接触到CMus(C* Music Player)这个工作在终端里的音乐播放器后,在Linux环境里就很少使用GUI音乐播放器播放本地音乐文件了.它消耗资源少使用方便,对中文的支持也不错.CMus用C语言开发,可运行于各Unix-like平台,支持 Ogg Vorbis, FLAC, MP3, WAV, Musepack, WavPack, WMA, AAC 和 MP4 等音乐格式.使用Vim风格的快捷键进行音乐管理和播放操作,可用来管理音乐库,制作播放列表等. 主页: https://cmu

linux命令行学习-dig(DNS查询器)

在web开发中,总要熟悉的就是http协议,而发起一个http开始前最先要经历的一个过程就是DNS解析.简单说就是域名如何最终解析到实际服务器ip的过程. 而在研究DNS解析和排除DNS解析类故障问题的时候一个强大的工具就是dig.和他对应的有个比较传统的命令nslookup,不过dig作为更新的命令,其强大而简洁可定制的输出也使得运维其开发人员使用. 实例1(访问服务器本地DNSserver查询根域名服务器):  ~#: dig ; <<>> DiG 9.3.6-P1-RedHa

linux下好用的音乐播放器

本人推荐 mplayer 安装方法 sudo apt-get install mplayer 播放指令 mplayer 音乐名 关闭mplayer     pkill mplayer linux下好用的音乐播放器

仿酷狗音乐播放器开发日志二十四 选项设置窗体的实现(附328行xml布局源码)

转载请说明原出处,谢谢~~ 花了两天时间把仿酷狗的选项设置窗体做出来了,当然了只是做了外观.现在开学了,写代码的时间减少,所以整个仿酷狗的工程开发速度减慢了.今天把仿酷狗的选项设置窗体的布局代码分享出来,给学习duilib布局的朋友做个demo.现在编写的仿酷狗选项设置窗体和原酷狗的窗体不细看几乎看不出差别,控件的布局位置和原酷狗最多只有几个像素的位置差别. 先来看一下原酷狗的选项设置窗体的其中一个页面: 如果还不太会布局的朋友可以先看我前些日子写的关于duilib布局的博客<duilib各种布

Linux常用音乐播放器

1.Rhythmbox是一个音乐播放和管理应用,GNOME桌面环境自带,它可以播放各种音频格式的音乐管理收藏的音乐.同时还具有音乐回放.音乐导入.刻录音频CD.显示专辑封面.显示歌词.DAAP共享等功能. 2.Amarok是一款音乐播放器,KDE桌面环境自带,有着非常漂亮的外观和强大的播放功能,同时也有很好的中文tag支持,并且可以在播放的时候最小化到托盘. 原文地址:https://www.cnblogs.com/pipci/p/9618492.html

Ubuntu 下安装深度音乐播放器

网上搜了一个安装深度音乐的有问题. 我自己又整理一个最新的2014版的深度音乐. Linux环境:Ubuntu14.04 LTS 64bit 深度音乐都是DEB包安装. 下面,介绍如何安装深度音乐播放器. 需要python-deepin-utils.deepin-ui.gstreamer0.10-ffmpeg.python-deepin-gsettings.deepin-music-player #1,安装 python-deepin-utils 包 下载地址:下载 下载完毕,双击安装即可. #

mini2440裸机音乐播放器(很久以前的笔记)

[这是好久以前写的,有点乱,没时间整理,当做记录用的.] 图片粘贴失效,没上传图,想要的直接下载文档吧. 项目目的:通过IIS,触摸屏,LCD模块实现音乐播放器功能(按钮上一首.下一首.播放.暂停的音频控制功能,并实现播放歌曲时显示相应的歌曲图片,不播放时显示hello music图片) 项目设备:windows7(32位),mini2440,uboot(nandflash),ADS1.2开发环境,jlink v8,耳机: 功能模块LCD.触摸屏.IIS 分别介绍: Main函数中主频设置: U

STM32实现Airplay音乐播放器

AirPlay是苹果公司推出的一套无线音乐解决方案,我们手里的iPhone.iPad甚至是Apple Watch等设备还有电脑上的iTunes都支持AirPlay,但是支持AirPlay功能的音响设备都是比较贵的,荷包扁扁的我自然是感觉买那么贵的音响实在是不合算.前两天突发奇想,如果STM32可以支持AirPlay的功能,那么不就可以让我享受一把无线音乐的自由自在了吗?于是马上登陆github搜了一下,发现还真有解决方案不过基本上所有的方案都是在linux或者windows上运行的,精挑细选之后

Android实现音乐播放器(一)

Graphical User Interface 本篇文章记录了我实现Android简单音乐播放器的过程,(一)中介绍了怎么构建音乐播放器的前端页面.首先大家看一下,界面最后是这样的(界面有点粗陋) 音乐文件列表是从SD卡中读取出来的. 首先我们先在Layout里面创建Music Player的GUI,diagram如下图所示: 根据diagram我们在activity_main.xml写出如下代码: <LinearLayout xmlns:android="http://schemas.