C#:直接调用 OpenFileDialog

C# 直接调用 OpenFileDialog,打开文件夹,选择视频文件,并播放。

编写  openvideo.cs  如下

// open a video file
using System;
using System.Diagnostics;
using System.Windows.Forms;
 
public class OpenVideoFile
{
    [STAThread]
    public static void Main()
    {
        OpenFileDialog ofd = new OpenFileDialog();
 
        // 设置对话框属性
        ofd.Title = "请选择Video文件";
        // 设置初始目录
        ofd.InitialDirectory = "D:\\VIDEO";
        // 设置文件过滤器
        ofd.Filter = "avi files (*.avi)|*.avi|All files (*.*)|*.*";
        ofd.FilterIndex = 1; // 设置默认的文件过滤器索引
        ofd.RestoreDirectory = true; // 设置在关闭对话框前还原目录
 
        if (ofd.ShowDialog() == DialogResult.OK) // 显示对话框
        {
            // 获取选中的文件路径
            string filePath = ofd.FileName;
            ProcessStartInfo startInfo = new ProcessStartInfo("D:\\FFModules\\Encoder\\mplayer.exe");
            startInfo.Arguments = " -aspect 4:3 " +filePath;
            startInfo.UseShellExecute = false;
        
            Process process = Process.Start(startInfo);
            process.WaitForExit();
        } else {
            Console.WriteLine("Select null");
        }
    }
}

where csc
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe

编译  csc /r:System.Windows.Forms.dll /target:winexe openvideo.cs

运行 openvideo

如果你的PC安装了【 格式工厂】这个应用软件,那么实际安装了Windows版的 FFmpeg
在D:\FormatFactory\FFModules\Encoder\ 能找到 mplayer.exe 和 ffmpeg.exe

这里谈谈 mplayer 简单应用:mplayer -h

1. 播放比例调整
mplayer -aspect 16:9 <videofile> 
mplayer -aspect 4:3 <videofile>

2. 控制热键
基本播放 
→     前进10秒
←     后退10秒
↑     前进60秒
↓     后退60秒
PageUP  前进10分钟
PageDown 后退10分钟
Enter   全屏开关
Space   暂停开关
Esc    退出
q     退出

相关推荐

  1. C#:直接调用 OpenFileDialog

    2024-04-22 13:40:02       16 阅读
  2. C# OpenFileDialog

    2024-04-22 13:40:02       19 阅读
  3. react 封装请求axios,直接调用即可

    2024-04-22 13:40:02       13 阅读
  4. yolov7直接调用zed相机实现三维测距(python)

    2024-04-22 13:40:02       12 阅读
  5. VScode 里面使用 python 去直接调用 CUDA

    2024-04-22 13:40:02       19 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-22 13:40:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-22 13:40:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-22 13:40:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-22 13:40:02       20 阅读

热门阅读

  1. 第二章:c语言中的表达式和运算符

    2024-04-22 13:40:02       13 阅读
  2. Vue解构工作原理

    2024-04-22 13:40:02       12 阅读
  3. python项目环境安装实测

    2024-04-22 13:40:02       17 阅读
  4. 3、完成量

    2024-04-22 13:40:02       13 阅读
  5. 【JVM】JVM调优可配置参数及配置时机和原则

    2024-04-22 13:40:02       16 阅读
  6. JVM基础

    JVM基础

    2024-04-22 13:40:02      15 阅读
  7. Proxmox VE (PVE) 教学 (2) | 网络配置

    2024-04-22 13:40:02       15 阅读
  8. 高可用环境kafka消息未按顺序消费问题

    2024-04-22 13:40:02       11 阅读