Play audio files from aspx page

Discussion in 'ASP.NET 2.0' started by surfsUP, May 17, 2007.

  1. Hi, I want to play audio files (mp3, m4a) from an ASP.NET 2.0 page by clicking on a linkButton control. Can you help with the correct syntax, and can I test it from my development machine (XP tablet PC) using my test environment IIS, VS.NET2005? Many thanks.
     
  2. You will have to use a third party server control to play mp3's.
    See: http://www.codeproject.com/aspnet/MP3PlayerControl.asp

    You can set Console attribute of the control to 'false' to hide the UI and set the following on button click :
    (Assuming PseudoMP3_1 is the control ID)

    PseudoMP3_1.Src = 'Yoursong.mp3'
    PseudoMP3_1.Stream = True
    PseudoMP3_1.AutoStart = True

    Sample on DASP server daspstaff00.web120.discountasp.net/Mp3/default.aspx

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (vvsharma) : 5/17/2007 7:53:11 PM GMT
     
  3. Thank you Vikram for helping me. My experience is more on creating DB?s and .NET data access layer components database business sites? playing music and soon videos is all new to me.
    </o:p>
    I am using VisualStudio.NET2005. I have loaded .NET Framework v1.1 on my developer PC (it is a requirement of the PseudoEngine.PseudoMP3 downloaded). Following your code I created a test page w/ this click event - but not does not play music:
    </o:p>
    protected void linkSong1_Click(object sender, EventArgs e)</o:p>
    {</o:p>
    PseudoEngine.PseudoMP3 PseudoMP3_1 = new PseudoEngine.PseudoMP3();</o:p>
    PseudoMP3_1.Src = "01 Box of Pearls.mp3";</o:p>
    PseudoMP3_1.Stream = true;</o:p>
    PseudoMP3_1.AutoStart = true;</o:p>
    }</o:p>
    }
    </o:p>
    The code runs without errors, and in debug mode the properties seem to set properly. Am I missing something? Do I need other software on my developer machine for the code to play music? Flash? Your help greatly appreciated.
    </o:p>
    Thx
    jim
    </o:p>
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    Though i don't have much experience, most have told me that Flash streaming is quite simple to implement too.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Hi Vikram and Bruce, I?ve been struggling to understand how to interface with the PseudoEgine and the PseudoMp3.dll contained in the solution posted on The Code Project.


    Could you post code for the sample app you ghave a link to http://daspstaff00.web120.discountasp.net/Mp3/default.aspx ? I?m trying to achieve the same functionality within my DASP site using the PseudoMp3.dll as I believe you have done in the sample.
    </o:p>
    My current status is - my solution references the PseudoMp3.dll and sets properties based on your example. It compiles and runs but does not play music. I need help to properly call the dll, or may be missing resources or have incomplete configuration. Appreciate you help. </o:p>

    thx
    jim
     
  6. Download Link : Click here

    Upload an Mp3 file and replace [PseudoMP3_1.Src = 'Yoursong.mp3'-Default.aspx.vb] with the appropriate mp3 file name.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (vvsharma) : 5/23/2007 1:16:43 AM GMT
     
  7. Thanks Vikram! It?s working great on my development machine, I?ve not yet promoted to DASP host.Down the road I want to learn more about the shockwave component, for example somehow trapping an event that a song has finished playing, etc..
    </o:p>
    Again thank you for the help on getting this up and running
    </o:p>
    </o:p>
    Jim
     
  8. What i do is





    I have the mp3 uploaded in music folder under my project, and have the webpage.cs created under the root. and


    this is the code i have.


    PseudoMP3_1.Src = @"\music\"+song + ".mp3";


    PseudoMP3_1.Stream = true;


    PseudoMP3_1.AutoStart = true;
    Still doesnt work.
     
  9. Even copying the project as it is not working for you?May be you have the code at the wrong place on your page?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  10. I was able to play MP3?s using the embed statement on my DiscountASP aspx pages. For example:
    </o:p>
    <EMBED src="SoundFiles/ThePinkPanther.mp3" autoStart="TRUE" hidden="FALSE"/>
    </o:p>
    Admittedly, the keywords ?autostart? and ?hidden? will throw compiler errors, but they work just fine anyway.
    </o:p>
    The ?hidden? keyword hides the player if true, which means folks can?t turn off the sound. Might not want to do that.
    </o:p>
    You can also play <st1:place w:st="on">MIDI files too, e.g., ?ThreeStooges.mid?.
    </o:p>
    Good luck,
    </o:p>Lar
     
  11. pod

    pod

    I need to play a part of my mp3 file. just 30 sec. or something like that. can I do it with pseudomp3?
     
  12. Why not to use a standard MS component? We have implemented audio preview on our http://www.BestRussianBuy.com site by putting this MS MediaPlayer component code into HTML page:<SUB>





     

Share This Page