From 2ec81b34ea1bda3748f1d64ba18657736106397d Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 4 Apr 2016 06:12:23 -0500 Subject: [PATCH] CLI: Added repeat command, updated online help. --- .../wdiwtlt/cli/CommandLineInterface.groovy | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy index 1a6ccbf..7c547f2 100644 --- a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy +++ b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy @@ -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 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 ${normalStyle} + + Create a new bookmark at the current play position in the currently playing + playlist. + +${cmdStyle}create bookmark named on playlist at ${normalStyle} + + Create a bookmark on the named media file in the named playlist. + +${cmdStyle}create playlist named ${normalStyle} + + Create a new playlist. + +${cmdStyle}create playlist named 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 '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 (alias: n) prev (alias: p) + repeat { all | one | off } stop pause fasforward (aliases: ff, fwd) @@ -1267,7 +1321,9 @@ Playlist and Queue Management: remove selection from queue remove from queue - create playlist named from selection + create bookmark named + create bookmark named on playlist at + create playlist named from { selection | queue } create playlist named copy playlist as create bookmark