本文整理汇总了C#中System.Media.SoundPlayer.PlaySync方法的典型用法代码示例。如果您正苦于以下问题:C# System.Media.SoundPlayer.PlaySync方法的具体用法?C# System.Media.SoundPlayer.PlaySync怎么用?C# System.Media.SoundPlayer.PlaySync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Media.SoundPlayer
的用法示例。
在下文中一共展示了System.Media.SoundPlayer.PlaySync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayWav
private static void PlayWav(string wavFile)
{
Task.Run(() =>
{
var player = new System.Media.SoundPlayer {SoundLocation = wavFile};
player.PlaySync();
});
}
示例2: Play
public static void Play(Sonidos sonido)
{
byte[] musica = Obtener(sonido.ToString());
string pathSonido;
//play sonido
pathSonido = DameRutaTemporal(musica,sonido.ToString());
System.Media.SoundPlayer player = new System.Media.SoundPlayer(pathSonido);
player.PlaySync();
}
示例3: PlaySound
public static void PlaySound(ConfigurationProfile profile)
{
if (profile.SoundEnabled.IsTrue())
{
using (var p = new System.Media.SoundPlayer())
{
p.SoundLocation = Path.Combine(Globals.ExecutableDirectory, profile.Soundfile);
p.PlaySync();
}
}
}
示例4: Main
public static void Main(string[] args)
{
bool infinito = args[1] == "-i";
System.Media.SoundPlayer player = new System.Media.SoundPlayer(args[0]);
Console.WriteLine("Plaing:"+args[0]);
if (!infinito)
player.PlaySync();
else{
player.PlayLooping();
for(;;);
}
}
示例5: PlayAsync
public void PlayAsync(string url)
{
System.Threading.EventWaitHandle wait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
Task.Factory.StartNew(() =>
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer(url);
player.PlaySync();
wait.Set();
}).ContinueWith(x =>
{
wait.WaitOne();
});
}
示例6: Fisished
public void Fisished()
{
btStart.Text = "Start";
btStopReset.Text = "Reset";
IndicatorOn(false);
CDTimer.Enabled = false;
TimeToCountDown.Clear();
DisplayRefesh();
int sel = Properties.Settings.Default.WavFileSelected;
string location = CDCControls.WavLocation[sel];
System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);
for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
{
player.PlaySync();
}
}
示例7: PlayCachedSound
public static void PlayCachedSound(this UnmanagedMemoryStream resource)
{
if (ReferenceEquals(SoundCache, null))
SoundCache = new Dictionary<int, MemoryStream>();
if (!SoundCache.ContainsKey(resource.GetHashCode()))
{
resource.Position = 0;
SoundCache.Add(resource.GetHashCode(),
new MemoryStream(new BinaryReader(resource).ReadBytes((int)resource.Length))
);
}
System.Media.SoundPlayer sp = new System.Media.SoundPlayer(SoundCache[resource.GetHashCode()]);
try { sp.PlaySync(); }
catch { }
finally
{
sp = null;
SoundCache[resource.GetHashCode()].Position = 0;
}
}
示例8: beep
/// <summary>
/// Emet un bip.
/// </summary>
public void beep()
{
//Il faut que le bot ne soit pas en train de se déconnecter pour émettre un bip
if (!this.IsLoggingOut)
{
System.Media.SoundPlayer spBeep = new System.Media.SoundPlayer(Path.Combine(Logging.ApplicationPath, Classes.Updater.strPluginPath + "Sounds\\beep.wav"));
spBeep.PlaySync();
spBeep.PlaySync();
}
}
示例9: SAY
private void SAY(string content)
{
string[] lines;
#region decide emotion
//get current emotion
Console.WriteLine("EMOTION?");
emotion = Console.ReadLine();
//if emotion doesn't exist, set it to empty
if (emotion == "EMOTION")
{
emotion = "";
}
//load emotion settings
try
{
lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
}
catch
{
Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
Console.Out.Flush();
return;
}
//decide emotion
int numline = 1;
foreach (string line in lines)
{
if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
{
string[] separators = { "," };
string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
try
{
if (emotion == entry[0])
{
silent_animation = entry[1];
talk_animation = entry[2];
File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[3]);
}
}
catch
{
Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
}
}
numline++;
}
#endregion
#region coordinate animation
foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
{
if (part.Trim() != "")
{
//Generate speech wav
GenSpeech(part);
if (!noAnimation)
{
ANIMATE(talk_animation);
using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
{
player.PlaySync();
}
ANIMATE(silent_animation);
}
else
{
using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
{
player.Play();
}
}
}
}
#endregion
}
示例10: PlaySound
private void PlaySound() {
//オーディオリソースを取り出す
using (System.IO.Stream strm = Properties.Resources.sound1) {
//同期再生する
System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm);
player.PlaySync();
}
}
示例11: PlaySound
private void PlaySound()
{
string wavPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), WavFileUriPath);
Uri uri = new Uri(wavPath);
System.Media.SoundPlayer player = new System.Media.SoundPlayer(WavFileUriPath);
player.PlaySync();
this.Dispatcher.Invoke((Action)(() =>
{
recordGrid.Visibility = System.Windows.Visibility.Visible;
recordingdGrid.Visibility = System.Windows.Visibility.Hidden;
DisplayAnalysis();
}));
}
示例12: TellString
/// <summary>
/// Reads aloud string passed in parameter. Automatically detects available syllables or word parts from data direcory (Path is specified in DATA_PATH constant).
/// </summary>
/// <param name="input">String used as for slovak reading routine.</param>
public static void TellString(string input)
{
List<string> syllables = new List<string>();
DirectoryInfo directory = new DirectoryInfo(DATA_PATH);
foreach (FileInfo file in directory.GetFiles("*.wav"))
{
if (file.Name.Substring(0, file.Name.Length - file.Extension.Length) != SPACE_NAME) syllables.Add(file.Name.Substring(0, file.Name.Length - file.Extension.Length));
}
Queue<string> readingQueue = new Queue<string>();
foreach (string word in input.Replace("q", "k").Replace("w", "v").Replace("ä","e").Replace("nn","n").Replace(":",".").ToLower().Split(' '))
{
string wordPart = word;
while (wordPart != "")
{
string longestSyllable = "";
foreach (string syllable in syllables)
{
if (wordPart.StartsWith(syllable) && syllable.Length > longestSyllable.Length) longestSyllable = syllable;
}
if (longestSyllable == "") break;
readingQueue.Enqueue(longestSyllable);
wordPart = wordPart.Remove(0, longestSyllable.Length);
}
readingQueue.Enqueue(SPACE_NAME);
}
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
while (readingQueue.Count > 0)
{
player.SoundLocation = DATA_PATH + readingQueue.Dequeue() + ".wav";
player.PlaySync();
}
}
示例13: SAY
private void SAY(int id, string content)
{
string[] lines;
#region decide emotion
//get current emotion
Console.WriteLine("EMOTION?");
emotion = Console.ReadLine();
//if emotion doesn't exist, set it to empty
if (emotion == "EMOTION")
{
emotion = "";
}
//load emotion settings
try
{
lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
}
catch
{
Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
Console.Out.Flush();
return;
}
//decide emotion
int numline = 1;
foreach (string line in lines)
{
if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
{
string[] separators = { "," };
string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
try
{
if (emotion == entry[0])
{
File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[1]);
}
}
catch
{
Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
}
}
numline++;
}
#endregion
int length;
#region coordinate animation
foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
{
if (part.Trim() != "")
{
//Generate speech wav
length = GenSpeech(part);
if (length == 0) { return; }
//float[] amps = AmplitudesFromFile(Environment.CurrentDirectory + @"\res\sound\speech.wav");
if (!noAnimation)
{
Console.WriteLine(@"UI_PlaySound(res\sound\speech.wav," + id + ")");
System.Threading.Thread.Sleep(length);
}
else
{
using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\res\sound\speech.wav"))
{
player.PlaySync();
}
}
Console.WriteLine("UI_SetMouthOpen(0," + id + ")");
}
}
#endregion
}
示例14: PlayInternal
protected virtual void PlayInternal(string path)
{
System.Media.SoundPlayer soundPlayer = null;
try
{
soundPlayer = new System.Media.SoundPlayer(path);
soundPlayer.PlaySync();
}
catch (Exception ex)
{
Trace.WriteLine(ex);
}
finally
{
if (null != soundPlayer)
{
soundPlayer.Dispose();
soundPlayer = null;
}
}
}
示例15: Fisished
public void Fisished()
{
Timer.Enabled = false;
Time.Clear();
TimeChangedEventArgs e = new TimeChangedEventArgs(Time.ToString());
DelegateExpansion.CrossInvoke(CountDownChanged, this, e);
//CountDownChanged(this,e) ;
int sel = Properties.Settings.Default.WavFileSelected;
string location = CDCControls.WavLocation[sel];
System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);
for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
{
player.PlaySync();
}
}