本文整理匯總了Java中com.codename1.components.MediaPlayer類的典型用法代碼示例。如果您正苦於以下問題:Java MediaPlayer類的具體用法?Java MediaPlayer怎麽用?Java MediaPlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MediaPlayer類屬於com.codename1.components包,在下文中一共展示了MediaPlayer類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDemo
import com.codename1.components.MediaPlayer; //導入依賴的package包/類
public Container createDemo() {
Container player = new Container(new BorderLayout());
final MediaPlayer mp = new MediaPlayer();
try {
InputStream is = Display.getInstance().getResourceAsStream(getClass(), "/video.mp4");
if(is != null) {
mp.setDataSource(is, "video/mp4", null);
} else {
mp.setDataSource("https://dl.dropbox.com/u/57067724/cn1/video.mp4");
}
} catch (IOException ex) {
ex.printStackTrace();
}
player.addComponent(BorderLayout.CENTER, mp);
return player;
}
示例2: play
import com.codename1.components.MediaPlayer; //導入依賴的package包/類
/**
* Start media playback implicitly setting the component to visible
*/
public void play() {
if(nativePlayer && curentForm == null){
curentForm = Display.getInstance().getCurrent();
Form f = new Form();
f.setLayout(new BorderLayout());
f.addComponent(BorderLayout.CENTER, new MediaPlayer(this));
f.show();
}
player.play();
}