C# WinCE下播放*.wav,*.mp3 详解(适用WinCE6.0和以前的所有版本)

本文详细介绍了如何在Windows CE 6.0及更早版本下使用C#播放.wav和.mp3文件。对于.wav文件,微软提供了一种适用于小文件的标准播放类,而对于.mp3文件,作者推荐使用fmodce.dll控件,该控件可在旧版本的WinCE上运行。
摘要由CSDN通过智能技术生成

前天买了块wince的控制板,询问厂家如何用C#在wince下如何播放声音,令人郁闷的是,几天过去了也没问出个结果。只好自己找资料,

现在贡献出来,希望能帮助其他的朋友少走弯路。


我介绍的方法适用WinCE6.0和以前的所有版本。

1.首先介绍如何播放*.wav, 这个方式微软提供了标准的播放类,但不适合播放大文件的*.wav, 只适合10MB以内的简单系统提示语音。

如下:

using System;
using System.Runtime.InteropServices;
using System.IO;
namespace Dengfengsoft
{
    public class Sound
    {
        private byte[] m_soundBytes;
        private string m_fileName;
        //

        private enum Flags
        {
            SND_SYNC = 0x0000,  /* play synchronously (default) */
            SND_ASYNC = 0x0001,  /* plaSmartHomey asynchronously */
            SND_NODEFAULT = 0x0002,  /* silence (!default) if sound not found */
            SND_MEMORY = 0x0004,  /* pszSound points to a memory file */
            SND_LOOP = 0x0008,  /* loop the sound until next sndPlaySound */
            SND_NOSTOP = 0x0010,  /* don't stop any currently playing sound */
            SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
            SND_ALIAS = 0x00010000, /* name is a registry alias */
            SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
            SND_FILENAME = 0x00020000, /* name is file name */
            SND_RESOURCE = 0x00040004  /* name is resource name or atom */
        }

        [DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
        private extern static int WCE_PlaySound(string
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值