Hi Steven,
I think I've been doing stuff similar to Morris, I got stuck however
because I seem to have no fastforwarding / rewind functionality in my
Windows Media Player control! I'm using the OBJECT tag to include the
WMP control in my web page to play streamed WAV files as illustrated
below.
* ASP.NET 2.0
* VS 2005
* Windows Media Player 10.00.00.3802 and 9.00.00.2980
______________________________
Requirements:
I want to build a web page with an integrated Audio Player that
-1- can play (streamed) WAV files
-2- has Play / Stop / Pause / FastForward / Rewind buttons
-3- prevents the user from downloading the WAV file
-4- does not cache the audio file
My first choice was the Windows Media Player control in internet
explorer, simply because I don't need support for browsers other than
IE, and it seems quite easy at first sight to add my own UI to the
player, controlling the WMP control with some VBScript for instance. It
should become part of an ASP.NET solution anyhow...
______________________________
I tried this:
An audioPlayer.aspx file that generates a web page with a Windows Media
Player control. The URL parameter of the WMP control is a
streamAudio.aspx file. The streamAudio.aspx file streams the WAV file to
the browser (streamAudio.aspx will pick the file name from the request
eventually). I thought this already solves -3- and -4- because the
client has no direct access to the WAV file, only to a binary stream.
This is the code:
===== audioPlayer.aspx =====
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>audioPlayer</title></head>
<body>
<form id="form1" runat="server">
<div>
<object id="Player" height="45" width="220"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param name="autoStart" value="False" />
<!--param name="uiMode" value="invisible" /<!-- hide later, when it
works... -->
<param name="URL" value="audioStream.aspx" />
</object>
<input type="BUTTON" name="BtnPlay" value="Play" onclick="StartMeUp()"
/>
<input type="BUTTON" name="BtnStop" value="Stop" onclick="ShutMeDown()"
/>
<input type="BUTTON" name="BtnForward" value="fwd" onclick="ffw()" />
<script type="text/vbscript">
<!--
Sub StartMeUp ()
form1.Player.controls.play()
End Sub
Sub ShutMeDown ()
form1.Player.controls.stop()
End Sub
Sub ffw()
If form1.Player.controls.isAvailable("FastForward") Then
MsgBox "found fastforward"
form1.Player.controls.fastForward()
Else
MsgBox "didn't find fastforward"
End If
End Sub
-->
</script>
</div>
</form>
</body>
</html>
===== audioStream.aspx =====
<%@ Page Language="VB" Src="~/audioStream.aspx.vb"
Inherits="MyNS.audioStream"%>
===== Code-behind page audioStream.aspx.vb =====
Imports Microsoft.VisualBasic
Namespace MyNS
Partial Public Class audioStream
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "audio/wav"
Response.WriteFile("C:\myfile.wav")
Response.End()
End Sub
End Class
End Namespace
______________________________
Result:
When I click the fwd button
on Windows XP SP2, WMP 10.00.00.3802:
all clicks: "didn't find fastforward"
on Windows 2000 advanced Server, WMP 9.00.00.2908:
first click: "found fastforward" and fast forwarding really works
all subsequent clicks: "didn't find fastforward"
______________________________
Questions:
[1] fastforward in WMP
Does anyone know why the fastforward is disabled? Is this problem caused
by my specific files (WAV files, but it also fails for mp3, and I heard
others complain even about WMV!), or is it caused by WMP? I mean, are
there some characteristics of audio files that make it impossible for
any audio player to fastforward them, or is this just a shortcoming
(bug!?) of Windows Media Player?
This makes me think WMP is unreliable and not the way to go. How can I
expect my customer to run WMP 10.00.00.2334.11.22.s.o.m.e.n.r.0.1.2.3 on
Windows XP SP2 with this and this and that, and nothing else because
otherwise his player will not be fully functional? It seemed like quite
a cool control initially but I'm starting to have some doubts now...
[2] Caching of streams
I'm not quite sure about the caching. If I stream the WAV file to the
client, is the stream cached somehow on the client? Simply put: If the
client closes all the browsers, and all sessions have expired, is there
any way that he can find and playback the audio on his machine (from tmp
internet files or whatever location)?
[3] What are the alternatives to realize the above in a reasonably
simple way: An audio player (preferably with customizable UI) that can
receive streamed WAV files (or possible a converted file format, if WAV
is not suitable), with play/pause/stop/fastforward/rewind functionality.
No Quicktime or Realplayer... Using .NET 2.0 and VB 2005 though!
Many Thanks in advance!
Guido
*** Sent via Developersdex
http://www.developersdex.com ***