开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1352|回复: 3
收起左侧

[源码分享] CD播放器

[复制链接]
发表于 2015-4-2 19:37:17 | 显示全部楼层 |阅读模式   陕西省西安市
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize 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 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
Dim Nowfen As Integer, Nowmiao As Integer
Dim M_stop As Boolean
Private Sub Combo1_Click()
        MMControl1.UpdateInterval = 0
        MMControl1.Command = "stop"
        MMControl1.TimeFormat = 10
        MMControl1.Track = Val(Combo1.Text)
        MMControl1.From = MMControl1.TrackPosition
        Slider1.Value = 0
        Slider1.Min = 0
        MMControl1.TimeFormat = 0
        If MMControl1.TrackLength < 1000 Then
            Slider1.Max = 1
        Else
            Slider1.Max = MMControl1.TrackLength \ 1000
        End If
        Fen = MMControl1.TrackLength \ 60000
        Lnow.Caption = "00:00"
        Lsum.Caption = Format$(Fen * 100 + (MMControl1.TrackLength \ 1000 - Fen * 60), "00:00")
        Lend.Caption = Lsum.Caption
        MMControl1.TimeFormat = 10
        MMControl1.Command = "play"
        MMControl1.TimeFormat = 0
End Sub
Private Sub Command1_Click()
    Unload Me
End Sub
Private Sub Command2_Click()
    Form1.Reload
End Sub
Private Sub Form_Activate()
    M_stop = False
    Form1.Reload
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then
        MMControl1.Command = "Close"
        End
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    MMControl1.Command = "stop"
    MMControl1.Command = "close"
End Sub
Private Sub MMControl1_PauseClick(Cancel As Integer)
    MMControl1.UpdateInterval = 0
    Combo1.Enabled = True
End Sub

Private Sub MMControl1_PlayClick(Cancel As Integer)
    MMControl1.UpdateInterval = 1000
    Combo1.Enabled = False
End Sub

Private Sub MMControl1_StatusUpdate()

        If Nowmiao = 59 Then
            Nowmiao = 0
            Nowfen = Nowfen + 1
        Else
            Nowmiao = Nowmiao + 1
        End If
        Slider1.Value = Slider1.Value + 1
        If Slider1.Value >= Slider1.Max Then
            MMControl1.TimeFormat = 10
            MMControl1.Track = Val(Combo1.Text) + 1
            MMControl1.TimeFormat = 0
            MMControl1.From = MMControl1.TrackPosition
            Slider1.Value = 0
            Slider1.Min = 0
            Combo1.Text = Combo1.List(Val(Combo1.Text))
            If MMControl1.TrackLength < 1000 Then
                Slider1.Max = 1
            Else
                Slider1.Max = MMControl1.TrackLength \ 1000
            End If
            Fen = MMControl1.TrackLength \ 60000
            Lnow.Caption = "00:00"
            Lsum.Caption = Format$(Fen * 100 + (MMControl1.TrackLength \ 1000 - Fen * 60), "00:00")
            Lend.Caption = Lsum.Caption
            Nowfen = 0
            Nowmiao = 0
            Exit Sub
        End If
        Lnow.Caption = Format$(Nowfen * 100 + Nowmiao, "00:00")
   
    If Nowmiao = 59 Then
        Nowmiao = 0
        Nowfen = Nowfen + 1
    Else
        Nowmiao = Nowmiao + 1
    End If
    Slider1.Value = Slider1.Value + 1
    Lnow.Caption = Format$(Nowfen * 100 + Nowmiao, "00:00")
    If Lnow.Caption >= Lsum.Caption Then
        Lnow.Caption = Lsum.Caption
        MMControl1.UpdateInterval = 0
    End If
End Sub

Private Sub MMControl1_StopClick(Cancel As Integer)
    MMControl1.UpdateInterval = 0
    M_stop = True
       Combo1.Enabled = True
        MMControl1.Command = "stop"
        MMControl1.TimeFormat = 10
        MMControl1.Track = 1
        MMControl1.TimeFormat = 0
        MMControl1.From = MMControl1.TrackPosition
        Slider1.Value = 0
        Slider1.Min = 0
        If MMControl1.TrackLength < 1000 Then
            Slider1.Max = 1
        Else
            Slider1.Max = MMControl1.TrackLength \ 1000
        End If
        Fen = MMControl1.TrackLength \ 60000
        Lnow.Caption = "00:00"
        Lsum.Caption = Format$(Fen * 100 + (MMControl1.TrackLength \ 1000 - Fen * 60), "00:00")
        Lend.Caption = Lsum.Caption
        Combo1.Text = "01"
  
End Sub

Private Sub Slider1_Change()
    If M_stop Then Exit Sub
    MMControl1.UpdateInterval = 1000
    MMControl1.From = Slider1.Value * 1000
    MMControl1.Command = "play"
    Nowfen = Slider1.Value \ 60
    Nowmiao = Slider1.Value - Nowfen * 60
End Sub

Public Sub Reload()
    Dim Drivename As String, I As Integer, A As Integer
    Nowfen = 0
    Nowmiao = 0
    MMControl1.Command = "Close"
    Drivename = ""
    '  查找CD-ROM的驱动器号
    For I = 65 To 75
        If GetDriveType(Chr$(I) & ":") = 5 Then
            Drivename = Chr$(I) & ":"
            Exit For
        End If
    Next
    If Drivename = "" Then
        A = MsgBox("找不到 CD-ROM !", 0 + 16, "提示信息")
        MMControl1.Command = "Close"
        End
    End If
    On Error GoTo err
    File1.Path = Drivename + "\"
    On Error GoTo 0
    File1.Pattern = "*.cda"
    If File1.ListCount > 0 Then
        Label2.Caption = " CD 唱片"
        MMControl1.DeviceType = "cdaudio"
        MMControl1.Command = "open"
        If MMControl1.Mode = 524 Then
            A = MsgBox("驱动程序安装错误,无法播放 CD 唱片 !", 0 + 16, "提示信息")
            MMControl1.Command = "Close"
            End
        End If
        MMControl1.TimeFormat = 0
        MMControl1.UpdateInterval = 0
        If File1.ListCount > 1 Then
            For I = 0 To File1.ListCount - 1
                Combo1.AddItem Format$(Str$(I + 1), "00"), I
                Combo1.Enabled = True
            Next I
            Combo1.Text = "01"
        Else
            Combo1.AddItem "01", 0
            Combo1.Enabled = True
        End If
        Slider1.Value = 0
        Slider1.Min = 0
        If MMControl1.TrackLength < 1000 Then
            Slider1.Max = 1
        Else
            Slider1.Max = MMControl1.TrackLength \ 1000
        End If
        Fen = MMControl1.TrackLength \ 60000
        Lnow.Caption = "00:00"
        Lsum.Caption = Format$(Fen * 100 + (MMControl1.TrackLength \ 1000 - Fen * 60), "00:00")
        Lend.Caption = Lsum.Caption
        Exit Sub
    End If
   
err:
    Label2.Caption = "不正确的碟片"
    A = MsgBox("未插入正确的碟片!", 0 + 1 + 16, "提示信息")
    If A = 2 Then
        MMControl1.Command = "Close"
        End
    End If
    Resume
End Sub

结帖率:86% (12/14)

签到天数: 1 天

发表于 2023-7-18 11:32:11 | 显示全部楼层   浙江省台州市
有窗体吗
回复 支持 反对

使用道具 举报

结帖率:87% (20/23)

签到天数: 1 天

发表于 2015-4-2 23:05:46 | 显示全部楼层   广东省东莞市
看不懂,不知道是啥。
回复 支持 反对

使用道具 举报

结帖率:36% (4/11)
发表于 2015-4-2 22:48:59 | 显示全部楼层   四川省南充市
沙发。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

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