How to make Video splash

本文介绍了一个简单的视频启动屏实现方案,支持多种视频格式,如GIF、AVI、MPG等,并提供了完整的Java代码示例。

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;
    }
 
}

 

<think>好的,用户之前询问了如何屏蔽特定的ACPI方法,现在他们又提出了关于将GRUB启动参数中的“quiet splash”改为“nomodeset”的问题。我需要先理解用户的需求以及他们可能的知识水平。 首先,用户可能是在安装或使用Linux系统时遇到了显示问题,比如显卡驱动不兼容导致无法正常进入图形界面。他们可能尝试过其他方法,现在想通过修改启动参数来解决。需要确认用户的具体情况,但根据问题本身,用户可能是在安装Ubuntu或类似发行版时遇到问题,需要临时禁用内核模式设置(KMS)。 接下来,我需要解释“quiet splash”和“nomodeset”各自的作用。“quiet splash”是启动时隐藏详细信息,显示品牌标志,而“nomodeset”是禁用内核模式设置,让系统使用基本显示驱动。用户可能需要了解这两个参数的区别以及为何要替换。 然后,操作步骤是关键。用户需要知道如何编辑GRUB配置文件,可能对Linux命令行操作不太熟悉,所以步骤要详细但清晰。需要注意提醒用户备份配置文件,避免操作失误导致系统无法启动。 还要考虑用户可能的风险和后续步骤。例如,使用nomodeset后可能需要安装合适的显卡驱动,或者这只是临时解决方案。需要指出这一点,并提供后续建议,比如安装专有驱动后可以移除nomodeset。 另外,用户可能不太清楚nomodeset的具体影响,比如分辨率降低或性能问题,需要说明这些潜在问题,帮助他们权衡利弊。同时,提醒不同显卡可能需要不同的参数,如NVIDIA的nouveau.modeset=0,避免用户遇到其他问题。 最后,确保回答结构清晰,分步骤说明,注意事项和常见问题,让用户能按部就班操作,同时了解可能的风险和解决方法。需要保持语言简洁,避免技术术语过多,但又要准确,确保用户正确理解每个步骤的意义。</think>--- ### **将GRUB启动参数中的 `quiet splash` 修改为 `nomodeset` 的用途与操作指南** --- #### **1. `quiet splash` 和 `nomodeset` 的作用解析** - **`quiet splash`** - **用途**: - `quiet`:隐藏Linux内核启动时的详细日志信息,使启动过程更“安静”。 - `splash`:显示图形化启动界面(如Ubuntu的Logo动画)。 - **典型场景**: 默认用于提升用户体验,隐藏底层硬件初始化细节,让启动界面更简洁。 - **`nomodeset`** - **用途**: - **禁用内核模式设置(Kernel Mode Setting, KMS)**,强制系统使用最基本的显示驱动(如VESA或EFI帧缓冲)。 - 避免因显卡驱动不兼容导致的启动黑屏、分辨率异常或图形界面崩溃。 - **典型场景**: - 安装或运行Linux时遇到NVIDIA/AMD显卡驱动冲突。 - 无法进入图形界面(如卡在Ubuntu Logo界面)。 --- #### **2. 为何需要将 `quiet splash` 改为 `nomodeset`** - **核心原因**: 某些显卡(尤其是NVIDIA独立显卡或较新的AMD GPU)的专有驱动与Linux开源驱动(如`nouveau`或`amdgpu`)存在兼容性问题。 - **问题表现**: - 启动时黑屏或卡死。 - 图形界面分辨率极低(如仅显示640x480)。 - 安装系统时无法进入Live CD环境。 - **`nomodeset` 的作用**: 禁用内核自动加载显卡驱动,使用通用显示模式,为后续安装专有驱动或调试提供临时解决方案。 --- #### **3. 操作步骤(以Ubuntu为例)** ##### **步骤1:启动时临时添加 `nomodeset`** 1. 重启电脑,在GRUB菜单界面(启动时按住 `Shift` 或 `Esc`)选择需启动的条目。 2. 按 `e` 进入编辑模式,找到以 `linux` 开头的行,删除 `quiet splash`,替换为 `nomodeset`。 ``` 原始行: linux /boot/vmlinuz... ro quiet splash $vt_handoff 修改后: linux /boot/vmlinuz... ro nomodeset $vt_handoff ``` 3. 按 `Ctrl+X` 或 `F10` 启动系统。 ##### **步骤2:永久修改GRUB配置** 1. 打开终端,编辑GRUB配置文件: ```bash sudo nano /etc/default/grub ``` 2. 修改 `GRUB_CMDLINE_LINUX_DEFAULT` 行: ``` 原始值: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 修改后: GRUB_CMDLINE_LINUX_DEFAULT="nomodeset" ``` 3. 保存文件并更新GRUB: ```bash sudo update-grub ``` 4. 重启生效: ```bash sudo reboot ``` --- #### **4. 注意事项与后续操作** - **临时性解决方案**: `nomodeset` 仅用于临时绕过驱动问题,长期使用会导致以下问题: - 分辨率锁定为低分辨率。 - 无法启用显卡硬件加速(影响游戏、视频渲染)。 - **安装专有驱动**: 1. 进入系统后,安装厂商驱动(如NVIDIA官方驱动): ```bash sudo ubuntu-drivers autoinstall ``` 2. 安装完成后,移除 `nomodeset` 并重新启用KMS: - 删除 `/etc/default/grub` 中的 `nomodeset`,恢复 `quiet splash`。 - 更新GRUB并重启。 - **替代参数(按需使用)**: - **NVIDIA显卡**:`nouveau.modeset=0`(仅禁用开源驱动)。 - **Intel/AMD显卡**:`i915.modeset=0` 或 `amdgpu.dc=0`。 --- #### **5. 常见问题与解决** - **Q1:添加 `nomodeset` 后仍黑屏** - 尝试组合参数:`nomodeset acpi=off`(禁用ACPI)或 `radeon.modeset=0`(AMD显卡)。 - **Q2:修改后无法进入系统** - 重启进入Recovery Mode,回退GRUB配置: ```bash sudo nano /etc/default/grub # 恢复原配置 sudo update-grub ``` - **Q3:分辨率过低** - 安装专有驱动后,通过 `nvidia-settings` 或 `xrandr` 调整分辨率。 --- #### **6. 总结建议** 1. **优先尝试临时修改**:在GRUB菜单中临时添加 `nomodeset`,确认问题是否解决。 2. **长期方案**:安装官方显卡驱动,避免依赖 `nomodeset`。 3. **日志分析**:若问题复杂,检查内核日志定位具体错误: ```bash dmesg | grep -i error ``` 如需进一步帮助,请提供以下信息: - 显卡型号(如NVIDIA RTX 3060) - 系统版本(如Ubuntu 22.04 LTS) - 错误现象截图或日志片段。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值