0

I am very new at c# and visual studio and now i am learning all the tools. At first i tried adding background sound to my form. I added a wav file trhough resources and i changed it's build action to embedded resources so that i can "play" the .exe file without problems at any other pc.Then i wrote this and it worked.

namespace audio
{
    public partial class Form1 : Form
    {
        SoundPlayer sp = new SoundPlayer(Properties.Resources.back_sound);

        public Form1()
        {
            InitializeComponent(); 
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            sp.Play();
        }
    }
}

Now i want to play a video file with windows media player.I added it through COM components and i added it to my form.I can make it play any video just by adding the video file at the debug folder and write this.

private void button1_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.URL = "video.AVI";


        }

But as before i want to add it to my resources so that i can execute the .exe file to aby other pc and by this way, i cant

I tried with ( following the same pattern with the sound file)

AxWindowsMediaPlayer player = new AxWindowsMediaPlayer(Properties.Resources.video);

( and inside the button player.play();)

and

WindowsMediaPlayer player = new WindowsMediaPlayer(Properties.Resources.video);

( and inside the button player.play();)

but no luck.

Can anyone help me, please? Thanks in advance

UPDATE:

I tried a lot of things and nothing worked, so i thought that it would better to stream the videos directly from youtube. I went to COM components and i added to my form a SHOCKWAVE FLASH OBJECT. I took the url i wanted, i transformed it ( from www.youtube.com/watch?v=xxxxxxxxxxxx to www.youtube.com/v/xxxxxxxxxxxx) i added it to the movie section of the flash object. It is working but only on my computer. If i execute the .exe in any other pc it doesnt work. It says that System.IO.FileNotFoundException.

What can i do to make it work?

just_me
  • 11
  • 5
  • Select your video file in solution explorer then right click on it choose Properties and change its Build Action property(Content to Embedded Resource) – Mehmed Aug 14 '15 at 07:57
  • See this : [link](https://www.daniweb.com/software-development/csharp/code/258293/add-sound-file-into-resource-and-access-it-in-net-c) and this :[link](http://stackoverflow.com/questions/4125698/how-to-play-wav-audio-file-from-resources) – Mehmed Aug 14 '15 at 08:01

0 Answers0