Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > 全屏的SWT多媒体播放器
【标  题】:全屏的SWT多媒体播放器
【关键字】:SWT
【来  源】:http://blog.csdn.net/benewu/archive/2007/04/11/1560268.aspx

全屏的SWT多媒体播放器

Your Ad Here SWT可以内嵌系统控件,这样理论就可以打开任何格式的文件。

下面代码是一个全屏的多媒体播放器。

package com.kompakar.tutorial.swt.video;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * 
 * 
@author Benewu(at)gmail.com
 * SWT Player
 
*/

public class SWTVideoPlayer {

    
public static void main(String[] args) {
        Display display 
= new Display();
        
//设置全屏shell
        Shell shell = new Shell(display,SWT.ON_TOP | SWT.TOOL);
//        Shell shell = new Shell(display); //带title的窗口
        shell.setText("SWT Video Player");

        shell.setSize(
640480);
        
        shell.setLayout(
new FillLayout());

        OleFrame frm 
= new OleFrame(shell, SWT.NONE);

        OleClientSite site 
= new OleClientSite(frm, SWT.NONE,
                
"MediaPlayer.MediaPlayer");
 
        OleAutomation auto 
= new OleAutomation(site);
        
int[] ids = null;
 
        
        ids 
= auto.getIDsOfNames(new String[] "Open" });
        String mediaFilePath 
= "D:/Program Files/eMule/Incoming/South.Park.S11E05.Fantastic.Easter.Special.DSR.XviD-CRiMSON.avi";
        auto.invoke(ids[
0],    new Variant[] new Variant(mediaFilePath) });

        
new SWTVideoPlayer().setOleAutomationPropertiy(auto);
        
        ids 
= auto.getIDsOfNames(new String[] "Play" });
        auto.invoke(ids[
0]);
        
        shell.open();

        
while (!shell.isDisposed())
            
if (!display.readAndDispatch())
                display.sleep();

        site.deactivateInPlaceClient();

        site.dispose();
        auto.dispose();
    }


    
private  void setOleAutomationPropertiy(OleAutomation auto) {
        Variant variant 
= null;
        variant 
= new Variant(0);
        
int[] ids = null;
        ids 
= auto.getIDsOfNames(new String[] "ShowCaptioning" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowControls" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowAudioControls" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowDisplay" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowGotoBar" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowPositionControls" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowStatusBar" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "ShowTracker" });
        auto.setProperty(ids[
0], variant);
        
        ids 
= auto.getIDsOfNames(new String[] "PlayCount" });
        auto.setProperty(ids[
0], variant);
        
        variant 
= new Variant(2);
        ids 
= auto.getIDsOfNames(new String[] "DisplaySize" });
        auto.setProperty(ids[
0], variant);
        
    }

}

如果有话要说,请联系我。
enjoy it!
Eclipse 插件安装注意事项:【上一篇】
ActiveBPEL Designer整合到Eclipse:【下一篇】
【相关文章】
  • 可以运行SWT的精简版JRE 1.4.2_04, 压缩后仅1.3MB
  • SWT 一个简单的自适应 CLabel 大小的画图组件
  • eclipse的SWT插件——SWT-Designer下载地址
  • Java2Script Pacemaker - 基于 SWT 开发 RIA 应用
  • 替代 SWT GridData 更简单有效的方法
  • Advanced SWT Widegts 3rd
  • SWT Hello World!!
  • Advanced SWT Widegts 2nd
  • 如何使 Eclipse(SWT 程序)能够使用 XP 系统外观?
  • SWT Extension under Windows OS can be checked out through CVS now!
  • 【随机文章】
  • 服务器端后刷新的自动定位
  • 这几天微软发布的一些好玩的东西
  • 利用Photoshop光晕美化字体
  • 科普知识
  • Linux中ext2、ext3及reiserfs文件系统概述
  • base想到...
  • 计算机病毒太厉害了
  • 梦幻西游 青龙也疯狂
  • 在C语言中调用进行python编程示例[原创]
  • html中select语句读取mysql表中内容
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.