http://wiki.forum.nokia.com/index.php/How_to_make_Video_splash
In those a few lines you will find a code of how to create easy startup splash screen that can play video files of any format (GIF,AVI,mpg,3gpp,real etc..)
video splash class
package GALAXY.videosplash;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
public class Splash extends Canvas implements PlayerListener, Runnable {
private Display display;
//the next screen
private Displayable next;
//the video mime type
private String MIMEtype;
private Player player;
private String file;
public Splash(Display display, Displayable next, String file,
String MIMEtype) {
this.display = display;
this.next = next;
this.file = file;
this.MIMEtype = MIMEtype;
Thread th = new Thread(this);
th.start();
}
//if any button is pressed, finalizes splash screen
protected void keyPressed(int keyCode) {
stopPlayer();
nextScreen();
}
protected void paint(Graphics g) {
int x = g.getClipX();
int y = g.getClipY();
int w = g.getClipWidth();
int h = g.getClipHeight();
g.setColor(0x0000000);
g.fillRect(x, y, w, h);
}
//for touch screen devices.
protected void pointerPressed(int x, int y) {
stopPlayer();
nextScreen();
}
protected void showNotify() {
}
private void nextScreen() {
this.display.setCurrent(next);
}
public void run() {
try {
resetplayer();
} catch (MediaException ex) {
nextScreen();
}
this.play(file);
}
public void playerUpdate(Player player, String playerstate, Object object) {
if (playerstate == PlayerListener.END_OF_MEDIA) {
try {
resetplayer();
} catch (MediaException me) {
}
player = null;
nextScreen();
}
}
private void resetplayer() throws MediaException {
if (player != null) {
//checks if the video is being rendered.
if (player.getState() == Player.STARTED) {
player.stop();
}
//the player has all resources to execute
if (player.getState() == Player.PREFETCHED) {
//free resources
player.deallocate();
}
//the player obtained the necessary information to acquire the resources (REALIZED) or the player
//has just been created.
if (player.getState() == Player.REALIZED ||
player.getState() == Player.UNREALIZED) {
player.close(); //closes the player
}
}
player = null;
}
private void play(String url) {
try {
//gets video from /res folder
InputStream is = getClass().getResourceAsStream(url);
VideoControl vc;
resetplayer();
// create a player instance
player = Manager.createPlayer(is, this.MIMEtype);
// realize the player
player.realize();
//gets all necessary resources
player.prefetch();
//adds a player listener. annonces player events: stoped, paused, etc
player.addPlayerListener(this);
//video control for video rendering
vc = (VideoControl) player.getControl("VideoControl");
//if null, the device probably has no support for video rendering
if (vc != null) {
vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
vc.setDisplayLocation(((this.getWidth() - vc.getDisplayWidth()) /
2),
(this.getHeight() - vc.getDisplayHeight()) /
2);
vc.setVisible(true);
this.setFullScreenMode(true);
}
player.start();
this.display.setCurrent(this);
} catch (Throwable t) {
player = null;
nextScreen();
}
}
private void stopPlayer() {
try {
resetplayer();
} catch (MediaException me) {
}
player = null;
}
}
second ,this is the MIDlet example. Note that all I have to do was just to create a new instance of videosplash class
MIDLET
{
package GALAXY.videosplash;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SplashMIDlet extends MIDlet {
static SplashMIDlet instance;
public SplashMIDlet() {
instance = this;
}
public void startApp() {
Display dispaly = Display.getDisplay(this);
Splash sp = new Splash(dispaly, new Form("Test"),"/PhotoStory.3gp", "video/3gpp");
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
分享到:
相关推荐
This demonstrates how to create a splash form for your program.
The book shows you how to work with JavaFX controls, how to enhance your scenic design, and also offers advice on how to make a splash with your programs. Then, the author wraps it all up with extra ...
how to update splash screen
Splash
Android_SplashScreen_Video SplashScreen 在加载 Main Activity 之前播放视频。
Android12 SplashScreen使用举例代码下载,运行效果 与 相关API使用介绍请参考博文: Android12适配指南——SplashScreen: https://xiaxl.blog.csdn.net/article/details/123522277 Android 12(API 31)引入了 ...
Splash是专为下一代多媒体播放器打造的杰出软件,可以观看高清电影、摄像机录像、高清电视节目,享受最好的视频质量和独特的用户体验,是高清播放器领域的一支新秀 Splash1.12.1激活版下载,具有Mirillis高级解码器...
C#实现SplashScreen,不同于VB.NET,需要在MAIN中控制加载界面的顺序。
简单炫酷Splash界面
Android SplashScreen Android library for getting a nice and simple SlashScreen into your Android app. Installation Up to now, the library is only available in JitPack. Please add this code to your...
简单的SplashScreen例子
不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash ...
带进度条的splash窗口
Splash Pro是一款高清影音视频播放工具,能够播放多种本地视频和音频,支持外挂字幕,和回放功能,当然最重要的一点,Splash Pro技术比较强大,据说耗电量比起同类软件来说要少! 功能&特点 硬件加速视频解码; ...
Splash启动界面
Splash screen组件是添加启动画面的时候要用到的,但是在基于对话框的工程下是不能直接添加的,如果把这个文件添加到工程目录下酒能用这个组件了
VC++2010工程中加入SPLASHSCREEN VC++2010工程中加入SPLASHSCREEN VC++2010工程中加入SPLASHSCREEN
android splash demo 源代码
Splash PRO EX 结合了包括NVIDIA CUDA 和 Intel Quick Sync Video 硬件视频解码加速的最新技术,让你在快速欣赏清晰生动的高清视频的同时,有效节约电量延长笔记本电池的使用时间!Mirillis 公司开发的还有一款顶级...
winform 窗体引导画面 等待画面