本文整理汇总了C#中Audio.Play方法的典型用法代码示例。如果您正苦于以下问题:C# Audio.Play方法的具体用法?C# Audio.Play怎么用?C# Audio.Play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio.Play方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Play a sound with the Audio class:
Audio myAudio = new Audio();
Console.WriteLine("Playing sound...");
myAudio.Play(@"c:\WINDOWS\Media\chimes.wav");
// Display time information with the Clock class:
Clock myClock = new Clock();
Console.Write("Current day of the week: ");
Console.WriteLine(myClock.LocalTime.DayOfWeek);
Console.Write("Current date and time: ");
Console.WriteLine(myClock.LocalTime);
// Display machine information with the Computer class:
Computer myComputer = new Computer();
Console.WriteLine("Computer name: " + myComputer.Name);
if (myComputer.Network.IsAvailable)
{
Console.WriteLine("Computer is connected to network.");
}
else
{
Console.WriteLine("Computer is not connected to network.");
}
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:27,代码来源:how-to--use-the-my-namespace--csharp-programming-guide-_2.cs
示例2: toFinal
public void toFinal(Audio qMusic, Audio qFinal, int qNumber)
{
if (qMusic.Playing == true && qNumber > 5) qMusic.Stop();
qFinal.Play();
ansLabel.ForeColor = Color.Black;
ansPic.Image = Form3.getPictureRes(ansLetter + "_final");
ansIfLocked = true;
}
示例3: AlarmStart
public void AlarmStart()
{
if (mAudio != null)
{
mAudio.Dispose();
}
mAudio = new Audio(mFileName);
mAudio.Ending += new EventHandler(mAudio_Ending);
mAudio.Play();
}
示例4: toCorrect
public void toCorrect(Audio qMusic, Audio qFinal, Audio qCorrect, Audio qWrong, int qNumber)
{
if (ansIfCorrect == true)
{
if (ansIfCorrect == ansIfLocked)
{
currentQuestion.ifAnsweredCorrectly = true;
if (qNumber == 5) qMusic.Stop();
if (qFinal.Playing == true) qFinal.Stop();
qCorrect.Play();
ansLabel.ForeColor = Color.Black;
for (int i = 1; i <= 11; i++)
{
if (i % 2 == 1)
{
ansPic.Image = Form3.getPictureRes(ansLetter + "_correct");
ansPic.Refresh();
Thread.Sleep(100);
}
else
{
ansPic.Image = Form3.getPictureRes(ansLetter + "_final");
ansPic.Refresh();
Thread.Sleep(100);
}
}
if (qMusic.Stopped && qNumber < 5) qMusic.Play();
}
else
{
qMusic.Stop();
if (qFinal.Playing == true) qFinal.Stop();
qWrong.Play();
for (int i = 1; i <= 11; i++)
{
if (i % 2 == 1)
{
ansPic.Image = Form3.getPictureRes(ansLetter + "_correct");
ansLabel.ForeColor = Color.Black;
ansPic.Refresh();
Thread.Sleep(250);
}
else
{
ansPic.Image = Form3.getPictureRes(ansLetter + "_normal");
ansLabel.ForeColor = Color.White;
ansPic.Refresh();
Thread.Sleep(250);
}
}
}
}
}
示例5: ReproduzirArquivo
public static void ReproduzirArquivo(string arquivo, bool excluir, bool isAsync)
{
Audio player = new Audio(caminhoTemp);
player.Play();
if (!isAsync)
{
while (player.CurrentPosition < player.Duration) { }
if (excluir)
{
File.Delete(caminhoTemp);
}
}
}
示例6: SetupMusic
private void SetupMusic()
{
backgroundMusic = Audio.FromFile( @".\\Music\\backgroundMusic.mp3" );
musicTimer.Interval = ( int )backgroundMusic.Duration * 1000;
musicTimer.Tick += new EventHandler( MusicTimerTick );
musicTimer.Enabled = true;
backgroundMusic.Play();
}
示例7: play
private void play(Audio audio)
{
audio.Stop();
audio.Play();
}
示例8: Run
public void Run()
{
form = new Form();
// �E�B���h�E�T�C�Y�ς̕����ǂ��ˁH
form.Icon = MafiaLoader.DefaultLoader.GetIcon("mafia.ico");
form.Text = Mafia.TITLE;
stages = new Stage[numStages];
for (int i = 0; i < numStages; i++)
{
if (i < Mafia.NUM_STAGES)
{
stages[i] = MafiaLoader.DefaultLoader.GetStage("stage" + i + ".stg");
}
else
{
stages[i] = MafiaLoader.DefaultLoader.GetStage(stagePath[i - Mafia.NUM_STAGES]);
}
}
if (stagePath.Length == 0)
{
currentStageIndex = 0;
}
else
{
currentStageIndex = Mafia.NUM_STAGES;
}
title = new TitleScene();
select = new SelectScene(stages, 0);
state = TITLE_SCENE;
video = new MafiaVideo(form, MessageBox.Show("�t���X�N���[���ŋN�����܂����H", "�m�F", MessageBoxButtons.YesNo) == DialogResult.Yes);
sound = new MafiaSound(form);
input = new MafiaInput(form);
try
{
bgm = new Audio(Application.StartupPath + "\\" + Mafia.RESOURCE_NAME + "\\mafia.mp3");
bgm.Ending += new EventHandler(bgm_Ending);
}
catch
{
}
form.Show();
timer = new FpsTimer(Mafia.FPS, false);
while (CheckState())
{
if (input.ShouldToggleFullscreen())
{
video.ToggleFullscreen();
}
switch (state)
{
case TITLE_SCENE:
// �C�F���h�E�Anull���ǂ����`�F�b�N���Ȃ���Ȃ��Ƃ͉�����
if (bgm != null && bgm.Playing)
{
bgm.Stop();
}
switch (title.Tick(input.GetCurrentTitleInput()))
{
case TitleScene.NONE:
if (timer.ShouldRender() && video.CheckDrawable())
{
video.Begin();
video.DrawTitleScene(title);
video.DrawFps(timer.GetCurrentFps());
video.End();
video.Present();
}
break;
case TitleScene.START_GAME:
select.CurrentStage = currentStageIndex;
state = SELECT_SCENE_TITLE;
break;
case TitleScene.EXIT:
form.Close();
break;
}
break;
case SELECT_SCENE_TITLE:
{
title.Tick(TitleInput.Empty);
int result = select.Tick(input.GetCurrentSelectInput());
switch (result)
{
case SelectScene.NONE:
if (timer.ShouldRender() && video.CheckDrawable())
{
video.Begin();
video.DrawTitleScene(title);
video.DrawSelectScene(select);
video.DrawFps(timer.GetCurrentFps());
video.End();
video.Present();
//.........这里部分代码省略.........
示例9: button4_Click
private void button4_Click(object sender, EventArgs e)
{
Audio music = new Audio("resources\\track.wma", true);
music.Play();
System.Threading.Thread.Sleep(5000);
music.Stop();
}
示例10: handler
IEnumerator handler(string new_str, string meta)
{
Debug.Log ("JSON PARSER");
var packet = JSON.Parse(new_str);
var metapacket = JSON.Parse(meta);
timer = 0;
//JSON PACKET PARSING
var packetType = packet["ptype"].Value;
text = packet["text"].Value;
var type = packet["type"].Value;
time = packet["time"].AsInt;
var angry = packet["emotions"]["anger"].AsFloat;
var disgust = packet["emotions"]["disgust"].AsFloat;
var happy = packet["emotions"]["happy"].AsFloat;
var sad = packet["emotions"]["sad"].AsFloat;
var scared = packet["emotions"]["scared"].AsFloat;
float[] emotions = new float[5];
emotions [0] = happy;
emotions [1] = sad;
emotions [2] = angry;
emotions [3] = scared;
emotions [4] = disgust;
Debug.Log ("text:" + text +
" time:" + time +
" angry:" + angry +
" disgust:" + disgust +
" happy:" + happy +
" sad:" + sad +
" scared:" + scared + "\n");
//JSON METADATA PARSING
//get all weight values of every key and average the non-zero values
for (int j = 8; j < 28; j++) {
blendshapes[j-8] = 0; //metadata file starts at 8 to skip initial name,id,age etc. metadata
var count = 0;
for (int i = 0; i < 5; i++) {
if(metapacket ["profiles"] [0] [j] [i].AsFloat * emotions[i] > 0){
blendshapes[j-8] = blendshapes[j-8] + (metapacket ["profiles"] [0] [j] [i].AsFloat * emotions[i]);
count++;
}
}
if(count >0){
blendshapes[j-8] = blendshapes[j-8] / count;
}
}
//debug log code
/*for (int i = 0; i < 20; i++) {
Debug.Log (blendshapes [i]);
}
*/
if (packetType == "snippet") {
Audio audio = new Audio ();
AudioSource source = gameObject.GetComponent<AudioSource> ();
if (type == "enhance") {
yield return StartCoroutine (audio.Play (text, true, source));
} else
yield return StartCoroutine (audio.Play (text, false, source));
}
}
示例11: tmr_CheckNotification_Tick
private void tmr_CheckNotification_Tick(object sender, EventArgs e)
{
try
{
//Check the web service for notifications.
Object[] notifInfo = Helper.service.getNotificationInfo(this.login);
if (((int)notifInfo[0]) == NotificationExists || ((int)notifInfo[0]) == NotificationApproved)//Notification Exists.
{
lbl_Notifications.Text = "Le technicien " + notifInfo[1].ToString()/* + " " + notifInfo[2] */+ " a besoin de l'aide:\n";
lbl_Notifications.Text += "Type de panne: " + notifInfo[3].ToString() + "\n";
lbl_Notifications.Text += "Panne: " + notifInfo[4].ToString() + "\n";
lbl_Notifications.Text += "Diagnostique:\n" + notifInfo[5].ToString();
NotifOn("images\\notification_warning.png");
if (!NotifSound || !NotifSound2)
{
Audio notify = new Audio("Data\\Notify.mp3");
notify.Play();
NotifSound = true;
NotifSound2 = true;
}
if ((bool)notifInfo[6] && !videolunched)
{
Thread.Sleep(2000);
btn_StartVideo_Click(null, EventArgs.Empty);
videolunched = true;
}
//if ((bool)notifInfo[6])
// MessageBox.Show("La video est prete.","RenderForm.tmr_CheckNotification");
//tmr_CheckNotification.Enabled = false;
}
else
{
lbl_Notifications.Text = "";
NotifOff("images\\notification_warning_Gray.png");
NotifSound2 = false;
if (!(bool)notifInfo[6] && videolunched)
{
videolunched = false;
ChangeVideoStateLabel("Démarrer");
btn_StartVideo_Click(null, EventArgs.Empty);
//NotifOff("images\\notification_warning_Gray.png");
}
}
#region Check for Messages from the technician
if (Helper.service.ExisteMsgFromTech(this.login))
{
Audio notify = new Audio("Data\\msg.mp3");
notify.Play();
string msg = Helper.service.ReceiveMsgFromTech(this.login);
//LoadRichTxt(msg,notifInfo[1].ToString());
LoadRichTxt(msg, "Abdelalim ZERKANI");
}
#endregion
}
catch (Exception x)
{
MessageBox.Show(x.ToString(), "RenderForm.tmr_CheckNotification");
}
}
示例12: useLF2
private void useLF2(ref bool ifLF, Audio musicLF, Audio soundLF, string st1, string st2, string st3,
System.Windows.Forms.Button buttonLF)
{
if (!ifLF)
{
ifLF = true;
currentQuestion.stopAllMusic();
musicLF.Play();
pictureActiveLF.Visible = true;
pictureActiveLF.Image = getPictureRes(st1);
pictureActiveLF.BringToFront();
pictureLF2.Image = getPictureRes(st2);
}
else
{
musicLF.Stop();
soundLF.Play();
pictureActiveLF.Visible = false;
pictureLF2.Image = getPictureRes(st3);
Thread.Sleep(1500);
currentQuestion.qMusic.Play();
buttonLF.Enabled = false;
}
}
示例13: UpdateQueues
static void UpdateQueues()
{
bool fromAlarm = false;
bool configVolumeChanged = false;
int baseVolume = 1;
int finalVolume = 0;
//ToteaMainConfig main_config = ToteaConfigManager.getMainConfig();
int configVolume = -1;
DateTime timeFlag = new DateTime();
while (true)
{
string newSound = "";
try
{
if (alarmEnable)
{
if (!fromAlarm)
{
if (backMusic != null)
backMusic.Pause();
if (soundHP != null)
soundHP.Pause();
if (soundMP != null)
soundMP.Pause();
fromAlarm = true;
timeFlag = DateTime.Now;
}
if ((!soundAlarm.Playing || soundAlarm.CurrentPosition >= soundAlarm.Duration) && (DateTime.Now - timeFlag).Minutes < 10)
{
soundAlarm.CurrentPosition = 0;
soundAlarm.Play();
}
}
else
{
if (fromAlarm)
{
soundAlarm.Stop();
if (backMusic != null && backMusic.CurrentPosition < backMusic.Duration)
backMusic.Play();
}
//Silece mode -> calculate new volume
if (buffer != null && (finalVolume == -10000 || (currentSounds[0] == "" && currentSounds[1] == "" && currentSounds[2] == "")))
{
Array samples = buffer.Read(0, typeof(Int16), LockFlag.FromWriteCursor, SAMPLE_FORMAT_ARRAY);
int goal = 0;
// average across all samples to get the goals
for (int i = 0; i < SAMPLES; i++)
{
goal += Math.Abs(Convert.ToInt32(samples.GetValue(i, 0, 0)));
}
goal = goal / SAMPLES;
//Normalize
goal = Math.Max(Math.Min(goal, MAX_IN_VOLUME), MIN_IN_VOLUME);
goal = (int)map(goal, MIN_IN_VOLUME, MAX_IN_VOLUME, MIN_OUT_VOLUME, MAX_OUT_VOLUME);
if (baseVolume <= 0)
baseVolume = (int)((float)baseVolume * 0.8f + (float)goal * 0.2f);
else
baseVolume = goal;
configVolume = -1;
}
//ConfigVolume changed
/*
if (configVolumeChanged = (configVolume != (configVolume = main_config.currentVolume)))
{
if (configVolume != 0)
finalVolume = (int)map(configVolume, 0, 100, baseVolume, MAX_OUT_VOLUME);
else
finalVolume = -10000;//Silence
Console.Title = String.Format("{1}% de {0} = {2}", baseVolume, configVolume, finalVolume);
}
*/
//Background music
if (backMusic == null || backMusic.CurrentPosition >= backMusic.Duration)
{
if (backMusic != null)
{
backMusic.Dispose();
backMusic = null;
}
if (queueLowPriority.Count > 0)
{
newSound = queueLowPriority.Dequeue();
currentSounds[0] = newSound;
backMusic = new Audio("Audio/" + newSound);
//.........这里部分代码省略.........
示例14: toBlankDD
public void toBlankDD(Audio qFinal, Audio DD2)
{
toBlank();
qFinal.Stop();
DD2.Play();
}