以编程方式从 PowerPoint 演示文稿中提取嵌入文件

发布于 2024-09-15 15:15:50 字数 619 浏览 6 评论 0原文

我正在开发一个 VSTO PowerPoint 插件,其中涉及录制和播放声音。我在最后一刻被要求允许用户选择播放声音的设备,就像 Skype 那样。

一般来说,我认为不可能指定 PowerPoint 应使用什么设备,除非在控制面板中选择默认设备,而我无法以编程方式执行此操作。不过,我可以识别我的外接程序录制的声音,因为它们作为 SoundEffect 嵌入到我标记的形状中。

我的问题是:是否可以直接访问 .wav 文件 - 类似于 SoundEffect.ImportFromFile,但在另一个方向?如果我能做到这一点,我就可以使用加载项代码而不是 PowerPoint 打开并播放 .wav 文件。

[编辑:直接,我的意思是“无需以不同的格式保存演示文稿”]

或者,是否有一种方法可以添加和检索二进制文件作为演示文稿中的嵌入内容?

我怀疑这是不可能的,但如果有人知道,我会在 StackOverflow 上找到那个人!

I am working on a VSTO PowerPoint add-in which involves recording and playing sounds. I was requested at the last minute to allow users to pick the device that will play the sound, like Skype does.

In general, I don't think it is possible to specify what device PowerPoint should use, except by selecting the default device in the control panel, which I can't do programmatically. However I can recognize the sounds my add-in recorded because they are embedded as SoundEffect in Shapes that I tag.

My question is: is it possible to access the .wav file directly - something like the equivalent of SoundEffect.ImportFromFile, but in the other direction? If I could do that, I could open and play the .wav file using the add-in code, and not PowerPoint.

[Edit: by directly, I mean "without having to save the presentation under a different format"]

Alternatively, is there a way to add and retrieve binary files as embedded content in a presentation?

I suspect this is not possible, but that if someone knew, I would find that person on StackOverflow!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼睛会笑 2024-09-22 15:15:50

两者皆有可能。

  1. 从 PPTX 中提取 WAV:所有嵌入媒体都位于 .pptx\ppt\media 文件夹中(将 .pptx 重命名为 .zip,解压缩并导航到 \ppt\media)。它们通常按照添加和/或处理的顺序依次编号。 AFAIK,叙述总是嵌入的并且从不链接。问题将是确定要提取的确切内容 - 这可以通过在添加到 pptx 时添加标签或其他唯一标识符来解决。提取它的方法是使用 Open XML SDK(或直接使用 System.IO.Packaging)并打开当前演示文稿的内存中副本,在文件夹中找到 .wav(我使用 Linq-to-XML 来找到我需要的内容)并将其读入内存流,以便写入磁盘进行播放,或者如果您的加载项可以从内存流播放,那就更好了。

  2. PPTX 中的二进制类型:任何内容都可以进入 Open XML 文档,但关键是让它保留在那里。有关详细信息,请参阅此答案 - 是否可以向 Word 文档添加一些数据?

Both are possible.

  1. Extract WAVs from PPTX: All embedded media are in the .pptx\ppt\media folder (rename .pptx to .zip, unzip and nav to \ppt\media). They are usually sequentially numbered in the order they were added and/or processed. Narration, AFAIK, is always embedded and never linked. The problem will be identifying the exact one to extract - that may be taken care by adding a tag or other unique identifier to it when adding to the pptx. The way to extract it is to use the Open XML SDK (or just System.IO.Packaging directly) and open an in-memory copy of the current presentation, locate your .wav in the folder (I use Linq-to-XML to find what I need) and read that into a memory stream for either writing to disk to play or if your add-in can play from a memory stream, even better.

  2. Binary types in PPTX: Anything can go into an Open XML document, but it's making it stay there that is the key. See this answer for details - Is it possible to add some data to a Word document?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文