CLI: Added repeat command, updated online help.

This commit is contained in:
Jonathan Bernard 2016-04-04 06:12:23 -05:00
parent ed31078d4c
commit 2ec81b34ea

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory
import uk.co.caprica.vlcj.discovery.NativeDiscovery
import uk.co.caprica.vlcj.component.AudioMediaListPlayerComponent
import uk.co.caprica.vlcj.player.MediaPlayerEventListener
import uk.co.caprica.vlcj.player.list.MediaListPlayerMode
import static com.jdbernard.util.AnsiEscapeCodeSequence.*
import static com.jdbernard.wdiwtlt.MediaLibrary.*
@ -95,7 +96,7 @@ Configuration:
/// Console output data
private String titleStyle, normalStyle, statusStyle, promptStyle,
artistStyle, albumStyle, fileStyle, errorStyle, playlistStyle,
cmdStyle
cmdStyle, optStyle
private String clearLine = new ANSI().eraseLine(Erase.All).toString()
private String afterInput =
@ -334,6 +335,7 @@ Configuration:
normalStyle = new ANSI().resetText().toString()
promptStyle = new ANSI().color(Colors.YELLOW, Colors.DEFAULT, true).toString()
cmdStyle = new ANSI().color(Colors.YELLOW, Colors.DEFAULT, true).toString()
optStyle = new ANSI().color(Colors.GREEN, Colors.DEFAULT, true).toString()
statusStyle = new ANSI().color(Colors.CYAN, Colors.DEFAULT, false).toString()
playlistStyle = new ANSI().color(Colors.GREEN, Colors.DEFAULT, false).toString()
artistStyle = new ANSI().color(Colors.RED, Colors.DEFAULT, false).toString()
@ -421,6 +423,7 @@ Configuration:
case 'fastforward': return processFastForward(rest)
case 'rw': case 'rwd':
case 'rewind': return processRewind(rest)
case 'repeat': return processRepeat(rest)
case 'vol':
case 'volume': return processVolume(rest)
case 'help': return printLongMessage(processHelp(rest))
@ -577,7 +580,7 @@ Configuration:
msg "New bookmark: ${b.id}: ${b.name}"
return b
case ~/playlist named (.+) from (queue|selection)/:
case ~/playlist named (.+) from (queue|selection|.+)/:
Playlist p
if (Matcher.lastMatcher[0][2] == 'queue') {
p = playQueue.clone()
@ -587,6 +590,10 @@ Configuration:
else {
p = new Playlist(name: Matcher.lastMatcher[0][1])
p = library.save(p)
if (Matcher.lastMatcher[0][2] != 'selection')
selection = select(Matcher.lastMatcher[0][2], selection)
library.addToPlaylist(p.id,
library.collectMediaFiles(selection).collect { it.id }) }
@ -599,7 +606,9 @@ Configuration:
p = library.save(p)
msg "New playlist: ${p.id}: ${p.name}"
return p } }
return p
default: invalidOptionsErr('create') } }
private Playlist processPlay(String options, List<Model> selection) {
@ -878,6 +887,19 @@ Configuration:
"(or 'millis' or 'ms'), 'seconds' (or 'sec' or 's'), or " +
"'minutes' (or 'min' or 'm')" } }
private def processRepeat(String option) {
switch(option) {
case 'off':
vlcj.mediaListPlayer.mode = MediaListPlayerMode.DEFAULT
break
case 'all':
vlcj.mediaListPlayer.mode = MediaListPlayerMode.REPEAT
break
case 'one':
vlcj.mediaListPlayer.mode = MediaListPlayerMode.LOOP
break
default: invalidOptionsErr('repeat') } }
private def processVolume(String rest) {
int percentage
@ -1017,6 +1039,28 @@ ${cmdStyle}queue${normalStyle}
Select the current play queue
"""
// CREATE
// --------------
case 'create': return """\
${cmdStyle}create bookmark named <name>${normalStyle}
Create a new bookmark at the current play position in the currently playing
playlist.
${cmdStyle}create bookmark named <name> on playlist <playlist-name | id> at <file-name | id>${normalStyle}
Create a bookmark on the named media file in the named playlist.
${cmdStyle}create playlist named <name>${normalStyle}
Create a new playlist.
${cmdStyle}create playlist named <name> from { queue | selection}${normalStyle}
Create a new playlist and populate it with the contents of either the
current play queue or the current selection.
"""
// PLAY
@ -1211,6 +1255,15 @@ rw <amount> <unit>
'seconds', or 'minutes'. The following abbreviations are allowed: 'ms',
'millis', 's', 'sec', 'm', 'min'.
"""
case 'repeat': return """\
repeat { all | one | none }
Set the playlist repeat mode to:
all: repeat the entire play queue
one: loop the currently playing song
none: do not repeat.
"""
case 'vol': case 'volume': return """\
@ -1248,6 +1301,7 @@ Play and Controlling Media:
next <count> (alias: n)
prev <count> (alias: p)
repeat { all | one | off }
stop
pause
fasforward <duration> <time-unit> (aliases: ff, fwd)
@ -1267,7 +1321,9 @@ Playlist and Queue Management:
remove selection from queue
remove <selection-criteria> from queue
create playlist named <name> from selection <id | name>
create bookmark named <name>
create bookmark named <name> on playlist <playlist name | id> at <file name | id>
create playlist named <name> from { selection | queue }
create playlist named <name from <selection-criteria>
copy playlist <id | name> as <new name>
create bookmark <id | name>