国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

無外部控件制作多媒體播放器(一)

2024-07-21 02:16:09
字體:
來源:轉載
供稿:網友


利用mci指令制作播放器,簡單實用,很適合于做為自己軟件的一個附帶功能或背景音樂,正是基于這點需求,我準備分幾個部分來寫:

1、mci指令的簡單使用;
2、媒體播放的進度控制與音量調節;
3、音樂信息的讀取,包括mp3(id3v1 & id3v2)與asf(wma & wmv)等;
4、音樂列表的建立與保存(m3u格式)

本來主要是想寫播放音樂的,舉個播放視頻的例子,沒什么別的意思,只是感覺播放音樂實在是簡單,沒什么可寫,同時也是為了說明,mci放視頻也是可以的。

private const ws_child = &h40000000
private declare function mcisendstring lib "winmm.dll" alias "mcisendstringa" (byval lpstrcommand as string, byval lpstrreturnstring as string, byval ureturnlength as long, byval hwndcallback as long) as long
private declare function getshortpathname lib "kernel32" alias "getshortpathnamea" (byval lpszlongpath as string, byval lpszshortpath as string, byval cchbuffer as long) as long
private declare function setwindowpos lib "user32" (byval hwnd as long, byval hwndinsertafter as long, byval x as long, byval y as long, byval cx as long, byval cy as long, byval wflags as long) as long
private function shortname(lname as string) as string
    '取得短文件名
    dim s as string, i as long
    i = 512
    s = space$(i)
    getshortpathname lname, s, i
    shortname = left$(s, instr(1, s, vbnullchar) - 1)
end function

private function playmci(cmd as string, optional returnstr as string) as long
    '播放mci
    dim s as string
    s = space$(256)
    playmci = mcisendstring(cmd, s, 256, 0)
    returnstr = left$(s, instr(1, s, vbnullchar) - 1)
end function

private function showvideo(strfilename as string, hwd as long, x as long, y as long, w as long, h as long) as long
    dim i as long, s as string
    if dir(strfilename, vbhidden or vbreadonly or vbsystem) = vbnullstring or strfilename = vbnullstring then exit function
    i = playmci("open """ & shortname(strfilename) & """ alias song parent " & hwd & " style " & ws_child & " wait")
    if i <> 0 then exit function
    i = playmci("status song window handle wait", s)
    if i <> 0 then goto fail
    i = val(s)
    if i = 0 then goto fail
    setwindowpos i, 0, x, y, w, h, 0
    playmci "play song"
    showvideo = i   '若成功返回視頻窗口的句柄
    exit function
fail:
    playmci "close song"
end function

private sub cmdplay_click()
    i=showvideo("h:/1.wmv", me.hwnd, 0, 0, 100, 100)
   '返回的這個句柄,很有用的,可用于移動窗口位置,或subclass它,加上彈出菜單,響應鼠標動作等
    if i <> 0 then
        cmdplay.enabled = false
        cmdstop.enabled = true
    end if
end sub
private sub cmdstop_click()
    playmci "close song"
    cmdplay.enabled = true
    cmdstop.enabled = false
end sub

private sub form_load()
    me.scalemode = 3
    cmdplay.enabled = true
    cmdstop.enabled = false
    cmdplay.caption = "播放"
    cmdstop.caption = "停止"
end sub
private sub form_unload(cancel as integer)
    playmci "close song"
end sub


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉木萨尔县| 衡山县| 汉源县| 大连市| 柘城县| 昌乐县| 保亭| 永仁县| 永修县| 绥江县| 屯昌县| 民勤县| 卓尼县| 高碑店市| 四平市| 金平| 剑阁县| 巩义市| 建德市| 沙洋县| 虎林市| 杂多县| 泉州市| 莎车县| 洛宁县| 乐昌市| 临夏市| 沂南县| 洞口县| 绥中县| 巢湖市| 托克托县| 宁化县| 湖州市| 景东| 雷州市| 高平市| 沐川县| 筠连县| 马龙县| 安康市|