找回密码
 加入
搜索
查看: 2387|回复: 4

[AU3基础] 写的电台播放器,录音之后换台功能失效

  [复制链接]
发表于 2011-6-22 19:23:35 | 显示全部楼层 |阅读模式
我在Tendy的源码的基础之上写了一款电台播放器,主要是增加了录音,优化了一些代码,纯属自用,专门用来听英语的,但最近发现一个Bug,就是使用录音功能并保存录音文件后,无论换什么台,都只会播放之前录制的那个电台,自己已经想方设法作了很多尝试,还是没用,希望大家看看。
;与本问题无关的代码省略,帖子最后有可供测试的已编译文件
Dim $inifile_path="playlist.ini"
$oMediaPlayer.URL=""
$PlayList = GuiCtrlCreateCombo("", 38, 90, 170, 21) ;创建列表
$Play = GuiCtrlCreateButton("播放", 5, 60, 45, 25) ;创建播放按钮
;……
$List = IniReadSection ($inifile_path,"List")
If @error Then
  MsgBox(16,"错误!","读取"&$inifile_path&"失败,程序无法继续!")
  Exit
EndIf
For $I = 1 To $List[0][0]
 $ComboList=$ComboList&"|"&$List[$I][0]
Next
GuiCtrlSetData($PlayList,$ComboList,$List[1][1])
GuiSetState()
;……
While 1
 Local $msg = GuiGetMsg()
 Select
;……
;播放列表
 Case $msg=$PlayList
  $oMediaPlayer.URL = IniRead ($inifile_path, "List",GUICtrlRead($PlayList),"")
  $oMediaPlayControl.Play
  GUICtrlSetData($Play,"停止")
;录音/保存
 Case $msg=$Record
  __Record()
 EndSelect
WEnd

;函数
;录音(Func)
Func __SoundMciSendString($string, $iLen = 65534)
 Local $iRet = DllCall('winmm.dll', 'int', 'mciSendString', 'str', $string, 'str', '', 'int', $iLen, 'hwnd', 0)
 Return $iRet[2]
EndFunc
Func __Record()
  Select
   Case GUICtrlRead($Play)="播放"
    MsgBox(0,"注意","您未收听任何电台!")
   Case GUICtrlRead($Record)="录制"
    __SoundMciSendString('Open New type WaveAudio alias recorder');新建录音recorder
    __SoundMciSendString('set recorder bitspersample 8');使用8位
    __SoundMciSendString('set recorder samplespersec 11025');11025Hz
    __SoundMciSendString('set recorder channels 2');立体声(双声道)
    __SoundMciSendString('record recorder');开始录音
    GUICtrlSetData($Record,"保存")
   Case GUICtrlRead($Record)="保存"
        GUICtrlSetData($Record,"录制")
    __SoundMciSendString('stop recorder')
        $RecordSave = FileSaveDialog('保存录音', @DesktopDir, '录音文件 (*.wav)', 18, 'Record.wav', $Formm)
        If Not @error Then __SoundMciSendString('save recorder "' & $RecordSave & '"')
    __SoundMciSendString('close recorder')
  EndSelect
EndFunc
下面是已编译的文件,供测试

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-6-23 09:15:32 | 显示全部楼层
有没有对这方面比较了解的朋友?都快沉了啊……
发表于 2011-7-6 11:23:36 | 显示全部楼层
源码都没有,怎么测试?!
发表于 2011-7-6 13:35:31 | 显示全部楼层
没有可运行的源码
难道让大家为了帮你一行行地看你给出的部分代码?
并且说不好不是你给出的源码部分的问题
发表于 2011-7-6 15:08:11 | 显示全部楼层
回复 1# 雪栀


超小家子气,还怕别人盗了你源码不成?问个问题都要遮遮掩掩,无法帮忙抱歉。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 03:36 , Processed in 0.081590 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表