-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusic.java
108 lines (77 loc) · 2.2 KB
/
Music.java
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.lang.Runtime;
import java.lang.Process;
import java.util.List;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
public class Music {
int len;
int p_hour;
int p_min;
private ArrayList<String> arr_song;
Music(ArrayList<String> song_list,int period_hour_int,int period_min_int){
this.len=song_list.size();
this.arr_song=song_list;
this.p_hour=period_hour_int;
this.p_min=period_min_int;
}
String fr="C:\\Program Files (x86)\\Windows Media Player\\wmplayer.exe";
@SuppressWarnings("unchecked")
public void PlayMusic(int check_flag) throws Exception{
// new FrontFrame();
// System.out.println(super.period_hour_int);
long song_time=Math.round((len-1)*4.5*60*1000);
long period_time=(p_hour+(p_min/60))*3600*1000;
long check=0;
/*System.out.println(check_flag);*/
if(song_time<period_time)
check=song_time;
else
check=period_time;
arr_song.add(0,fr);
len++;
String[] arg=new String[len];
for(int i=0;i<len;i++){
arg[i]=(String)arr_song.get(i);
}
/*arg[0]="C:\\Program Files (x86)\\Windows Media Player\\wmplayer.exe";
//arg[10]="C:\\Windows\\System32\\shutdown.exe";
for(int i=1;i<10;i++){
arg[i]="N:\\Projects\\Personal\\MyMusicPlayer\\Song_Folder\\"+i+".mp3";
}*/
try{
Process proc=new ProcessBuilder(arg).start();
try{
Thread.sleep(check);
}catch(Exception ex){
ex.printStackTrace();
}
proc.destroy();
/*Runtime rt=Runtime.getRuntime();
rt.exec("taskkill /F /IM wmplayer.exe");
*/
}
catch(Exception ex){
ex.printStackTrace();
}
if(check_flag==1){
try{
Runtime runtime=Runtime.getRuntime();
Process p=runtime.exec("shutdown -s -t 0");
System.exit(0);
}catch(Exception ex){
ex.printStackTrace();
}
}
else if(check_flag==2){
try{
Runtime runtime=Runtime.getRuntime();
Process p=runtime.exec("Rundll32.exe powrprof.dll,SetSuspendState Sleep");
System.exit(0);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
}