![]() |
2008-04-14
, 00:50
|
Posts: 118 |
Thanked: 16 times |
Joined on Sep 2007
|
#1
|
![]() |
2008-04-14
, 01:04
|
Posts: 112 |
Thanked: 28 times |
Joined on Mar 2008
@ Victoria, BC
|
#2
|
![]() |
2008-04-14
, 07:13
|
|
Posts: 48 |
Thanked: 40 times |
Joined on Apr 2008
@ Spain
|
#3
|
![]() |
2008-04-14
, 13:05
|
Posts: 118 |
Thanked: 16 times |
Joined on Sep 2007
|
#4
|
Mplayer could be a candidate. It can play a wide range of audio formats, and in the latest version it is able to resume the last file played.
However, in order to be a good audiobook player some changes are needed:
- The GUI only shows videos. It does not show audio files (although it can play them if they are selected through the "Open" button)
- The resume capability is only present in the GUI (as far as I know), so it is limited to video files.
- The resume capability only remembers the resume point of the last file player. It would be very useful if it could remember a resume point for *each* file played. I don't think this is a technical limitation. The resume point is stored in the file ~/.mplayer/video.position and currenty only contains one line. It would be possible to include several lines here, one per file played.
- It does not provide bookmarking, but perhaps it would be not difficult to add it using the same mechanism than the one used for resuming.
However, it is also possible to use mplayer from command line, to play an audio file. The command-line version allows for the option -ss to start playing at any specified offset in the file (specified as seconds, or as HH:MM:SS). This would allow for a python script which manages the bookmarks and calls mplayer with the appropiate -ss options. Mplayer is continuosly printing the playing position in the standard output, so the python script could parse this information, in order to store the time offset at which mplayer is stopped, and save it as a resume point (to be used with option -ss in the next play).
![]() |
2008-04-14
, 14:05
|
Posts: 112 |
Thanked: 28 times |
Joined on Mar 2008
@ Victoria, BC
|
#5
|
![]() |
2008-04-14
, 15:45
|
|
Posts: 4,930 |
Thanked: 2,272 times |
Joined on Oct 2007
|
#6
|
The Following User Says Thank You to Benson For This Useful Post: | ||
![]() |
2008-04-14
, 16:42
|
|
Posts: 48 |
Thanked: 40 times |
Joined on Apr 2008
@ Spain
|
#7
|
Why does everyone want to do everything with Python?
Shell scripts, awk, etc. are more than sufficient for this task.
#!/bin/sh if test -f "$1".resume then resumepoint=`cat "$1".resume` else resumepoint=0 fi mplayer -ss $resumepoint "$1"|awk 'BEGIN{RS="\r"}{if ($1=="A:") t=$2}END{print t}' > "$1".resume
$ abplayer /route/to/audiobook.mp3
What format are your audiobooks? mpg123 might seem a more natural choice than mplayer, if they're mp3; otherwise mplayer might be better.
![]() |
2008-04-14
, 18:09
|
Posts: 118 |
Thanked: 16 times |
Joined on Sep 2007
|
#8
|
You are right. Using python for everything is a tic. I accomplished this task with a simple shell script and a little of awk. Here is how:
Copy the following code to a file named, for example abplayer (from "audiobook player), or wathever you like:
Put this file in a place where your shell can find it (I have a "bin" folder in my $HOME, and a line in the .profile for adding this folder to the PATH variable). Make executable this file (chmod +x abplayer).Code:#!/bin/sh if test -f "$1".resume then resumepoint=`cat "$1".resume` else resumepoint=0 fi mplayer -ss $resumepoint "$1"|awk 'BEGIN{RS="\r"}{if ($1=="A:") t=$2}END{print t}' > "$1".resume
Then, use it from the command line (xterm) like this:
The audio begins to play. When you press 'q', the player is exited, and a new file is created, with name /route/to/audiobook.mp3.resume which contains the time in which the playback was quitted. Next time you use abeplay, it will search for this file. If it founds it, the playback is resumed from that point. If not, it is restarted again from the beginning.Code:$ abplayer /route/to/audiobook.mp3
If the player exits unexpectedly and the .resume file is corrupt, you have to delete it (or you can write a correct one with any editor, it only contains the time where the playback has to be resumed, in the format hh:mm:ss.ff, being ff any fraction of second, for example: 3:21.52)
I used mplayer because I have it already installed, and supports a wide range of formats. As for mpg123, I did not find it with apt-cache...
![]() |
2008-04-14
, 18:21
|
Posts: 118 |
Thanked: 16 times |
Joined on Sep 2007
|
#10
|
The Following User Says Thank You to MstPrgmr For This Useful Post: | ||