Package org.livesub.input

Examples of org.livesub.input.Caption


    }
   
    @Override
    public void run() {
        try {
            Caption current = currentCaption.getElement();

            playTime++;

            if(playTime > subtitleList.getLast().getElement().getDisappear()) {
                stop();
            } else if (playTime >= current.getAppear() && playTime <= current.getDisappear()) {
                setText(current.getContents());
            } else if(playTime > current.getDisappear()) {
                currentCaption = currentCaption.getNext();
                setText(null);
            }
        } catch(Exception e) {
            LOG.error("SubtitleTask Error!", e);
View Full Code Here


            line = br.readLine();
        } catch (IOException ex) {
            Logger.getLogger(SrtParser.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        Caption caption = null;
        int lineNumber = 0;
               
        while(line != null){
            if (line.matches("[0-9]+:[0-9]+:[0-9]+,[0-9]+\\s-->\\s[0-9]+:[0-9]+:[0-9]+,[0-9]+")) {
                long startTime = Utils.dateParseRegExp(line.split("\\s-->\\s")[0]);
                long endTime = Utils.dateParseRegExp(line.split("\\s-->\\s")[1]);
                caption = new Caption(startTime, endTime);
                caption.setNumericCounter(lineNumber);
            } else if (line.matches("[0-9]+") && caption == null) {
                lineNumber = Integer.parseInt(line);
            } else if (line.matches(".+")) {
                if (caption != null) {
                    caption.setContents(line);
                }
            } else {
                if (caption != null) {
                    subs.put(caption, caption.getNumericCounter());
                    caption = null;
                }
            }
            try {
                line = br.readLine();
            } catch (IOException ex) {
                Logger.getLogger(SrtParser.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
       
        if (caption != null) {
            subs.put(caption, caption.getNumericCounter());
        }
       
        return subs;
    }
View Full Code Here

            Matcher matcher = pattern.matcher(line);
            if (matcher.matches()) {
                long startAt = (long) ((Long.parseLong(matcher.group(1)) / Utils.fps) * 1000);
                long endAt = (long) ((Long.parseLong(matcher.group(2)) / Utils.fps) * 1000);
                String text = matcher.group(4);
                Caption caption = new Caption(startAt, endAt);
                caption.setContents(text);
                caption.setNumericCounter(lineNumber);
                subs.put(caption, caption.getNumericCounter());
            }
            lineNumber++;
            try {
                line = br.readLine();
            } catch (IOException ex) {
View Full Code Here

TOP

Related Classes of org.livesub.input.Caption

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.