-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartRecorder.java
More file actions
92 lines (69 loc) · 2.7 KB
/
StartRecorder.java
File metadata and controls
92 lines (69 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.io.File;
import java.util.ArrayList;
import java.util.Properties;
public class StartRecorder {
public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m";
public static final String ANSI_RESET = "\u001B[0m";
private static String fileSeparator = File.separator;
private static String m3uFile = "";
private static String destinationPath = "";
private static String url = "";
private static String m3uName = "";
private static boolean useFFMPEG = false;
private static boolean useM3UFile = false;
@SuppressWarnings("static-access")
public static void main(String[] args) {
try{
RecorderHelper rH = new RecorderHelper();
Properties prop = new Properties();
ArrayList<M3UHolder> myChannels = new ArrayList<M3UHolder>();
prop = rH.readPropertiesFile(rH.getRunningDir("config.properties") + fileSeparator + "config.properties");
destinationPath = prop.getProperty("destinationPath");
useFFMPEG = Boolean.valueOf(prop.getProperty("useFFMPEG"));
useM3UFile = Boolean.valueOf(prop.getProperty("useM3UFile"));
if (useM3UFile) {
m3uFile = prop.getProperty("m3uFile");
M3UParser m3u = new M3UParser();
myChannels = m3u.parseFile(new File(m3uFile));
}else {
M3UParser m3u = new M3UParser();
url = prop.getProperty("url");
m3uName = prop.getProperty("m3uName");
rH.getM3UFile(url,destinationPath, m3uName);
myChannels = m3u.parseFile(new File((destinationPath + fileSeparator + "NordicStream.m3u")));
}
//Visa kanaler
while(true) {
if (rH.loadChannels(myChannels, false, "")){
break;
}
}
//Hanterar starttid
rH.waitForTimeInput("\nPlease choose a starting time for the recording: \n", true);
//Hanterar sluttid
rH.waitForTimeInput("\nPlease choose a stop time for the recording: \n", false );
//Hanterar klocka och när inspelning startar
rH.startCounter();
if (useFFMPEG) {
//Startar inspelning med ffmpeg
rH.startRecFFMPEG(destinationPath);
//Hanterar klocka och när inspelningen avslutas
rH.endCounter();
//Avslutar inspelning
rH.stopRecording();
}else {
//Startar och stoppar inspelning med inputstream/outputstream
rH.startRecRegular(destinationPath);
//Visar meddelande om när inspelningen slutar
rH.endCounter();
}
//Avslutsmeddelande
rH.endMessage();
//Vänta några extra sekunder så att övriga inspelningstrådar stängs.
Thread.sleep(10000);
}catch(Exception e){
e.printStackTrace();
}
}
}