php new com("wmplayer.ocx"),WMplayer.ocx的一些使用

属性/方法名: 说明:

[基本属性]

URL:String; 指定媒体位置,本机或网络地址

uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible

playState:integer; 播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪

enableContextMenu:Boolean; 启用/禁用右键菜单

fullScreen:boolean; 是否全屏显示

[controls] wmp.controls //播放器基本控制

controls.play; 播放

controls.pause; 暂停

controls.stop; 停止

controls.currentPosition:double; 当前进度

controls.currentPositionString:string; 当前进度,字符串格式。如“00:23”

controls.fastForward; 快进

controls.fastReverse; 快退

controls.next; 下一曲

controls.previous; 上一曲

[settings] wmp.settings //播放器基本设置

settings.volume:integer; 音量,0-100

settings.autoStart:Boolean; 是否自动播放

settings.mute:Boolean; 是否静音

settings.playCount:integer; 播放次数

[currentMedia] wmp.currentMedia //当前媒体属性

currentMedia.duration:double; 媒体总长度

currentMedia.durationString:string; 媒体总长度,字符串格式。如“03:24”

currentMedia.getItemInfo(const string); 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述, "Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址

currentMedia.setItemInfo(const string); 通过属性名设置媒体信息

currentMedia.name:string; 同 currentMedia.getItemInfo("Title")

[currentPlaylist] wmp.currentPlaylist //当前播放列表属性

currentPlaylist.count:integer; 当前播放列表所包含媒体数

currentPlaylist.Item[integer]; 获取或设置指定项目媒体信息,其子属性同wmp.currentMedia

playState:integer; 播放状态。这个属性改变时同时引发PlayStateChange事件与StateChange事件。取值范围为枚举型:WMPLib.WMPPlayState,它的成员如下:

wmppsUndefined = 0;   //未知状态

wmppsStopped = 1;    //播放停止

wmppsPaused = 2;     //播放暂停

wmppsPlaying = 3;     //正在播放

wmppsScanForward = 4;   //向前搜索

wmppsScanReverse = 5;   //向后搜索

wmppsBuffering = 6;     //正在缓冲

wmppsWaiting = 7;      //正在等待流开始

wmppsMediaEnded = 8;    //播放流已结束

wmppsTransitioning = 9;    //准备新的媒体文件

wmppsReady = 10;      //播放准备就绪

wmppsReconnecting = 11;   //尝试重新连接流媒体数据

wmppsLast = 12;       //上一次状态,状态没有改变

利用aar播放示例:import win.ui;

import com;

import fsys;

import table;

import string;

import console;

/*DSG{{*/

var winform = win.form(text="aardio Form";right=368;bottom=450;exmode="toolwindow";max=false;min=false;parent=...)

winform.add(

button={cls="button";text="获取播放状态";left=12;top=387;right=82;bottom=431;z=7};

button2={cls="button";text="获取播放进度";left=91;top=389;right=165;bottom=433;z=8};

button3={cls="button";text="button3";left=177;top=391;right=231;bottom=433;z=9};

button4={cls="button";text="button4";left=244;top=396;right=313;bottom=436;z=10};

listbox={cls="listbox";left=33;top=54;right=336;bottom=366;ah=1;aw=1;bgcolor=16777215;edge=1;hscroll=1;items={};vscroll=1;z=4};

next={cls="button";text="下一曲";left=276;top=7;right=320;bottom=42;ah=1;aw=1;z=6};

pause={cls="button";text="暂停";left=109;top=7;right=153;bottom=42;ah=1;aw=1;z=2};

play={cls="button";text="播放";left=47;top=7;right=97;bottom=42;ah=1;aw=1;z=1};

previous={cls="button";text="上一曲";left=221;top=7;right=265;bottom=42;ah=1;aw=1;z=5};

stop={cls="button";text="停止";left=165;top=7;right=208;bottom=42;ah=1;aw=1;z=3}

)

/*}}*/

console.open();

var wmp = com.CreateObject("WMPlayer.OCX");

//io.open();

list = {};

musiclist = {};

path = "D:\KuGou";

fsys.enum( path, "*.*",

function(dir,filename,fullpath,findData){

if(filename){

//io.print("发现文件:"+filename,"完整路径:"+fullpath)

if string.find(filename,".mp3")!=null or string.find(filename,".wav")!=null or string.find(filename,".MP3")!=null or string.find(filename,".WAV")!=null {

//io.print(filename);

table.push(list,filename+"  "+fullpath);

table.push(musiclist,fullpath);

}

}

/*

else{

io.print( "发现目录:" + dir )

}*/

}

,

function(dir){

return true;

}

/*如果此参数为false则忽略子目录*/

);

for i in list {

winform.listbox.add(list[i]);

}

for j in musiclist {

media = wmp.newMedia(musiclist[j]);

wmp.currentPlaylist.appendItem(media);

}

//查看当前进度

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

//winform.msgbox( winform.button2.text );

console.log(wmp.controls.currentPositionString());

}

//查看媒体总长度

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

console.dump(wmp.currentMedia.durationString());

}

//获取播放文件信息

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

console.dump("名字:",wmp.currentMedia.getItemInfo("title"));

console.dump("名字:",wmp.currentMedia.getItemInfo("FileSize"));

}

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

wmp.controls.next();

}

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

wmp.controls.previous();

}

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

wmp.controls.stop();

}

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

wmp.controls.pause();

}

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

wmp.controls.play();

}

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

if( event == 0x2/*_LBN_SELCHANGE*/ ){

winform.msgbox(musiclist[winform.listbox.selIndex]);

}

}

//查看播放状态

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

//winform.msgbox( winform.button.text );

console.log("播放状态:");

select(wmp.playState()) {

case 1 {

console.log("停止!")

}

case 2 {

console.log("暂停中!")

}

case 3 {

console.log("播放中!")

}

else {

console.log("....!")

}

}

}

winform.show()

win.loopMessage();

5e38b7d70472dea257ce9988e427990a.png

以上代码基于原帖:http://bbs.aardio.com/forum.php?mod=viewthread&tid=9629&extra=page%3D1

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值