`
javastder
  • 浏览: 12143 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

How to make Video splash

阅读更多

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 progr

    在开发应用程序时,一个吸引人的启动界面,也就是我们常说的“启动画面”(Splash Screen),可以为用户带来更好的第一印象。本示例将详细介绍如何在VB(Visual Basic)环境中创建一个自定义的启动画面,以提升软件...

    JavaFX For Dummies(Wiley,2014)

    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 ...

    C#实现SplashScreen

    在C#中实现SplashScreen(启动屏幕)是一个常见的需求,特别是在开发Windows桌面应用程序时,它可以在应用程序启动初期显示一个简洁的界面,展示品牌信息或进行加载进度提示。与VB.NET不同,C#需要通过手动控制加载...

    C# winform SplashScreen

    《C# WinForm Splash Screen 实现详解》 在软件开发中,Splash Screen(启动画面)是一种常见的用户界面设计,它通常在应用程序启动时显示,提供一个动态的视觉效果,同时可以展示公司标志、加载进度等信息,提升...

    C#闪屏SplashScreen

    在C#编程环境中,"闪屏(SplashScreen)"是一个应用程序启动时首先显示的临时窗口,通常用来展示品牌标识、加载进度或者简单的欢迎信息。它为用户提供了视觉反馈,表明程序正在初始化,增加了用户体验的专业感。本文...

    Splash

    《Splash》是一款独特的字体设计,它以其鲜明的个性和创新的风格在众多字体中脱颖而出。在IT行业中,字体设计是用户界面(UI)和用户体验(UX)设计中的关键元素,对于提升应用程序、网站或者品牌识别度起着至关重要...

    不破解跳过unity splash 界面,去掉烦人的LOGO

    不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash 界面,去掉烦人的LOGO 不破解跳过unity splash ...

    Android12 SplashScreen使用案例代码下载

    Android12 SplashScreen使用举例代码下载,运行效果 与 相关API使用介绍请参考博文: Android12适配指南——SplashScreen: https://xiaxl.blog.csdn.net/article/details/123522277 Android 12(API 31)引入了 ...

    Splash PRO EX播放器

    Splash是专为下一代多媒体播放器打造的杰出软件,可以观看高清电影、摄像机录像、高清电视节目,享受最好的视频质量和独特的用户体验,是高清播放器领域的一支新秀 Splash1.12.1激活版下载,具有Mirillis高级解码器...

    winform 启动 数据加载画面Splash Screan

    在Windows Forms(Winform)应用开发中,"启动数据加载画面"(Splash Screen)是一种常见的设计模式,用于在应用程序初始化和加载数据时提供一个简洁的界面,以展示品牌信息或加载进度,同时隐藏主窗体的加载过程。...

    Splash启动程序画面_splash_C++_

    在软件开发中,"Splash Screen"(启动程序画面)是一种常见的设计元素,它在应用程序启动时显示,通常用来展示公司标志、程序版本信息或者进行加载进度的显示。本项目是关于如何使用C++语言来创建一个自定义的Splash...

    带进度条的splash窗口

    在IT领域,Splash窗口通常指的是应用程序启动时显示的欢迎或加载屏幕,它向用户展示了程序正在准备运行的状态。而“带进度条的splash窗口”则更进一步,它为用户提供了有关程序启动进度的视觉反馈,增加了用户体验的...

    AnimSplash_splash_

    《使用Delphi开发的动态启动界面——AnimSplash_splash_详解》 在计算机软件开发领域,用户界面的设计至关重要,它不仅是软件与用户交互的第一道窗口,也是体现软件品质的重要因素。"AnimSplash_splash_"是一个专门...

    启动画面类Splash

    在Windows应用程序开发中,启动画面(Splash Screen)通常是一个短暂显示的窗口,它在应用程序启动时展示,以提供用户友好的加载体验。"启动画面类Splash"是专门为基于对话框的应用程序设计的一种机制,用于在应用...

    VB.NET中实现SplashScreen

    在VB.NET编程环境中,SplashScreen通常用于应用程序启动时显示一个简短的欢迎界面,它能够展示应用程序的品牌信息、加载进度或者正在进行的初始化操作。本文将详细介绍如何在VB.NET中实现SplashScreen,并设置...

    显示程序启动图片Splash类

    在开发应用程序时,为了提升用户体验,常常会在程序启动时展示一个具有公司或产品特色的启动画面,也就是所谓的“启动图片”或“Splash Screen”。这不仅可以让用户知道程序正在加载,还能展示品牌风格,增加视觉...

    简单炫酷Splash界面

    简单炫酷Splash界面

    纯C实现Splash

    标题中的“纯C实现Splash”指的是使用C语言编写程序,创建一个启动时显示的欢迎界面,通常称为Splash Screen。在软件启动过程中,Splash Screen会给用户一个应用正在加载的视觉反馈,提升用户体验。这类屏幕通常会...

    Android_SplashScreen_Video:SplashScreen 在加载 Main Activity 之前播放视频

    在Android_SplashScreen_Video-master文件中,可能包含了实现这一功能的完整代码示例,包括布局文件、Activity代码以及可能的额外资源文件。开发者可以通过查阅这些文件,了解具体实现细节,并根据自己的项目需求...

    Android代码-SplashScreen

    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...

Global site tag (gtag.js) - Google Analytics