1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
;;; emms-player-mplayer.el --- mplayer support for EMMS
;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
;; Authors: William Xu <william.xwl@gmail.com>
;; Jorgen Schaefer <forcer@forcix.cx>
;; This file is part of EMMS.
;; EMMS is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;; EMMS is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with EMMS; if not, write to the Free Software Foundation,
;; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; This provides a player that uses mplayer. It supports pause and
;; seeking.
;;; Code:
(require 'emms-compat)
(require 'emms-player-simple)
(defcustom emms-player-mplayer-subtitle-extensions
'("sub" "srt" "gb.srt" "big5.srt" "eng.srt" "chs.srt" "cht.srt")
"Possible movie subtitle file extensions."
:type 'symbol
:group 'emms)
(define-emms-simple-player mplayer '(file url)
(regexp-opt '(".ogg" ".mp3" ".wav" ".mpg" ".mpeg" ".wmv" ".wma"
".mov" ".avi" ".divx" ".ogm" ".asf" ".mkv" "http://" "mms://"
".rm" ".rmvb" ".mp4" ".flac" ".vob" ".m4a" ".ape"))
"mplayer" "-slave" "-quiet" "-really-quiet")
(define-emms-simple-player mplayer-playlist '(streamlist)
"http://"
"mplayer" "-slave" "-quiet" "-really-quiet" "-playlist")
(emms-player-set emms-player-mplayer
'pause
'emms-player-mplayer-pause)
;;; Pause is also resume for mplayer
(emms-player-set emms-player-mplayer
'resume
nil)
(emms-player-set emms-player-mplayer
'seek
'emms-player-mplayer-seek)
(emms-player-set emms-player-mplayer
'seek-to
'emms-player-mplayer-seek-to)
(defun emms-player-mplayer-pause ()
"Depends on mplayer's -slave mode."
(process-send-string
emms-player-simple-process-name "pause\n"))
(defun emms-player-mplayer-seek (sec)
"Depends on mplayer's -slave mode."
(process-send-string
emms-player-simple-process-name
(format "seek %d\n" sec)))
(defun emms-player-mplayer-seek-to (sec)
"Depends on mplayer's -slave mode."
(process-send-string
emms-player-simple-process-name
(format "seek %d 2\n" sec)))
(defun emms-player-mplayer-subtitle-checker ()
(let* ((track (emms-playlist-current-selected-track))
(name (emms-track-name track))
(ext (file-name-extension name))
(choices
(emms-remove-if-not (lambda (i)
(and (eq (emms-track-type track) 'file)
(file-exists-p i)))
(mapcar (lambda (el)
(emms-replace-regexp-in-string
(concat ext "$") el name))
emms-player-mplayer-subtitle-extensions)))
(subtitle (mapconcat (lambda (el) el) choices ",")))
(unless (string= subtitle "")
(setq emms-player-mplayer-parameters
(append emms-player-mplayer-parameters
(list "-sub" subtitle))))))
(defun emms-player-mplayer-start-with-subtitle-checker (track)
"Start the player process by checking possible subtitles
additionally."
(let ((emms-player-mplayer-parameters emms-player-mplayer-parameters))
(emms-player-mplayer-subtitle-checker)
(emms-player-simple-start (emms-track-name track)
emms-player-mplayer
emms-player-mplayer-command-name
emms-player-mplayer-parameters)))
;; I have to redefine `emms-player-mplayer-start', since i can't figure
;; out an easy way to achieve this based on current design. (xwl)
(defalias 'emms-player-mplayer-start
'emms-player-mplayer-start-with-subtitle-checker)
(provide 'emms-player-mplayer)
;;; emms-player-mplayer.el ends here
|