2013-06-20 3 views
0

SoundPlayer 클래스를 사용하여 웨이브 파일을 재생하는 응용 프로그램이 있습니다. 그러나 IIS에서 응용 프로그램을 게시 할 때 파일이 재생되지 않습니다. 참조 windows.dll을 추가 한 SoundPlayer 클래스를 사용하려면 방해가 될 수 있습니까?클라이언트에서 .wav를 실행하는 방법. ASP.NET

public void PlaySound() 
    { 
     try 
     { 
      while (1 == 1) 
      { 
       List<string> distinctMusic = GetMusicFile.Distinct().ToList(); 

       for (int i = 0; i < distinctMusic.Count; i++) 
       { 
        player.SoundLocation = distinctMusic[i]; 
        player.Play(); 
        Thread.Sleep(GetMusicDuration[i] * 1000); 
        player.Stop(); 
       } 
       player.Dispose(); 
      } 
     } 
     catch (Exception e) 
     { 
      //log.LogTxt(e.ToString()); 
     } 
    } 

아무도 도와 줄 수 있습니까? Thx!

+0

이 링크를 참조하시기 바랍니다? –

+1

System.Media.SoundPlayer player = new System.Media.SoundPlayer(); – user1792343

+0

클라이언트 측에서 서버 측 재생 사운드를 혼동합니다. http://stackoverflow.com/questions/12342519/how-to-play-sound-by-clicking-button-in-asp-net/12342639#12342639 – Aristos

답변

1

asp.net에서 C#을 사용하여 클라이언트 측 (물론 Silverlight 제외)에서 사운드를 재생할 방법이 없습니다. javascript와 같은 클라이언트 측 기술을 사용해야합니다. 예를이를 위해

:
Playing audio with Javascript?
http://www.w3schools.com/html/html_sounds.asp

<audio controls height="100" width="100"> 
    <source src="horse.mp3" type="audio/mpeg"> 
    <source src="horse.ogg" type="audio/ogg"> 
    <embed height="50" width="100" src="horse.mp3"> 
</audio> 
1

는 HTML5 오디오를 제어 또는 내장 미디어 플레이어 컨트롤을 사용해야합니다 중 웹 페이지에서 소리를 재생합니다.

걸리는 방향은 Windows 응용 프로그램에서는 가능하지만 웹에서는 작동하지 않습니다.

다른 응답에서 언급 한 것처럼 자바 스크립트가 필요하지 않습니다.

http://www.w3schools.com/html/html5_audio.asp

참고 : 모든 HTML5 브라우저는 웨이브 파일 (IE 예를 들어)를 지원하지, 플레이어의 인스턴스를 생성하는 방법 호환성

http://en.wikipedia.org/wiki/HTML5_Audio

관련 문제