作者:绿茗
一天看到一篇文章,说到RM格式的文件能通过控件prct3260.ocx格式压缩。为此,我把该控件加入VB窗体,通过object browser对象浏览器认真分析其属性事件和方法。现编一个小程序,让大家共享。
运行界面如下图所示:
两个文本框分别为txtopen,txtsave,浏览两个按钮为cmdopen,cmdsave,开始、停止和退出按钮:cmdstart,cmdstopt,cmdexit,三个显示状态label,lblface, lblfacemul,lbltime。还有一些label。
下面为源程序。
Option Explicit
Dim i As Integer, j As Integer, k As Integer
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdopen_Click()
On Error Resume Next
dlg1.DialogTitle = "请选择制作的文件"
dlg1.ShowOpen
txtopen.Text = dlg1.FileName
If Trim(txtopen.Text) <> "" Then
cmdsave.Enabled = True
cmdstart.Enabled = True
txtsave.Text = Mid(txtopen.Text, 1, InStr(txtopen.Text, ".")) & "rm"
lblface.Caption = "选择文件开始"
End If
End Sub
Private Sub cmdsave_Click()
dlg2.DialogTitle = "请输入要保存的文件"
dlg2.ShowOpen
txtsave.Text = dlg2.FileName + ".rm"
End Sub
Private Sub cmdstart_Click()
ProducerControl1.InputFilename = ""
ProducerControl1.OutputFilename = ""
ProducerControl1.InputFilename = txtopen.Text
ProducerControl1.OutputFilename = txtsave.Text
ProducerControl1.StartEncoding
lblfacemul.Caption = "共1个文件"
cmdstart.Enabled = False
cmdsave.Enabled = False
cmdopen.Enabled = False
cmdstop.Enabled = True
lblface.Caption = "压缩开始...."
lbltime.Caption = "00:00:00"
Timer1.Enabled = True
i = 0
j = 0
k = 0
End Sub
Private Sub cmdstop_Click()
ProducerControl1.StopEncoding
cmdsave.Enabled = False
cmdopen.Enabled = False
lblface.Caption = "用户停止"
cmdstart.Enabled = True
cmdstop.Enabled = False
cmdopen.Enabled = True
cmdsave.Enabled = True
Timer1.Enabled = False
lblfacemul.Caption = "共压缩1个文件"
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
cmdstart.Enabled = False
cmdstop.Enabled = False
cmdsave.Enabled = False
dlg1.Filter = "Media Files(*.dat;*.mov;*.mp3;*.avi)|*.dat;*.mov;*.mp3;*.avi|Mpeg Files(*.mpg;*.mpeg;*.mpa;*.mp2;*.mp3)|*.mpg;*.mpeg;*.mpa;*.mp2;*.mp3|QuickTime Files(*.mov;*.qt)|*.mov;*.qt|Audio Files(*.wav;*.au)|*.wav;*.au"
dlg1.FilterIndex = 1
dlg1.InitDir = App.path
dlg2.Filter = "RM格式(*.rm)|*.rm"
txtopen.Text = ""
txtsave.Text = ""
ProducerControl1.InputType = INPUT_SOURCE_FILE '压缩文件
ProducerControl1.TempDirectory = "c:\windows\temp" '暂存目录
lblface.Caption = "请选择文件"
lbltime.Caption = "00:00:00"
ProducerControl1.Target256KDSLCableModem = True '目标听从为256线缆
ProducerControl1.InputDoAudio = True '音频输入为真
ProducerControl1.InputDoVideo = True '视频输入为真
ProducerControl1.AudioContent = AUDIO_CONTENT_VOICE_BACKGROUND '声音和背景音乐
ProducerControl1.VideoQuality = VIDEO_QUALITY_SMOOTH_MOTION '平滑图象
End Sub
Private Sub ProducerControl1_OnEncodingProgressChanged(ByVal duration As Long, ByVal timestamp As Long, ByVal PercentDone As Long, ByVal AudioPeakLevel As Long)
lblfacemul.Caption = "已压缩 " + CStr(PercentDone) + "%" '显示压缩百分比率
End Sub
Private Sub ProducerControl1_OnEncodingStopped()
Timer1.Enabled = False
cmdstop.Enabled = False
cmdstart.Enabled = True
lblface.Caption = "压缩完成"
lblfacemul.Caption = "谢谢您的使用!"
End Sub
Private Sub Timer1_Timer()
i = i + 1
If i > 59 Then
i = 0
j = j + 1
End If
If j > 59 Then
j = 0
k = k + 1
End If
If k > 23 Then
k = 0
End If
lbltime.Caption = Format(k, "00") & ":" & Format(j, "00") & ":" & Format(i, "00")
End Sub
以上简单的实现了RM文件的压缩,通过对象浏览器,你可以为程序增加批量压缩功能,可以设定目标听众等,因篇幅关系,我就不写出来了。欢迎与我交流(elby@21cn.com)。
最新更新
python爬虫及其可视化
使用python爬取豆瓣电影短评评论内容
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比