当前位置:编程学习 > wap >>

pocket PC 播放声音文件

在手持终端上有时需要根据系统判断给用户报警声音提示,下面的代码为调用系统函数,播放自己的报警声音

 需要引用PDALib

[csharp]
using PDALib; 
using PDALib;

播放声音文件的代码:

[csharp]
/// <summary>  
        /// 播放wav音频文件  
        /// </summary>  
        /// <param name="wavfilename"></param>  
        protected void PlayWave(string wavfilename) 
        { 
            //www.zzzyk.com       
            string fullpath = 
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly(). 
                ManifestModule.FullyQualifiedName) +@"\"+ wavfilename; 
            if (!System.IO.File.Exists(fullpath)) 
                // 播放备用语音文件  
                TWavePlayer.PlayWave( "Warning.wav"); 
            else 
                // 播放语音文件  
                TWavePlayer.PlayWave(fullpath); 
        } 
/// <summary>
        /// 播放wav音频文件
        /// </summary>
        /// <param name="wavfilename"></param>
        protected void PlayWave(string wavfilename)
        {
            //
            string fullpath =
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().
                ManifestModule.FullyQualifiedName) +@"\"+ wavfilename;
            if (!System.IO.File.Exists(fullpath))
                // 播放备用语音文件
                TWavePlayer.PlayWave( "Warning.wav");
            else
                // 播放语音文件
                TWavePlayer.PlayWave(fullpath);
        }

调用时的代码:

[csharp]
PlayWave("ALARM1.wav"); 
PlayWave("ALARM1.wav");

摘自 #Define

 

补充:移动开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,