Révision 3206
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/player/MediaPlayerComposite.java (revision 3206) | ||
---|---|---|
1 |
package org.txm.backtomedia.editors.player; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.eclipse.swt.SWT; |
|
6 |
import org.eclipse.swt.events.SelectionEvent; |
|
7 |
import org.eclipse.swt.events.SelectionListener; |
|
8 |
import org.eclipse.swt.layout.GridData; |
|
9 |
import org.eclipse.swt.widgets.Button; |
|
10 |
import org.eclipse.swt.widgets.Composite; |
|
11 |
import org.eclipse.swt.widgets.FileDialog; |
|
12 |
import org.eclipse.swt.widgets.Label; |
|
13 |
import org.eclipse.swt.widgets.Scale; |
|
14 |
import org.txm.backtomedia.commands.function.TripleRangeSlider; |
|
15 |
import org.txm.backtomedia.preferences.BackToMediaPreferences; |
|
16 |
import org.txm.utils.logger.Log; |
|
17 |
|
|
18 |
import javafx.util.Duration; |
|
19 |
import vlcplayerrcp.MessagesMP; |
|
20 |
|
|
21 |
public class MediaPlayerComposite extends Composite { |
|
22 |
|
|
23 |
IPlayer player; |
|
24 |
private Scale rateField; |
|
25 |
private Label rateValueLabel; |
|
26 |
private Scale volumeField; |
|
27 |
private Label volumeValueLabel; |
|
28 |
private Button playButton; |
|
29 |
private Button stopButton; |
|
30 |
private Button repeatButton; |
|
31 |
Label timeLabel; |
|
32 |
TripleRangeSlider timeRange; |
|
33 |
|
|
34 |
protected boolean userStopped; |
|
35 |
protected String currentlyPlayed = ""; //$NON-NLS-1$ |
|
36 |
protected int start, end; |
|
37 |
protected boolean hasEnded = false; |
|
38 |
protected String previouslyPlayed = ""; //$NON-NLS-1$ |
|
39 |
protected boolean repeat = false; |
|
40 |
protected int volume = 100; |
|
41 |
protected int time; |
|
42 |
private int mins; |
|
43 |
private int secs; |
|
44 |
|
|
45 |
public MediaPlayerComposite(Composite parent, int style) { |
|
46 |
|
|
47 |
super(parent, style); |
|
48 |
|
|
49 |
if ("HTML".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
50 |
player = new HTMLPlayer(parent, SWT.NONE); |
|
51 |
// } else if ("JFX".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
52 |
// player = new JFXPlayer(parent, SWT.NONE); |
|
53 |
} |
|
54 |
else if ("VLC".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
55 |
player = new VLCPlayer(parent, SWT.NONE); |
|
56 |
} |
|
57 |
else { |
|
58 |
player = new HTMLPlayer(parent, SWT.NONE); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
// THE CONTROL BUTTONS |
|
63 |
playButton = new Button(this, SWT.PUSH); |
|
64 |
GridData playLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false); |
|
65 |
playButton.setLayoutData(playLayoutData); |
|
66 |
playButton.setText(MessagesMP.play); |
|
67 |
playButton.addSelectionListener(new SelectionListener() { |
|
68 |
|
|
69 |
@Override |
|
70 |
public void widgetSelected(SelectionEvent e) { |
|
71 |
userStopped = false; |
|
72 |
if (currentlyPlayed.length() == 0) { |
|
73 |
selectMedia(); |
|
74 |
playButton.setText(MessagesMP.pause); |
|
75 |
playButton.getParent().layout(); |
|
76 |
} |
|
77 |
else if (player != null && player.isPlaying()) { |
|
78 |
player.pause(); |
|
79 |
} |
|
80 |
else if (player != null && hasEnded) { |
|
81 |
if (player == null) return; |
|
82 |
player.replay(); |
|
83 |
} |
|
84 |
else { |
|
85 |
player.resume(); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
91 |
}); |
|
92 |
|
|
93 |
// Button browseButton = new Button(this,SWT.PUSH); |
|
94 |
// browseButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); |
|
95 |
// browseButton.setText("Open..."); |
|
96 |
// browseButton.addSelectionListener(new SelectionListener() { |
|
97 |
// @Override |
|
98 |
// public void widgetSelected(SelectionEvent e) { |
|
99 |
// selectMedia(); |
|
100 |
// } |
|
101 |
// |
|
102 |
// @Override |
|
103 |
// public void widgetDefaultSelected(SelectionEvent e) {} |
|
104 |
// }); |
|
105 |
|
|
106 |
stopButton = new Button(this, SWT.PUSH); |
|
107 |
stopButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
108 |
stopButton.setText(MessagesMP.stop); |
|
109 |
stopButton.addSelectionListener(new SelectionListener() { |
|
110 |
|
|
111 |
@Override |
|
112 |
public void widgetSelected(SelectionEvent e) { |
|
113 |
if (player != null) { |
|
114 |
userStopped = true; |
|
115 |
player.stop(); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
121 |
}); |
|
122 |
|
|
123 |
timeLabel = new Label(this, SWT.NONE); |
|
124 |
timeLabel.setText("00:00"); //$NON-NLS-1$ |
|
125 |
|
|
126 |
timeRange = new TripleRangeSlider(this, SWT.None); |
|
127 |
timeRange.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
|
128 |
timeRange.setToolTipText(MessagesMP.time_range); |
|
129 |
timeRange.addSelectionListener(new SelectionListener() { |
|
130 |
|
|
131 |
@Override |
|
132 |
public void widgetSelected(SelectionEvent e) { |
|
133 |
TripleRangeSlider.SELECTED_KNOB sk = timeRange.getLastSelectedKnob(); |
|
134 |
switch (sk) { |
|
135 |
case UPPER: |
|
136 |
end = timeRange.getUpperValue(); |
|
137 |
|
|
138 |
player.setStopTime(end); //Duration.seconds(end)); |
|
139 |
if (end < time) { |
|
140 |
// System.out.println("Upper changed: fix time"); |
|
141 |
time = end; |
|
142 |
player.seek(time);//Duration.seconds(time)); |
|
143 |
} |
|
144 |
break; |
|
145 |
case LOWER: |
|
146 |
start = timeRange.getLowerValue(); |
|
147 |
player.setStartTime(start);//Duration.seconds(start)); |
|
148 |
if (start > time) { |
|
149 |
// System.out.println("Lower changed: fix time"); |
|
150 |
time = start; |
|
151 |
player.seek(time);//Duration.seconds(time)); |
|
152 |
} |
|
153 |
break; |
|
154 |
case MIDDLE: |
|
155 |
|
|
156 |
time = timeRange.getMiddleValue(); |
|
157 |
// System.out.println("Middle changed: fix time: " + time); |
|
158 |
|
|
159 |
player.seek(time);//Duration.seconds(time)); |
|
160 |
|
|
161 |
break; |
|
162 |
default: |
|
163 |
// nothing |
|
164 |
} |
|
165 |
// System.out.println("time range: "+start+" -> "+end+" time="+time); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
170 |
}); |
|
171 |
|
|
172 |
repeatButton = new Button(this, SWT.CHECK); |
|
173 |
repeatButton.setText(MessagesMP.repeat); |
|
174 |
repeat = BackToMediaPreferences.getInstance().getBoolean(BackToMediaPreferences.REPEAT); |
|
175 |
repeatButton.setSelection(repeat); |
|
176 |
repeatButton.addSelectionListener(new SelectionListener() { |
|
177 |
|
|
178 |
@Override |
|
179 |
public void widgetSelected(SelectionEvent e) { |
|
180 |
repeat = repeatButton.getSelection(); |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
185 |
}); |
|
186 |
|
|
187 |
Label l = new Label(this, SWT.NONE); |
|
188 |
l.setText(MessagesMP.rate); |
|
189 |
|
|
190 |
rateField = new Scale(this, SWT.BORDER); |
|
191 |
GridData gdata4 = new GridData(SWT.FILL, SWT.CENTER, false, false); |
|
192 |
gdata4.widthHint = 100; |
|
193 |
rateField.setLayoutData(gdata4); |
|
194 |
rateField.setMaximum(140); |
|
195 |
rateField.setMinimum(70); |
|
196 |
rateField.setSelection(100); |
|
197 |
rateField.setPageIncrement(5); |
|
198 |
|
|
199 |
rateField.addSelectionListener(new SelectionListener() { |
|
200 |
|
|
201 |
@Override |
|
202 |
public void widgetSelected(SelectionEvent e) { |
|
203 |
float rate = rateField.getSelection() / 100.0f; |
|
204 |
player.setRate(rate); |
|
205 |
rateValueLabel.setText("" + rateField.getSelection() + "%"); |
|
206 |
} |
|
207 |
|
|
208 |
@Override |
|
209 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
210 |
}); |
|
211 |
|
|
212 |
rateValueLabel = new Label(this, SWT.NONE); |
|
213 |
rateValueLabel.setText("100%");//$NON-NLS-1$ |
|
214 |
|
|
215 |
l = new Label(this, SWT.NONE); |
|
216 |
l.setText(MessagesMP.volume); |
|
217 |
|
|
218 |
volumeField = new Scale(this, SWT.BORDER); |
|
219 |
gdata4 = new GridData(SWT.FILL, SWT.CENTER, false, false); |
|
220 |
gdata4.widthHint = 100; |
|
221 |
volumeField.setLayoutData(gdata4); |
|
222 |
volumeField.setMinimum(0); |
|
223 |
volumeField.setMaximum(100); |
|
224 |
volumeField.setSelection(volume); |
|
225 |
volumeField.setPageIncrement(5); |
|
226 |
volumeField.addSelectionListener(new SelectionListener() { |
|
227 |
|
|
228 |
@Override |
|
229 |
public void widgetSelected(SelectionEvent e) { |
|
230 |
player.setVolume(volumeField.getSelection()); |
|
231 |
volume = volumeField.getSelection(); |
|
232 |
volumeValueLabel.setText("" + volume + "%"); |
|
233 |
} |
|
234 |
|
|
235 |
@Override |
|
236 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
237 |
}); |
|
238 |
|
|
239 |
volumeValueLabel = new Label(this, SWT.NONE); |
|
240 |
volumeValueLabel.setText("100%"); |
|
241 |
|
|
242 |
|
|
243 |
} |
|
244 |
|
|
245 |
public void hideStopButton() { |
|
246 |
if (this.stopButton != null && !this.stopButton.isDisposed()) { |
|
247 |
this.stopButton.dispose(); |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
public void resume() { |
|
252 |
if (player != null) { |
|
253 |
//player.play(); |
|
254 |
playButton.setText(MessagesMP.pause); |
|
255 |
playButton.getParent().layout(); |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
public void pause() { |
|
260 |
if (player != null) { |
|
261 |
player.pause(); |
|
262 |
playButton.setText(MessagesMP.resume); |
|
263 |
playButton.getParent().layout(); |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
private void updateTimeLabel() { |
|
268 |
mins = time / 60; |
|
269 |
secs = (time) % 60; |
|
270 |
timeLabel.setText(String.format("%02d:%02d", mins, secs)); //$NON-NLS-1$ |
|
271 |
timeLabel.update(); |
|
272 |
} |
|
273 |
|
|
274 |
public void replay() { |
|
275 |
if (currentlyPlayed.length() > 0) { |
|
276 |
//player.seek(Duration.seconds(start)); |
|
277 |
playButton.setText(MessagesMP.pause); |
|
278 |
playButton.getParent().layout(); |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
protected void selectMedia() { |
|
283 |
Log.fine(MessagesMP.select_file); |
|
284 |
|
|
285 |
FileDialog fd = new FileDialog(MediaPlayerComposite.this.getShell(), SWT.OPEN); |
|
286 |
fd.setText(MessagesMP.select_file_title); |
|
287 |
File f = new File(previouslyPlayed); |
|
288 |
if (f.isDirectory()) fd.setFilterPath(f.getPath()); |
|
289 |
else fd.setFilterPath(f.getParent()); |
|
290 |
|
|
291 |
String[] filterExt = { "*.*", "*.mp3", "*.mp4", "*.avi", "*.ogg", "*.ogv" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
292 |
fd.setFilterExtensions(filterExt); |
|
293 |
String selected = fd.open(); |
|
294 |
if (selected == null) { |
|
295 |
System.out.println(MessagesMP.cancel); |
|
296 |
return; |
|
297 |
} |
|
298 |
|
|
299 |
currentlyPlayed = selected; |
|
300 |
previouslyPlayed = selected; |
|
301 |
Log.fine(MessagesMP.opening + currentlyPlayed); |
|
302 |
player.play(new File(currentlyPlayed).toURI().toString(), 0, 0); |
|
303 |
} |
|
304 |
|
|
305 |
} |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/player/HTMLPlayer.java (revision 3206) | ||
---|---|---|
6 | 6 |
|
7 | 7 |
import org.eclipse.swt.SWT; |
8 | 8 |
import org.eclipse.swt.browser.Browser; |
9 |
import org.eclipse.swt.browser.ProgressEvent; |
|
10 |
import org.eclipse.swt.browser.ProgressListener; |
|
9 | 11 |
import org.eclipse.swt.events.SelectionEvent; |
10 | 12 |
import org.eclipse.swt.events.SelectionListener; |
11 | 13 |
import org.eclipse.swt.layout.GridData; |
12 | 14 |
import org.eclipse.swt.layout.GridLayout; |
13 | 15 |
import org.eclipse.swt.widgets.Button; |
14 | 16 |
import org.eclipse.swt.widgets.Composite; |
17 |
import org.eclipse.swt.widgets.Label; |
|
15 | 18 |
import org.eclipse.swt.widgets.Scale; |
16 | 19 |
import org.txm.backtomedia.commands.function.OpenMediaPlayer; |
17 | 20 |
import org.txm.backtomedia.commands.function.SimpleFileDialog; |
... | ... | |
19 | 22 |
import org.txm.rcp.swt.GLComposite; |
20 | 23 |
|
21 | 24 |
public class HTMLPlayer extends Composite implements IPlayer { |
22 |
|
|
25 |
|
|
23 | 26 |
Browser browser; |
24 | 27 |
String mrl = null; |
25 | 28 |
private String login; |
26 | 29 |
private String mdp; |
27 | 30 |
private Button stopButton; |
28 | 31 |
|
29 |
public HTMLPlayer(Composite parent, int style) { |
|
32 |
String initMrl; |
|
33 |
int initStartTime = 0; |
|
34 |
int initEndTime = -1; |
|
35 |
String initStringStartTime = null; |
|
36 |
String initStringEndTime = null; |
|
37 |
boolean initRepeat = false; |
|
38 |
private Label volumeLabel; |
|
39 |
private Label rateLabel; |
|
40 |
|
|
41 |
public HTMLPlayer(Composite parent, int style, boolean lightweight) { |
|
30 | 42 |
|
31 | 43 |
super(parent, style); |
32 | 44 |
|
33 | 45 |
this.setLayout(new GridLayout(1, true)); |
34 | 46 |
|
35 |
GLComposite controls = new GLComposite(this, SWT.BORDER, "controls"); |
|
36 |
controls.getLayout().numColumns = 20; |
|
47 |
browser = new Browser(this, SWT.NONE); |
|
48 |
browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
49 |
browser.setText("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></head><body><video id=\"video\" width=\"100%\" height=\"100%\" controls></video></body></html>"); |
|
50 |
//browser.setText("<video id=\"video\" width=\"100%\" height=\"100%\" controls><source id=\"source\" src=\"\"></source></video>"); |
|
37 | 51 |
|
38 |
Button openButton = new Button(controls, SWT.PUSH); |
|
39 |
openButton.setText("Open..."); |
|
40 |
openButton.addSelectionListener(new SelectionListener() { |
|
52 |
browser.addProgressListener(new ProgressListener() { |
|
41 | 53 |
|
42 | 54 |
@Override |
43 |
public void widgetSelected(SelectionEvent event) { |
|
44 |
|
|
45 |
SimpleFileDialog fd = new SimpleFileDialog(HTMLPlayer.this.getDisplay().getActiveShell(), "Opening media file...", "Enter file path or URL", BackToMediaPreferences.getInstance().getString(OpenMediaPlayer.ID), null); |
|
46 |
if (fd.open() == SimpleFileDialog.OK) { |
|
47 |
String mrl = fd.getValue(); |
|
48 |
|
|
49 |
if (mrl != null) { |
|
50 |
File f = new File(mrl); |
|
51 |
if (f.exists()) { |
|
52 |
mrl = new File(mrl).toURI().toString(); |
|
53 |
} |
|
54 |
else { |
|
55 |
|
|
56 |
} |
|
57 |
BackToMediaPreferences.getInstance().put(OpenMediaPlayer.ID, mrl); |
|
58 |
play(mrl, 0); |
|
55 |
public void completed(ProgressEvent event) { |
|
56 |
//System.out.println("LOADED"); |
|
57 |
HTMLPlayer.this.loaded = true; |
|
58 |
if (initMrl != null) { |
|
59 |
if (initStringStartTime != null) { |
|
60 |
HTMLPlayer.this.play(initMrl, initStringStartTime, initStringEndTime); |
|
61 |
} else { |
|
62 |
HTMLPlayer.this.play(initMrl, initStartTime, initEndTime); |
|
59 | 63 |
} |
60 | 64 |
} |
65 |
setRepeat(initRepeat); |
|
61 | 66 |
} |
62 | 67 |
|
63 | 68 |
@Override |
64 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
69 |
public void changed(ProgressEvent event) { }
|
|
65 | 70 |
}); |
66 |
|
|
67 |
stopButton = new Button(controls, SWT.PUSH); |
|
68 |
stopButton.setText("Stop"); |
|
69 |
stopButton.addSelectionListener(new SelectionListener() { |
|
70 |
|
|
71 |
@Override |
|
72 |
public void widgetSelected(SelectionEvent event) { |
|
73 |
stop(); |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
78 |
}); |
|
79 | 71 |
|
80 |
Button playpauseButton = new Button(controls, SWT.TOGGLE); |
|
81 |
playpauseButton.setText("Pause"); |
|
82 |
playpauseButton.setSelection(true); |
|
83 |
playpauseButton.addSelectionListener(new SelectionListener() { |
|
72 |
GLComposite controls = new GLComposite(this, SWT.NONE, "controls"); |
|
73 |
controls.getLayout().numColumns = 20; |
|
74 |
controls.getLayout().horizontalSpacing = 2; |
|
75 |
|
|
76 |
if (!lightweight) { |
|
77 |
Button openButton = new Button(controls, SWT.PUSH); |
|
78 |
openButton.setText("Open..."); |
|
79 |
openButton.addSelectionListener(new SelectionListener() { |
|
80 |
|
|
81 |
@Override |
|
82 |
public void widgetSelected(SelectionEvent event) { |
|
83 |
|
|
84 |
SimpleFileDialog fd = new SimpleFileDialog(HTMLPlayer.this.getDisplay().getActiveShell(), "Opening media file...", "Enter file path or URL", BackToMediaPreferences.getInstance().getString(OpenMediaPlayer.ID), null); |
|
85 |
if (fd.open() == SimpleFileDialog.OK) { |
|
86 |
String mrl = fd.getValue(); |
|
87 |
|
|
88 |
if (mrl != null) { |
|
89 |
File f = new File(mrl); |
|
90 |
if (f.exists()) { |
|
91 |
mrl = new File(mrl).toURI().toString(); |
|
92 |
} |
|
93 |
else { |
|
94 |
|
|
95 |
} |
|
96 |
BackToMediaPreferences.getInstance().put(OpenMediaPlayer.ID, mrl); |
|
97 |
play(mrl, 0); |
|
98 |
} |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
104 |
}); |
|
84 | 105 |
|
85 |
@Override |
|
86 |
public void widgetSelected(SelectionEvent event) { |
|
87 |
if (playpauseButton.getSelection()) { |
|
88 |
resume(); |
|
89 |
playpauseButton.setText("Pause"); |
|
90 |
} else { |
|
91 |
pause(); |
|
92 |
playpauseButton.setText("Play"); |
|
106 |
stopButton = new Button(controls, SWT.PUSH); |
|
107 |
stopButton.setText("Stop"); |
|
108 |
stopButton.addSelectionListener(new SelectionListener() { |
|
109 |
|
|
110 |
@Override |
|
111 |
public void widgetSelected(SelectionEvent event) { |
|
112 |
stop(); |
|
93 | 113 |
} |
94 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
117 |
}); |
|
95 | 118 |
|
96 |
@Override |
|
97 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
98 |
}); |
|
99 |
|
|
100 |
Button replayButton = new Button(controls, SWT.PUSH); |
|
101 |
replayButton.setText("Re-play"); |
|
102 |
replayButton.addSelectionListener(new SelectionListener() { |
|
119 |
// Button playpauseButton = new Button(controls, SWT.TOGGLE); |
|
120 |
// playpauseButton.setText("Pause"); |
|
121 |
// playpauseButton.setSelection(true); |
|
122 |
// playpauseButton.addSelectionListener(new SelectionListener() { |
|
123 |
// |
|
124 |
// @Override |
|
125 |
// public void widgetSelected(SelectionEvent event) { |
|
126 |
// if (playpauseButton.getSelection()) { |
|
127 |
// resume(); |
|
128 |
// playpauseButton.setText("Pause"); |
|
129 |
// } else { |
|
130 |
// pause(); |
|
131 |
// playpauseButton.setText("Play"); |
|
132 |
// } |
|
133 |
// } |
|
134 |
// |
|
135 |
// @Override |
|
136 |
// public void widgetDefaultSelected(SelectionEvent e) { } |
|
137 |
// }); |
|
138 |
// |
|
139 |
// Button replayButton = new Button(controls, SWT.PUSH); |
|
140 |
// replayButton.setText("Re-play"); |
|
141 |
// replayButton.addSelectionListener(new SelectionListener() { |
|
142 |
// |
|
143 |
// @Override |
|
144 |
// public void widgetSelected(SelectionEvent event) { |
|
145 |
// replay(); |
|
146 |
// } |
|
147 |
// |
|
148 |
// @Override |
|
149 |
// public void widgetDefaultSelected(SelectionEvent e) { } |
|
150 |
// }); |
|
151 |
// |
|
152 |
// Button loopButton = new Button(controls, SWT.TOGGLE); |
|
153 |
// loopButton.setText("Loop"); |
|
154 |
// loopButton.setSelection(initRepeat); |
|
155 |
// loopButton.addSelectionListener(new SelectionListener() { |
|
156 |
// |
|
157 |
// @Override |
|
158 |
// public void widgetSelected(SelectionEvent event) { |
|
159 |
// setRepeat(loopButton.getSelection()); |
|
160 |
// } |
|
161 |
// |
|
162 |
// @Override |
|
163 |
// public void widgetDefaultSelected(SelectionEvent e) { } |
|
164 |
// }); |
|
165 |
// |
|
166 |
// volumeLabel = new Label(controls, SWT.NONE); |
|
167 |
// volumeLabel.setText("Volume (100%)"); |
|
168 |
// |
|
169 |
// Scale volumneSpinner = new Scale(controls, SWT.NONE); |
|
170 |
// volumneSpinner.setMinimum(0); |
|
171 |
// volumneSpinner.setMaximum(100); |
|
172 |
// volumneSpinner.setSelection(100); |
|
173 |
// volumneSpinner.addSelectionListener(new SelectionListener() { |
|
174 |
// |
|
175 |
// @Override |
|
176 |
// public void widgetSelected(SelectionEvent e) { |
|
177 |
// setVolume(volumneSpinner.getSelection()); |
|
178 |
// } |
|
179 |
// |
|
180 |
// @Override |
|
181 |
// public void widgetDefaultSelected(SelectionEvent e) { } |
|
182 |
// }); |
|
103 | 183 |
|
104 |
@Override |
|
105 |
public void widgetSelected(SelectionEvent event) { |
|
106 |
replay(); |
|
107 |
} |
|
184 |
// GridData gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
|
185 |
// gdata.minimumWidth = gdata.widthHint = 150; |
|
186 |
// volumneSpinner.setLayoutData(gdata); |
|
108 | 187 |
|
109 |
@Override |
|
110 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
111 |
}); |
|
112 |
|
|
113 |
Button loopButton = new Button(controls, SWT.TOGGLE); |
|
114 |
loopButton.setText("Loop"); |
|
115 |
loopButton.addSelectionListener(new SelectionListener() { |
|
116 | 188 |
|
117 |
@Override |
|
118 |
public void widgetSelected(SelectionEvent event) { |
|
119 |
setRepeat(loopButton.getSelection()); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
124 |
}); |
|
189 |
} |
|
125 | 190 |
|
126 |
Scale volumneSpinner = new Scale(controls, SWT.NONE); |
|
127 |
volumneSpinner.setMinimum(0); |
|
128 |
volumneSpinner.setMaximum(100); |
|
129 |
volumneSpinner.setSelection(100); |
|
130 |
volumneSpinner.addSelectionListener(new SelectionListener() { |
|
131 |
|
|
132 |
@Override |
|
133 |
public void widgetSelected(SelectionEvent e) { |
|
134 |
setVolume(volumneSpinner.getSelection()); |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
139 |
}); |
|
191 |
rateLabel = new Label(controls, SWT.NONE); |
|
192 |
rateLabel.setText("Rate (1.0)"); |
|
140 | 193 |
|
141 | 194 |
Scale rateSpinner = new Scale(controls, SWT.NONE); |
142 | 195 |
rateSpinner.setMinimum(10); |
... | ... | |
152 | 205 |
@Override |
153 | 206 |
public void widgetDefaultSelected(SelectionEvent e) { } |
154 | 207 |
}); |
208 |
GridData gdata2 = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
|
209 |
gdata2.minimumWidth = gdata2.widthHint = 150; |
|
210 |
rateSpinner.setLayoutData(gdata2); |
|
155 | 211 |
|
156 |
browser = new Browser(this, SWT.NONE); |
|
157 |
browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
158 |
browser.setText("<video id=\"video\" width=\"100%\" height=\"100%\" controls></video>"); |
|
159 |
//browser.setText("<video id=\"video\" width=\"100%\" height=\"100%\" controls><source id=\"source\" src=\"\"></source></video>"); |
|
212 |
// new Label(controls, SWT.NONE).setText("Progression"); |
|
213 |
// |
|
214 |
// Scale progressionSpinner = new Scale(controls, SWT.NONE); |
|
215 |
// progressionSpinner.setMinimum(0); |
|
216 |
// progressionSpinner.setMaximum(300); |
|
217 |
// progressionSpinner.setSelection(0); |
|
218 |
// progressionSpinner.addSelectionListener(new SelectionListener() { |
|
219 |
// |
|
220 |
// @Override |
|
221 |
// public void widgetSelected(SelectionEvent e) { |
|
222 |
// seek(((float)progressionSpinner.getSelection())); |
|
223 |
// } |
|
224 |
// |
|
225 |
// @Override |
|
226 |
// public void widgetDefaultSelected(SelectionEvent e) { } |
|
227 |
// }); |
|
228 |
// GridData gdata3 = new GridData(GridData.FILL, GridData.CENTER, true, false); |
|
229 |
// progressionSpinner.setLayoutData(gdata3); |
|
230 |
|
|
231 |
|
|
232 |
|
|
160 | 233 |
} |
161 |
|
|
234 |
|
|
235 |
// @Override |
|
236 |
// public void dispose() { |
|
237 |
// if (!browser.isDisposed()) { |
|
238 |
// browser.evaluate("document.getElementById('video').pause();"); |
|
239 |
// browser.evaluate("document.getElementById('video').removeAttribute('src');"); |
|
240 |
// } |
|
241 |
// super.dispose(); |
|
242 |
|
|
162 | 243 |
@Override |
163 | 244 |
public void setCredentials(String login, String mdp) { |
164 | 245 |
|
165 |
//browser.evaluate(TXMCoreMessages.bind("video.;", login, mdp));
|
|
246 |
//browser.evaluate(TXMCoreMessages.bind("document.getElementById('video').;", login, mdp));
|
|
166 | 247 |
this.login = login; |
167 | 248 |
this.mdp = mdp; |
168 |
|
|
169 | 249 |
} |
170 | 250 |
|
251 |
public void setInitialMedia(String mrl, int start, int end) { |
|
252 |
this.initMrl = mrl; |
|
253 |
this.initStartTime = start; |
|
254 |
this.initEndTime = end; |
|
255 |
} |
|
171 | 256 |
|
257 |
public void setInitialMedia(String mrl, String start, String end) { |
|
258 |
this.initMrl = mrl; |
|
259 |
this.initStringStartTime = start; |
|
260 |
this.initStringEndTime = end; |
|
261 |
} |
|
262 |
|
|
172 | 263 |
public void hideStopButton() { |
173 | 264 |
if (this.stopButton != null && !this.stopButton.isDisposed()) { |
174 | 265 |
this.stopButton.dispose(); |
175 | 266 |
} |
176 | 267 |
} |
177 |
|
|
268 |
|
|
269 |
@Override |
|
270 |
public void dispose() { |
|
271 |
stop(); |
|
272 |
super.dispose(); |
|
273 |
} |
|
274 |
|
|
178 | 275 |
DateTimeFormatter hhmmssFormatter = DateTimeFormatter.ISO_LOCAL_TIME; |
276 |
protected boolean loaded; |
|
277 |
|
|
179 | 278 |
@Override |
180 | 279 |
public boolean play(String mrl, String startTime, String endTime) { |
181 | 280 |
|
... | ... | |
203 | 302 |
return play(mrl, start, end); |
204 | 303 |
|
205 | 304 |
} |
206 |
|
|
305 |
|
|
207 | 306 |
@Override |
208 |
public boolean play(String mrl, int start, int end) { |
|
307 |
public boolean play(String mrl2, int start, int end) {
|
|
209 | 308 |
|
210 |
browser.evaluate("document;"); |
|
211 |
browser.evaluate("document.getElementById(\"video\");"); |
|
212 |
browser.evaluate("document.getElementById(\"source\");"); |
|
309 |
// browser.evaluate("document;"); |
|
310 |
// browser.evaluate("document.getElementById('video');"); |
|
311 |
// |
|
312 |
if (login != null && mdp != null) { |
|
313 |
mrl2 = mrl2.replace("{0}", login).replace("{1}", mdp); |
|
314 |
} |
|
315 |
//System.out.println("MEDIA URL: "+mrl2); |
|
316 |
String script = ""; |
|
213 | 317 |
|
214 |
if (login != null && mdp != null) { |
|
215 |
mrl = mrl.replace("{0}", login).replace("{1}", mdp); |
|
318 |
if (HTMLPlayer.this.mrl == null || !HTMLPlayer.this.mrl.equals(mrl2)) { |
|
319 |
script += "document.getElementById('video').setAttribute('src', '"+mrl2+"');\n"; |
|
320 |
|
|
321 |
script += "document.getElementById('video').play();\n" + |
|
322 |
"document.getElementById('video').onloadedmetadata = function() {document.getElementById('video').currentTime = "+start+";};\n"; |
|
323 |
} else { |
|
324 |
script += "document.getElementById('video').play();\n" + |
|
325 |
"document.getElementById('video').currentTime="+start+";\n"; |
|
216 | 326 |
} |
217 | 327 |
|
218 |
String script = "document;\n" |
|
219 |
+ "video = document.getElementById('video');\n"; |
|
220 |
|
|
221 |
if (this.mrl == null || !this.mrl.equals(mrl)) { |
|
222 |
script += "video.setAttribute('src', '"+mrl+"');\n"; |
|
223 |
} |
|
224 |
script += "video.play();\n" + |
|
225 |
"video.currentTime="+start+";\n"; |
|
226 | 328 |
//System.out.println("EVAL: "+script); |
227 | 329 |
browser.evaluate(script); |
228 | 330 |
|
229 |
this.mrl = mrl; |
|
331 |
this.mrl = mrl2;
|
|
230 | 332 |
return true; |
231 | 333 |
} |
232 |
|
|
334 |
|
|
233 | 335 |
@Override |
234 | 336 |
public boolean play(String mrl, int start) { |
235 | 337 |
|
236 | 338 |
return play(mrl, start, -1); |
237 | 339 |
|
238 | 340 |
} |
239 |
|
|
341 |
|
|
240 | 342 |
@Override |
241 | 343 |
public void stop() { |
242 | 344 |
|
243 | 345 |
if (browser.isDisposed()) return; |
244 | 346 |
|
245 |
browser.evaluate("video.pause();"); |
|
246 |
browser.evaluate("video.setAttribute('src', '');"); |
|
347 |
mrl = null; |
|
348 |
browser.evaluate("document.getElementById('video').pause();"); |
|
349 |
browser.evaluate("document.getElementById('video').removeAttribute('src');"); |
|
247 | 350 |
|
248 | 351 |
} |
249 |
|
|
352 |
|
|
250 | 353 |
@Override |
251 | 354 |
public boolean isMediaLoaded() { |
252 | 355 |
|
253 | 356 |
return mrl != null && mrl.length() > 0; |
254 | 357 |
|
255 | 358 |
} |
256 |
|
|
257 |
@Override |
|
258 |
public void setRepeat(boolean b) { |
|
359 |
|
|
360 |
public void setInitialRepeat(boolean b) { |
|
259 | 361 |
|
260 |
browser.evaluate("video.loop="+b+";");
|
|
362 |
initRepeat = b;
|
|
261 | 363 |
|
262 | 364 |
} |
263 |
|
|
365 |
|
|
264 | 366 |
@Override |
265 |
public boolean isDisposed() {
|
|
367 |
public void setRepeat(boolean b) {
|
|
266 | 368 |
|
267 |
return browser.isDisposed();
|
|
369 |
browser.evaluate("document.getElementById('video').loop="+b+";");
|
|
268 | 370 |
|
269 | 371 |
} |
270 |
|
|
372 |
// |
|
373 |
// @Override |
|
374 |
// public boolean isDisposed() { |
|
375 |
// |
|
376 |
// return browser == null || browser.isDisposed(); |
|
377 |
// |
|
378 |
// } |
|
379 |
|
|
271 | 380 |
@Override |
272 | 381 |
public void seek(float time) { |
273 | 382 |
|
274 |
browser.evaluate("video.currentTime="+time+";");
|
|
383 |
browser.evaluate("document.getElementById('video').currentTime="+time+";");
|
|
275 | 384 |
|
276 | 385 |
} |
277 |
|
|
386 |
|
|
278 | 387 |
@Override |
279 | 388 |
public void pause() { |
280 | 389 |
|
281 |
browser.evaluate("video.pause();");
|
|
390 |
browser.evaluate("document.getElementById('video').pause();");
|
|
282 | 391 |
|
283 | 392 |
} |
284 |
|
|
393 |
|
|
285 | 394 |
@Override |
286 | 395 |
public void replay() { |
287 | 396 |
|
288 |
browser.evaluate("video.currentTime=0;");
|
|
397 |
browser.evaluate("document.getElementById('video').currentTime=0;");
|
|
289 | 398 |
|
290 | 399 |
} |
291 |
|
|
400 |
|
|
292 | 401 |
@Override |
293 | 402 |
public void resume() { |
294 | 403 |
|
295 |
browser.evaluate("video.play();");
|
|
404 |
browser.evaluate("document.getElementById('video').play();");
|
|
296 | 405 |
|
297 | 406 |
} |
298 |
|
|
407 |
|
|
299 | 408 |
@Override |
300 | 409 |
public void setVolume(double volume) { |
301 | 410 |
|
302 |
browser.evaluate("video.volume="+volume/100.0d+";");
|
|
303 |
|
|
411 |
browser.evaluate("document.getElementById('video').volume="+volume/100.0d+";");
|
|
412 |
if (volumeLabel != null && !volumeLabel.isDisposed()) volumeLabel.setText("Volume ("+(int)volume+"%)"); |
|
304 | 413 |
} |
305 |
|
|
414 |
|
|
306 | 415 |
@Override |
307 | 416 |
public void setRate(float rate) { |
308 | 417 |
|
309 |
browser.evaluate("video.playbackRate="+rate+";"); |
|
418 |
browser.evaluate("document.getElementById('video').playbackRate="+rate+";"); |
|
419 |
if (rateLabel != null && !rateLabel.isDisposed()) rateLabel.setText(String.format("Rate (%.1f)", rate)); |
|
310 | 420 |
|
311 | 421 |
} |
312 |
|
|
422 |
|
|
313 | 423 |
@Override |
314 | 424 |
public boolean isPlaying() { |
315 |
Object o = browser.evaluate("return !video.played;");
|
|
425 |
Object o = browser.evaluate("return !document.getElementById('video').played;");
|
|
316 | 426 |
if (o == null) return false; |
317 | 427 |
if (o instanceof Boolean) { |
318 | 428 |
return (Boolean)o; |
... | ... | |
320 | 430 |
return false; |
321 | 431 |
|
322 | 432 |
} |
323 |
|
|
433 |
|
|
324 | 434 |
@Override |
325 | 435 |
public void setStartTime(float seconds) { |
326 | 436 |
|
327 | 437 |
//browser.evaluate(TXMCoreMessages.bind("alert(''set start time {0}'');", seconds)); |
328 | 438 |
|
329 | 439 |
} |
330 |
|
|
440 |
|
|
331 | 441 |
@Override |
332 | 442 |
public void setStopTime(float seconds) { |
333 | 443 |
|
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/player/MediaPlayerEditor.java (revision 3206) | ||
---|---|---|
5 | 5 |
import org.eclipse.swt.widgets.Composite; |
6 | 6 |
import org.eclipse.ui.IEditorInput; |
7 | 7 |
import org.eclipse.ui.IEditorSite; |
8 |
import org.eclipse.ui.ISaveablePart; |
|
9 |
import org.eclipse.ui.ISaveablePart2; |
|
8 | 10 |
import org.eclipse.ui.PartInitException; |
9 | 11 |
import org.eclipse.ui.part.EditorPart; |
12 |
import org.txm.backtomedia.editors.input.MediaPlayerEditorInput; |
|
10 | 13 |
import org.txm.backtomedia.preferences.BackToMediaPreferences; |
11 | 14 |
|
12 | 15 |
public class MediaPlayerEditor extends EditorPart { |
... | ... | |
18 | 21 |
|
19 | 22 |
@Override |
20 | 23 |
public void createPartControl(Composite parent) { |
21 |
if ("HTML".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
22 |
player = new HTMLPlayer(parent, SWT.BORDER); |
|
24 |
if ("VLC".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
25 |
player = new VLCPlayer(parent, SWT.BORDER); |
|
26 |
} else { //if ("HTML".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
27 |
HTMLPlayer hplayer = new HTMLPlayer(parent, SWT.BORDER, this.getEditorInput().getLightWeightInterface()); |
|
28 |
|
|
29 |
hplayer.setInitialMedia(this.getEditorInput().getURL(), this.getEditorInput().getStartTime(), this.getEditorInput().getEndTime()); |
|
30 |
hplayer.setInitialMedia(this.getEditorInput().getURL(), this.getEditorInput().getStringStartTime(), this.getEditorInput().getStringEndTime()); |
|
31 |
hplayer.setCredentials(this.getEditorInput().getCredentialUser(), this.getEditorInput().getCredentialPassword()); |
|
32 |
hplayer.setInitialRepeat(this.getEditorInput().getLoop()); |
|
33 |
|
|
34 |
player = hplayer; |
|
35 |
|
|
23 | 36 |
// } else if ("JFX".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
24 | 37 |
// player = new JFXPlayer(parent, SWT.NONE); |
25 | 38 |
} |
26 |
else if ("VLC".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
27 |
player = new VLCPlayer(parent, SWT.BORDER); |
|
28 |
} |
|
29 |
else { |
|
30 |
player = new HTMLPlayer(parent, SWT.BORDER); |
|
31 |
} |
|
32 | 39 |
} |
33 | 40 |
|
41 |
public MediaPlayerEditorInput getEditorInput() { |
|
42 |
return (MediaPlayerEditorInput)super.getEditorInput(); |
|
43 |
} |
|
44 |
|
|
34 | 45 |
public void init() { |
35 | 46 |
|
36 | 47 |
} |
37 | 48 |
|
49 |
/* Returns whether the contents of this editor should be saved when the editor |
|
50 |
* is closed. |
|
51 |
* <p> |
|
52 |
* This method returns <code>true</code> if and only if the editor is dirty |
|
53 |
* (<code>isDirty</code>). |
|
54 |
* </p> |
|
55 |
*/ |
|
56 |
@Override |
|
57 |
public boolean isSaveOnCloseNeeded() { |
|
58 |
player.stop(); |
|
59 |
return false; |
|
60 |
} |
|
61 |
|
|
38 | 62 |
@Override |
39 | 63 |
public void setFocus() { |
40 | 64 |
|
41 | 65 |
} |
42 | 66 |
|
43 |
@Override |
|
44 |
public void dispose() { |
|
45 |
try { |
|
46 |
if (player != null) player.stop(); |
|
47 |
} |
|
48 |
catch (Exception e) { |
|
49 |
e.printStackTrace(); |
|
50 |
} |
|
51 |
|
|
52 |
super.dispose(); |
|
53 |
} |
|
54 |
|
|
55 | 67 |
/* |
56 | 68 |
* (non-Javadoc) |
57 | 69 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
58 | 70 |
*/ |
59 | 71 |
@Override |
60 |
public void doSave(IProgressMonitor monitor) {} |
|
72 |
public void doSave(IProgressMonitor monitor) {player.stop();}
|
|
61 | 73 |
|
62 | 74 |
/* |
63 | 75 |
* (non-Javadoc) |
... | ... | |
75 | 87 |
throws PartInitException { |
76 | 88 |
setSite(site); |
77 | 89 |
setInput(input); |
90 |
|
|
78 | 91 |
// VLCPlayerEditorInput ii = (VLCPlayerEditorInput) input; |
79 | 92 |
} |
80 | 93 |
|
... | ... | |
84 | 97 |
*/ |
85 | 98 |
@Override |
86 | 99 |
public boolean isSaveAsAllowed() { |
87 |
return false;
|
|
100 |
return true;
|
|
88 | 101 |
} |
89 | 102 |
|
103 |
/** |
|
104 |
* ensure the player is displayed and ready |
|
105 |
* @return |
|
106 |
*/ |
|
90 | 107 |
public IPlayer getPlayer() { |
91 | 108 |
return player; |
92 | 109 |
} |
... | ... | |
98 | 115 |
|
99 | 116 |
@Override |
100 | 117 |
public boolean isDirty() { |
101 |
return false;
|
|
118 |
return true;// player.isMediaLoaded();
|
|
102 | 119 |
} |
103 | 120 |
|
104 | 121 |
/** |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/input/MediaPlayerEditorInput.java (revision 3206) | ||
---|---|---|
35 | 35 |
import org.txm.rcp.IImageKeys; |
36 | 36 |
|
37 | 37 |
/** |
38 |
* MEdia player editor input
|
|
38 |
* Media player editor input
|
|
39 | 39 |
* |
40 | 40 |
* @author mdecorde |
41 | 41 |
*/ |
42 | 42 |
public class MediaPlayerEditorInput implements IEditorInput { |
43 | 43 |
|
44 |
String mrl; |
|
45 |
int startTime = 0, endTime = -1; |
|
46 |
private String sStartTime; |
|
47 |
private String sEndTime; |
|
48 |
private boolean loop; |
|
49 |
private String mdp; |
|
50 |
private String user; |
|
51 |
private boolean lightweight = false; |
|
52 |
|
|
44 | 53 |
/** |
45 | 54 |
* Instantiates a new Media player editor input. |
46 | 55 |
* |
... | ... | |
50 | 59 |
super(); |
51 | 60 |
} |
52 | 61 |
|
62 |
public MediaPlayerEditorInput(String mrl, int startTime) { |
|
63 |
|
|
64 |
this.mrl = mrl; |
|
65 |
this.startTime = startTime; |
|
66 |
} |
|
67 |
|
|
68 |
public MediaPlayerEditorInput(String mrl, int startTime, int endTime) { |
|
69 |
|
|
70 |
this.mrl = mrl; |
|
71 |
this.startTime = startTime; |
|
72 |
this.endTime = endTime; |
|
73 |
} |
|
74 |
|
|
75 |
public MediaPlayerEditorInput(String mrl, String sStartTime, String sEndTime) { |
|
76 |
|
|
77 |
this.mrl = mrl; |
|
78 |
this.sStartTime = sStartTime; |
|
79 |
this.sEndTime = sEndTime; |
|
80 |
} |
|
81 |
|
|
82 |
public String getURL() { |
|
83 |
return mrl; |
|
84 |
} |
|
85 |
|
|
86 |
public int getStartTime() { |
|
87 |
return startTime; |
|
88 |
} |
|
89 |
|
|
90 |
public int getEndTime() { |
|
91 |
return endTime; |
|
92 |
} |
|
93 |
|
|
94 |
public String getStringStartTime() { |
|
95 |
return sStartTime; |
|
96 |
} |
|
97 |
|
|
98 |
public String getStringEndTime() { |
|
99 |
return sEndTime; |
|
100 |
} |
|
101 |
|
|
53 | 102 |
/** |
54 | 103 |
* Exists. |
55 | 104 |
* |
... | ... | |
118 | 167 |
public Object getAdapter(@SuppressWarnings("rawtypes") Class arg0) { |
119 | 168 |
return null; |
120 | 169 |
} |
170 |
|
|
171 |
public void setLoop(boolean loop) { |
|
172 |
|
|
173 |
this.loop = loop; |
|
174 |
} |
|
121 | 175 |
|
122 |
/** |
|
123 |
* Gets the source. |
|
124 |
* |
|
125 |
* @return the Correspondance analysis underlying object |
|
126 |
*/ |
|
127 |
public Object getSource() { |
|
128 |
return ""; //$NON-NLS-1$ |
|
176 |
public boolean getLoop() { |
|
177 |
|
|
178 |
return loop; |
|
129 | 179 |
} |
180 |
|
|
181 |
public void setCrendentials(String user, String mdp) { |
|
182 |
|
|
183 |
this.user = user; |
|
184 |
this.mdp = mdp; |
|
185 |
} |
|
186 |
|
|
187 |
public String getCredentialUser() { |
|
188 |
|
|
189 |
return user; |
|
190 |
} |
|
191 |
|
|
192 |
public String getCredentialPassword() { |
|
193 |
|
|
194 |
return mdp; |
|
195 |
} |
|
196 |
|
|
197 |
public void setLightWeightInterface(boolean lightweight) { |
|
198 |
|
|
199 |
this.lightweight = lightweight; |
|
200 |
} |
|
201 |
|
|
202 |
public boolean getLightWeightInterface() { |
|
203 |
|
|
204 |
return lightweight ; |
|
205 |
} |
|
130 | 206 |
} |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/OpenMediaPlayer.java (revision 3206) | ||
---|---|---|
36 | 36 |
import org.eclipse.core.commands.ExecutionEvent; |
37 | 37 |
import org.eclipse.core.commands.ExecutionException; |
38 | 38 |
import org.eclipse.jface.dialogs.InputDialog; |
39 |
import org.eclipse.jface.util.IPropertyChangeListener; |
|
40 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
39 | 41 |
import org.eclipse.jface.viewers.IStructuredSelection; |
40 | 42 |
import org.eclipse.swt.SWT; |
41 | 43 |
import org.eclipse.swt.events.SelectionEvent; |
... | ... | |
79 | 81 |
if (o instanceof IStructuredSelection) { |
80 | 82 |
selection = (IStructuredSelection) o; |
81 | 83 |
Object s = selection.getFirstElement(); |
82 |
if (s instanceof File) { |
|
84 |
if (s instanceof File && !((File)s).isDirectory() && !((File)s).getName().endsWith(".groovy")) { |
|
85 |
|
|
83 | 86 |
File f = (File) s; |
84 | 87 |
|
85 | 88 |
try { |
... | ... | |
138 | 141 |
} |
139 | 142 |
|
140 | 143 |
public static MediaPlayerEditor openEditor(String mrl, int time) { |
141 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
142 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
143 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
144 |
try { |
|
145 |
MediaPlayerEditor player = (MediaPlayerEditor) page.openEditor(editorInput, MediaPlayerEditor.ID); |
|
146 |
if (player != null) { |
|
147 |
player.getPlayer().play(mrl, time); |
|
148 |
StatusLine.setMessage(""); |
|
149 |
if (mrl != null) { |
|
150 |
player.setPartName(new File(mrl).getName()); |
|
151 |
} |
|
152 |
|
|
153 |
return player; |
|
154 |
} |
|
155 |
else { |
|
156 |
System.out.println(MessagesMP.error_open_media); |
|
157 |
} |
|
158 |
} |
|
159 |
catch (PartInitException e) { |
|
160 |
e.printStackTrace(); |
|
161 |
} |
|
162 |
return null; |
|
144 |
|
|
145 |
return openEditor(mrl, time, -1, false, null, null); |
|
163 | 146 |
} |
164 | 147 |
|
165 | 148 |
public static MediaPlayerEditor openEditor(String mrl, int time, int endtime) { |
149 |
|
|
150 |
return openEditor(mrl, time, endtime, false, null, null); |
|
151 |
} |
|
152 |
|
|
153 |
public static MediaPlayerEditor openEditor(String path, int startTime, int endTime, boolean loop, String user, String mdp) { |
|
154 |
return openEditor(path, startTime, endTime, loop, user, mdp, false); |
|
155 |
} |
|
156 |
|
|
157 |
public static MediaPlayerEditor openEditor(String mrl, int time, int endtime, boolean loop, String user, String mdp, boolean lightInterface) { |
|
158 |
|
|
166 | 159 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
167 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
160 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(mrl, time, endtime); |
|
161 |
editorInput.setLoop(loop); |
|
162 |
editorInput.setLightWeightInterface(lightInterface); |
|
163 |
editorInput.setCrendentials(user, mdp); |
|
164 |
|
|
168 | 165 |
StatusLine.setMessage(MessagesMP.opening_media); |
169 | 166 |
try { |
170 | 167 |
MediaPlayerEditor player = (MediaPlayerEditor) page.openEditor(editorInput, MediaPlayerEditor.ID); |
171 |
|
|
172 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); //$NON-NLS-1$ |
|
173 |
if (player != null) { |
|
174 |
player.getPlayer().play(mrl, time, endtime); |
|
175 |
StatusLine.setMessage(""); |
|
176 |
} |
|
177 |
else { |
|
178 |
System.out.println(MessagesMP.error_open_media); |
|
179 |
return null; |
|
180 |
} |
|
181 | 168 |
return player; |
182 | 169 |
} |
183 | 170 |
catch (PartInitException e) { |
... | ... | |
187 | 174 |
return null; |
188 | 175 |
} |
189 | 176 |
|
190 |
public static MediaPlayerEditor openEditor(String path, String sStartTime, |
|
191 |
String sEndTime) { |
|
177 |
public static MediaPlayerEditor openEditor(String path, String sStartTime, String sEndTime) { |
|
178 |
return openEditor(path, sStartTime, sEndTime, false, null, null); |
|
179 |
} |
|
180 |
|
|
181 |
public static MediaPlayerEditor openEditor(String path, String sStartTime, String sEndTime, boolean loop, String user, String mdp) { |
|
182 |
return openEditor(path, sStartTime, sEndTime, loop, user, mdp, false); |
|
183 |
} |
|
184 |
|
|
185 |
public static MediaPlayerEditor openEditor(String path, String sStartTime, String sEndTime, boolean loop, String user, String mdp, boolean lightInterface) { |
|
186 |
|
|
192 | 187 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
193 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
188 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(path, sStartTime, sEndTime); |
|
189 |
editorInput.setLoop(loop); |
|
190 |
editorInput.setLightWeightInterface(lightInterface); |
|
191 |
editorInput.setCrendentials(user, mdp); |
|
192 |
|
|
194 | 193 |
StatusLine.setMessage(MessagesMP.opening_media); |
195 | 194 |
try { |
196 | 195 |
IEditorPart editor = page.openEditor(editorInput, MediaPlayerEditor.ID); |
... | ... | |
198 | 197 |
return null; |
199 | 198 |
} |
200 | 199 |
|
201 |
MediaPlayerEditor player = (MediaPlayerEditor) editor; |
|
202 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); |
|
203 |
if (player != null) { |
|
204 |
player.getPlayer().play(path, sStartTime, sEndTime); |
|
205 |
StatusLine.setMessage(""); |
|
206 |
} |
|
207 |
return player; |
|
200 |
return (MediaPlayerEditor)editor; |
|
208 | 201 |
} |
209 | 202 |
catch (PartInitException e) { |
210 | 203 |
e.printStackTrace(); |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 3206) | ||
---|---|---|
511 | 511 |
Log.fine(MessagesMP.BackToMedia_25 + path); |
512 | 512 |
|
513 | 513 |
// System.out.println("Linked editors: "+associatedEditors); |
514 |
MediaPlayerEditor vlcEditor = null; |
|
515 |
if (editor != null) { |
|
516 |
vlcEditor = associatedEditors.get(editor); |
|
514 |
boolean alreadyOpened = false; |
|
515 |
MediaPlayerEditor mediaPlayerEditor = null; |
|
516 |
if (editor != null && associatedEditors.get(editor) != null && associatedEditors.get(editor).getPlayer() != null && !associatedEditors.get(editor).getPlayer().isDisposed()) { |
|
517 |
mediaPlayerEditor = associatedEditors.get(editor); |
|
518 |
alreadyOpened = true; |
|
517 | 519 |
} |
518 | 520 |
|
519 |
if (vlcEditor == null || vlcEditor.getPlayer().isDisposed()) {
|
|
521 |
if (!alreadyOpened) {
|
|
520 | 522 |
// System.out.println("new editor linked to "+ce); |
521 |
vlcEditor = OpenMediaPlayer.openEditor(); |
|
523 |
String user = null, mdp = null; |
|
524 |
if (media_auth) { |
|
525 |
// path_prefix = NLS.bind(media_directory, secured_media_login, secured_media_password); |
|
526 |
user = System.getProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN); |
|
527 |
mdp = System.getProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD); |
|
528 |
} |
|
529 |
mediaPlayerEditor = OpenMediaPlayer.openEditor(path, sStartTime, sEndTime, true, user, mdp, true); |
|
522 | 530 |
|
523 | 531 |
// editor.getPlayer().setRepeat(true); |
524 |
if (vlcEditor == null) {
|
|
532 |
if (mediaPlayerEditor == null) {
|
|
525 | 533 |
Log.warning("Error: could not open the MediaPlayer."); |
526 | 534 |
return null; |
527 | 535 |
} |
... | ... | |
529 | 537 |
// move the editor in the window |
530 | 538 |
int position = BackToMediaPreferences.getInstance().getInt(BackToMediaPreferences.BACKTOMEDIA_POSITION); |
531 | 539 |
if (editor != null) { |
532 |
SWTEditorsUtils.addEditor((EditorPart) editor, vlcEditor, position);
|
|
540 |
SWTEditorsUtils.addEditor((EditorPart) editor, mediaPlayerEditor, position);
|
|
533 | 541 |
} |
534 | 542 |
|
535 |
Object player = vlcEditor.getPlayer(); |
|
536 |
if (player != null) { |
|
537 |
// player.hideStopButton(); |
|
538 |
associatedEditors.put(editor, vlcEditor); |
|
543 |
if (mediaPlayerEditor != null) { |
|
544 |
associatedEditors.put(editor, mediaPlayerEditor); |
|
539 | 545 |
} |
546 |
} else { |
|
547 |
mediaPlayerEditor.getPlayer().play(path, sStartTime, sEndTime); |
|
540 | 548 |
} |
541 | 549 |
|
542 |
if (media_auth) { |
|
543 |
// path_prefix = NLS.bind(media_directory, secured_media_login, secured_media_password); |
|
544 |
vlcEditor.getPlayer().setCredentials(System.getProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN), System.getProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD)); |
|
545 |
} |
|
546 |
vlcEditor.getPlayer().play(path, sStartTime, sEndTime); |
|
547 |
vlcEditor.getPlayer().setRepeat(true); |
|
548 |
|
|
549 |
// if (!vlcEditor.isMediaLoaded()) { |
|
550 |
// |
|
551 |
// vlcEditor.getSite().getPage().closeEditor(vlcEditor, false); |
|
552 |
// if (media_auth) { |
|
553 |
// Log.warning("The MediaPlayer could not open the media: " + media_directory); // don't show credentials |
|
554 |
// System.clearProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD); |
|
555 |
// System.clearProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN); |
|
556 |
// } |
|
557 |
// else { |
|
558 |
// Log.warning("The MediaPlayer could not open the media: " + path); |
|
559 |
// } |
|
560 |
// } |
|
561 |
|
|
562 | 550 |
if (path != null) { |
563 |
vlcEditor.setPartName(textid);
|
|
551 |
mediaPlayerEditor.setPartName(textid);
|
|
564 | 552 |
} |
565 |
return vlcEditor;
|
|
553 |
return mediaPlayerEditor;
|
|
566 | 554 |
|
567 | 555 |
} |
568 | 556 |
catch (Exception e2) { |
Formats disponibles : Unified diff