【问题标题】:How to use the path from resource folder with windows media player如何将资源文件夹中的路径与 Windows 媒体播放器一起使用
【发布时间】:2022-01-22 11:59:32
【问题描述】:

我正在尝试使用“Properties.Resources.File”作为 Windows Media Player 的路径。但它显然只接受一个字符串。如何获取“Namespace.Properties.Resources.File”作为可用路径?

    axWindowsMediaPlayer1.URL = Namespace.Properties.Resources.File;
    axWindowsMediaPlayer1.Ctlcontrols.play();
    

【问题讨论】:

  • Resources 只是一个文件夹,直到您编译您的应用程序,然后它们成为 嵌入式资源...嵌入到您的应用程序中。该文件夹只是为您和 Visual Studio 提供组织便利。假设 Winforms 给出了相关标签

标签: c# .net windows-forms-designer


【解决方案1】:
  • 首先,创建您自己的文件目录。 ./资源文件。

  • 如下使用。

 
  ​var​ ​soundPlayer​ ​=​ ​new​ ​System​.​Media​.​SoundPlayer​();
 pathName​ ​=​ ​@"​/resource_files/OK.wav​"​; 
 ​fileName​ ​=​ ​System​.​Web​.​HttpContext​.​Current​.​Server​.​MapPath​(​pathName​); 
 ​​soundPlayer​.​SoundLocation​ ​=​ ​fileName​; 
 ​soundPlayer​.​Play​();

希望对我亲爱的朋友有所帮助...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-21
    • 2013-05-18
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多