Search in sources :

Example 6 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class View method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    int num = 0;
    FileSource source = null;
    if (args.length == 0) {
        Integer lastView = project.getProperty(Properties.VIEW_LAST_MEDIA);
        if (lastView == null) {
            getPrinter().println("Last view undefined");
            return;
        }
        source = project.getSource(lastView);
        getPrinter().println("Last view n°" + lastView + ": " + source.getFile().getName());
        num = lastView.intValue();
    } else if (args.length > 1) {
        println(getSyntax());
        return;
    } else {
        num = NumberUtils.toInt(args[0], -1);
        source = project.getSource(num);
        if (source == null) {
            println("Media number not found: " + num);
            return;
        }
    }
    open(source);
    project.setProperty(Properties.VIEW_LAST_MEDIA, num);
}
Also used : FileSource(org.fagu.fmv.core.project.FileSource)

Aggregations

FileSource (org.fagu.fmv.core.project.FileSource)6 File (java.io.File)1 Predicate (java.util.function.Predicate)1 CommandLine (org.apache.commons.cli.CommandLine)1 Options (org.apache.commons.cli.Options)1 ConsoleOutput (org.fagu.fmv.cli.ConsoleOutput)1 Alias (org.fagu.fmv.cli.annotation.Alias)1 Aliases (org.fagu.fmv.cli.annotation.Aliases)1 Command (org.fagu.fmv.cli.annotation.Command)1 FileType (org.fagu.fmv.media.FileType)1