Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

How to Embaded a File in the Solution as an Embaded Resource??

Back to Forum: Tech Off
  • User profile image
    skynyrd

    Hi,
    On smartphone programing, it's easy when embaded a picture into the solution as an Embaded Resource.
    But, how to embaded a file (especially mp3 file) ?? and to use it like using picture file??

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

     //when using picture file, the code is like this
    System.Reflection.Assembly execAssem = System.Reflection.Assembly.GetExecutingAssembly();

    (I need to watch my language).picBox.Image = new System.Drawing.Bitmap(execAssem.GetManifestResourceStream(@"DeviceApplication2.0_point.bmp"));

     //drag the picture file "0_point.bmp" into the Solution,
     //and in the File Properties of the 0_point.bmp, need to change content fo the Build Action to "Embaded Resource"

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     
    anyone could help me, please~
    (my school homework deadline is approaching, > <)
    Thanks alot in advance.
    Ermin.
    betawave@gmail.com

  • User profile image
    skynyrd

    hey...
    it seems I got my own answer now.
    if I am wrong,  please correct me.

    if we want to embedded a audio file, it only works on .Wav file

  • User profile image
    Shark_M

    go to project properties and in Resources section, drag and drop the file, and   make sure its added as Embedded Resource in the Build Action on the file's properties

    that is all I think, then the rest is codeing, from ExecutingAssembly.GetRosurceStream(Myspace.ResourceName.Extension) , or GetResourceByName

  • User profile image
    Minh

    skynyrd wrote:
    hey...
    it seems I got my own answer now.
    if I am wrong,  please correct me.

    if we want to embedded a audio file, it only works on .Wav file

    If you're talking about the built-in System.Media.SoundPlayer class, then, yes, it only does .WAV at the moment.

  • User profile image
    skynyrd

    but my problem is when i use windows media control
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/creatingtheplayercontrolprogrammatically.asp

    i  used the code below to play file:

    +++++++++++++++++

    Player.URL = url;

    Player.controls.play();

    +++++++++++++++++

    but how to play from ExecutingAssembly.GetRosurceStream(Myspace.ResourceName.Extension) , or GetResourceByName??

    below is a PlaySound example playing embedded Wav
    http://eggheadcafe.com/articles/20030302.asp

    thanx a loooot

  • User profile image
    Minh

    I don't know how to make the Windows Medica control play a WAV resource, but use can use the following code to do that with the built-in SoundPlayer class:

                System.Reflection.Assembly execAssem = 
                    System.Reflection.Assembly.GetExecutingAssembly();
    
                string nameSpaceName = execAssem.GetName().Name;
                string resourceName = "ringin.wav";
    
                System.IO.Stream s = execAssem.GetManifestResourceStream(nameSpaceName + "." + resourceName);
    
                System.Media.SoundPlayer pl = new System.Media.SoundPlayer(s);
    
                pl.Play();
    
                s.Close();
    


    Peace, I'm out. Happy New Year!

  • User profile image
    skynyrd

    Hi, Happy New Year to all~

    The SoundPlayer Class woks on Windows application,
    but not works on Windows Mobile 5.0 application.

    And infact, I wish to play Mp3 file or Wma file,
    and SoundPlayer Class dose not support Mp3 file.  >""<

    thank u for replying, any suggest do a great help.

  • User profile image
    skynyrd

    Although this is not the ultimate way to solve my problem, but it helps for my work~

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_evtuv/html/ettskcopyingfilestotargetdevice.asp

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.