查看完整版本: [-- AAuto免注册调用Aplayer示例 --]

APlayer 开发者论坛 -> APlayer 讨论区 -> AAuto免注册调用Aplayer示例 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

jacen 2014-11-15 01:08

AAuto免注册调用Aplayer示例

视频播放器示例源码下载:[attachment=339]

[attachment=340]


下面是一个更简单的APlayer调用示例:

import win.ui;
/*DSG{{*/
var winform = win.form(cls="aplayerform";text="aplayer播放器测试";right=835;bottom=484)
winform.add()
/*}}*/
import thunder.aPlayer;
var aPlayer = thunder.aPlayer(winform)
//播放器事件
aPlayer.OnMessage = function(message,wParam,lParam){
}
//按需下载解码器 http://aplayer.open.xunlei.com/codecs.zip
aPlayer.OnDownloadCodec =  function(strCodecPath){
    
}
aPlayer.open(
"http://f1.flv.kankan.xunlei.com/data/cdn_transfer/demo.hflv")
aPlayer.play()
//全屏
//winform.fullscreen(true);

winform.show()
win.loopMessage();


jacen 2014-11-15 01:18

import win.ui;
/*DSG{{*/
var winform = win.form(text="调用APlayer";right=856;bottom=483;bgcolor=15793151 )
winform.add(
btnFullScreen={cls=
"plus";left=811;top=458;right=847;bottom=481;background="\res\fullscreen.png";db=1;dr=1;notify=1;repeat="center";z=5};
btnPlay={cls=
"plus";left=10;top=457;right=42;bottom=480;background="\res\play.png";db=1;dl=1;notify=1;repeat="scale";z=6};
btnStop={cls=
"plus";left=518;top=458;right=550;bottom=481;background="\res\stop-hover.png";db=1;dr=1;notify=1;repeat="scale";z=7};
plus={cls=
"plus";left=664;top=458;right=692;bottom=481;background="\res\volume.png";db=1;dr=1;repeat="scale";z=3};
trackbar={cls=
"plus";left=49;top=460;right=514;bottom=478;background="\res\trackbar-bg.jpg";db=1;dl=1;dr=1;foreground="\res\trackbar.jpg";foreLeft=5;foreRepeat="expand";foreRight=14;notify=1;paddingLeft=2;z=1};
video={cls=
"custom";left=8;top=5;right=848;bottom=453;bgcolor=0;db=1;dl=1;dr=1;dt=1;z=2};
volume={cls=
"plus";left=690;top=461;right=800;bottom=479;background="\res\trackbar-bg.jpg";db=1;dr=1;foreground="\res\trackbar.jpg";foreLeft=5;foreRepeat="expand";foreRight=14;notify=1;paddingLeft=2;z=4}
)
/*}}*/

winform.btnStop.skin(
    background = {
        hover =
"/res/stop-hover.png";
        active =
"/res/stop-active.png";
        default =
"/res/stop.png";
    }
)

winform.btnPlay.skin(
    checked = {
        background = {
            hover =
"/res/pause-hover.png";
            active =
"/res/pause-active.png";
            default =
"/res/pause.png";
        }
    }
    background = {
        hover =
"/res/play-hover.png";
        active =
"/res/play-active.png";
        default =
"/res/play.png";
    }
)

winform.btnFullScreen.skin(
    background = {  
        hover =
"/res/fullscreen-hover.png";
        active =
"/res/fullscreen-active.png";
    }
)

import thunder.aPlayer;
var aPlayer = thunder.aPlayer(winform.video)

winform.trackbar.setTrackbarRange(1,100);
winform.trackbar.progressPos = 0;
aPlayer.OnOpenSucceeded =  
function(){
    winform.trackbar.setTrackbarRange(1,aPlayer.getDuration())
}
winform.trackbar.showProgress =
function(show){
    
if( !show ){
        
if( winform.timerProgressId ){
            winform.killtimer(winform.timerProgressId);
            winform.timerProgressId =
null;
        }
        
return;
    }
    
if( winform.timerProgressId ){
        
return;//避免重复启动定时器
    }
    
    
//显示视频播放进度
    winform.timerProgressId = winform.addtimer( 2000,
        
function(hwnd,msg,id,tick){
            
var pos = aPlayer.getPosition()
            
if(!pos) {
                winform.btnPlay.checked =
false;
                
return 0; //播放结束
            }
            
            winform.trackbar.progressPos =  pos;
        }
    )
}

winform.btnPlay.oncommand =
function(id,event){

    
if( winform.btnPlay.checked ){
        aPlayer.open(
"http://f1.flv.kankan.xunlei.com/data/cdn_transfer/demo.hflv")
        aPlayer.play()
        winform.trackbar.showProgress(
true);
    }
    
else {
        aPlayer.pause();
    }
    
}

winform.btnStop.oncommand =
function( id,event ){
    aPlayer.close()
    winform.btnPlay.checked =
false;
}
  
// 用户拖动滑块触发下面的函数
winform.trackbar.onMouseClick = function(wParam,lParam){
  
    winform.trackbar.showProgress(
false );  
    aPlayer.setPosition( winform.trackbar.progressPos );
    winform.trackbar.showProgress(
true );
}

winform.volume.setTrackbarRange(1,100);
winform.volume.progressPos = 100;
winform.volume.onPosChanged =
function( pos ){
    aPlayer.setVolume(pos);
}

winform.btnFullScreen.oncommand =
function(id,event){
    winform.video.fullscreen(
true);
}

// 关闭窗体时退出播放器
winform.onClose = function(hwnd,message,wParam,lParam){
    aPlayer.close();
}

//按回车、空格暂停
winform.isDialogMessage = function(hwnd,msg){
    
if(  msg.wParam == 0xD/*_VK_RETURN*/ || msg.wParam == 0x20/*_VK_SPACE*/ ){
        msg.hwnd = winform.btnPlay.hwnd;
        
return;
    }
    
return win.isDialogMessage(hwnd,msg);
}

//全屏快捷键
winform.video.translateAccelerator = function(msg){
    
if(  msg.wParam == 0xD/*_VK_RETURN*/ || msg.wParam == 0x20/*_VK_SPACE*/ ){
           msg.hwnd = winform.btnPlay.hwnd;
     }
    
if(  msg.wParam == 0x1B/*_VK_ESC*/ ){
          winform.video.fullscreen(
false);
     }
}

winform.show()
win.loopMessage();

aplayer 2014-11-16 17:52
感谢楼主分享!

阿刻凡 2014-11-18 10:44
感谢楼主分享!


查看完整版本: [-- AAuto免注册调用Aplayer示例 --] [-- top --]


Powered by phpwind v8.7 Code ©2003-2011 phpwind
Time 0.010716 second(s),query:0 Gzip enabled