• 7822阅读
  • 3回复

AAuto免注册调用Aplayer示例 [复制链接]

上一主题 下一主题
离线jacen
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2014-11-15
视频播放器示例源码下载: aplayer视频播放器.zip (49 K) 下载次数:51




下面是一个更简单的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
视频播放器示例源码(包含图像文件的完整工程需下载顶楼压缩包)

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
感谢楼主分享!
离线阿刻凡

只看该作者 地板  发表于: 2014-11-18
感谢楼主分享!
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个