Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to use play sound

how to use play sound

Scheduled Pinned Locked Moved ASP.NET
tutorialdesignquestionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyHelp
    wrote on last edited by
    #1

    I will like to play sound when the current page load. I found a code but when i run on my application. The sound didnt play but i hear sound like 'de' instead of my own wav sound. What wrong? Partial Class tutorial Inherits System.Web.UI.Page Dim mrdrreader As SqlDataReader Dim mycommand As SqlCommand Public Class SoundClass Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer ' name specifies the sound file when the SND_FILENAME flag is set. ' hmod specifies an executable file handle. ' hmod must be Nothing if the SND_RESOURCE flag is not set. ' flags specifies which flags are set. ' The PlaySound documentation lists all valid flags. Public Const SND_SYNC = &H0 ' play synchronously Public Const SND_ASYNC = &H1 ' play asynchronously Public Const SND_FILENAME = &H20000 ' name is file name Public Const SND_RESOURCE = &H40004 ' name is resource name or atom Public Sub PlaySoundFile(ByVal filename As String) ' Plays a sound from filename. PlaySound("c:/Inetup/wwwroot/fyp/sounds/newemail.wav", 0, SND_ASYNC) End Sub End Class Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SoundInst As New SoundClass() SoundInst.PlaySoundFile("c:/Inetup/wwwroot/fyp/sounds/newemail.wav") : :end class

    J 1 Reply Last reply
    0
    • L LovelyHelp

      I will like to play sound when the current page load. I found a code but when i run on my application. The sound didnt play but i hear sound like 'de' instead of my own wav sound. What wrong? Partial Class tutorial Inherits System.Web.UI.Page Dim mrdrreader As SqlDataReader Dim mycommand As SqlCommand Public Class SoundClass Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer ' name specifies the sound file when the SND_FILENAME flag is set. ' hmod specifies an executable file handle. ' hmod must be Nothing if the SND_RESOURCE flag is not set. ' flags specifies which flags are set. ' The PlaySound documentation lists all valid flags. Public Const SND_SYNC = &H0 ' play synchronously Public Const SND_ASYNC = &H1 ' play asynchronously Public Const SND_FILENAME = &H20000 ' name is file name Public Const SND_RESOURCE = &H40004 ' name is resource name or atom Public Sub PlaySoundFile(ByVal filename As String) ' Plays a sound from filename. PlaySound("c:/Inetup/wwwroot/fyp/sounds/newemail.wav", 0, SND_ASYNC) End Sub End Class Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SoundInst As New SoundClass() SoundInst.PlaySoundFile("c:/Inetup/wwwroot/fyp/sounds/newemail.wav") : :end class

      J Offline
      J Offline
      Jakob Farian Krarup
      wrote on last edited by
      #2

      Hi LovelyHelp :) You can't play a sound on the clientside (in the visitor's browser) in this way. This piece of code would play the sound on the server instead. The only way you can play a sound on the client side, is by embedding a soundfile in the webpage. This can be done using WAV, MP3, Flash or other products. Links:

      • http://www.tips-tricks.com/sound.asp[^]
      • http://www.webreference.com/js/column20/embed.html[^]

      Kind regards - Jakob :cool: Three kinds of people in the world: - Those who can count.. - Those who can't!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups