Search code examples
c#asp.netwmplib

WindowsMediaPlayer on Global.asax application_start


i have this basic code to play a mp3 file on a aspx page.

    WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
    player.URL = "file's url"
    player.controls.play();

now this works if i put it on a button's click event or something. But nothing happens if i put these codes to Application_Start event in Global.asax file.

What i am trying to achieve here is that, when someone loads the page, they don't start listening the song from the beginning, but start listening from the song's current time.


Solution

  • Ok, There is quite a bit wrong with this I don't know where to start.

    1) You are using vb script code in a browser and assuming the user has that control. This won't work on most browsers and most operating systems.

    2) Application on start does not know a user's state. At that point there is no user only the system process itself.

    You need to use some client side code such as javascript or flash. ASP.net cannot play music to a browser natively by itself, it just won't work.