How to add a sound file to a resource and play it in ASP.NET
This article introduces the relevant knowledge of "how to add sound files to resources and play them in ASP.NET". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The details are as follows:
1. The way to add resources is as follows:
2. Form2.cs is as follows:
/ Any source code blocks look like this//using System.Reflection;using System.IO;using System.Resources;using System.Media;using System.Diagnostics;namespace Yournamespace {public partial class Form2: Form {public Form2 () {InitializeComponent ();} private void Form2_Load (object sender, EventArgs e) {Assembly assembly; Stream soundStream; SoundPlayer sp; assembly = Assembly.GetExecutingAssembly (); sp = new SoundPlayer (assembly.GetManifestResourceStream ("Yournamespace.Dreamer.wav")); sp.Play () } / * SoundPlayer sp = new SoundPlayer (global::WindowsApplication1.Properties.Resources.yoursoundfilename); * / "how to add sound files to resources and play them in ASP.NET" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!