?? streamingdatasource.java
字號(hào):
import java.io.IOException;
import javax.microedition.media.Control;
import javax.microedition.media.protocol.DataSource;
import javax.microedition.media.protocol.SourceStream;
public class StreamingDataSource extends DataSource {
// the full URL like locator to the destination
private String locator;
// the internal streams that connect to the source
// in this case, there is only one
private SourceStream[] streams;
// is this connected to its source?
private boolean connected = false;
public StreamingDataSource(String locator) {
super(locator);
setLocator(locator);
}
public void setLocator(String locator) { this.locator = locator; }
public String getLocator() { return locator; }
public void connect() throws IOException {
// if already connected, return
if (connected) return;
// if locator is null, then can't actually connect
if (locator == null)
throw new IOException("locator is null");
// now populate the sourcestream array
streams = new RTPSourceStream[1];
// with a new RTPSourceStream
streams[0] = new RTPSourceStream(locator);
// set flag
connected = true;
}
public void disconnect() {
// if there are any streams
if (streams != null) {
// close the individual stream
try {
((RTPSourceStream)streams[0]).close();
} catch(IOException ioex) {} // silent
}
// and set the flag
connected = false;
}
public void start() throws IOException {
if(!connected) return;
// start the underlying stream
((RTPSourceStream)streams[0]).start();
}
public void stop() throws IOException {
if(!connected) return;
// stop the underlying stream
((RTPSourceStream)streams[0]).close();
}
public String getContentType() {
// for the purposes of this article, it is only video/mpeg
return "video/mpeg";
}
public Control[] getControls() { return new Control[0]; }
public Control getControl(String controlType) { return null; }
public SourceStream[] getStreams() { return streams; }
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -