Discussion:
Read wmv into a memorystream, then play from windows media control
(too old to reply)
James Janke
2005-11-21 15:55:11 UTC
Permalink
Hi,

I have been struggling with this problem for months and finally broke
down and decided to post a question. I'm working with C#.NET, Windows
Media Player 10 control, and Windows Forms.

I need to read a wmv into a memorystream, then play the memorystream
from a WindowsMedia Player control embedded in a windows form
application. The problem is the windows media player control only
takes a URL as an input for a file. I need to read a file from memory.

Step 1. Read WMV into a MemoryStream object. DONE
Step 2. Decrypt WMV in MemoryStream object DONE
Step 3. Add memorystream handle to Windows Media Player Control ???

I have read about inheriting the ActiveX IStream interface and creating
a new class to handle this, no idea how to do that. I've also read
about UrlMonikers and Named pipes. I don't think this is a solution
for me.

http://tjworld.net/software/IMemoryStream/
This looks promising, but i have no idea how to implement this into the
Windows Media Control for windows forms.

I need some direction for this tough problem. Any help would be
greatly appreciated!

Thanks,

James
James Janke
2005-11-21 16:18:40 UTC
Permalink
I would like the end result to be something like this:

MyWinMediaControl.Stream = MyMemoryStream.Read(buffer, 0,
buffer.Length);
Alessandro Angeli [MVP::DigitalMedia]
2005-11-21 17:15:28 UTC
Permalink
Post by James Janke
MyWinMediaControl.Stream = MyMemoryStream.Read(buffer, 0,
buffer.Length);
Forget it, you can't.

However, WMP uses DirectShow and the private WM reader in
the DirectShow graph uses WMF. So you can any of the
following:

- create an async reader source filter to provide data from
a memory buffer and install Geraint's ASF parser to parse
the ASF stream read from you source filter (the Async sample
in the DirectShow SDK, part of the latest version of the
Platform/Windows SDK or of older versions of the DirectX
SDK, is exactly what you need to create your async reader)

- create a push source filter that uses the WMReader object
in the WMF SDK to parse the ASF read from an IStream that
wraps your memory buffer (the PushSource sample in the
DirectShow SDK is a good starting point for the push source
and the ReadFromStream sample in the WMF SDK shows how to
make the WMReader read from an IStream)

- create a deprecated WM source plugin for WMF to make WMF
read from an IStream (source plugins were documented in the
WMF7SDK but removed from the WMF9SDK because the support was
buggy)

- apply an in-memory patch to the WMF runtime to make
IWMReader::Open() behave like
IWMReaderAdvanced::OpenStream()

In all of the above techniques, you need to identify your
IStream or memory buffer using a custom URL syntax with a
custom protocol. In the 2 DirectShow scenarios, you will
need to register a custom protocol for DirectShow. In the
WMF scenario you will need to register a custom protocol for
WMF. The hack scenario does not need you to register the
custom procotol.

All of the above have been extensively discussed before,
here or in microsoft.public.win32.programmer.directx.video
(which is focused on DirectShow), even with samples (search
the newsgroup archives on groups.google.com). All require a
steep learning curve and are not possible in .NET without
really a lot of high-level InterOp or are not possible at
all.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
James Janke
2005-11-21 19:15:39 UTC
Permalink
Thanks for your response.

I guess its time to look into other options. That is way past my
knowledge.
Jeremy Noring
2005-11-22 21:41:06 UTC
Permalink
Post by James Janke
Thanks for your response.
I guess its time to look into other options. That is way past my
knowledge.
Before you throw in the towel, could you tell us what you're trying to
accomplish? Is there some reason you absolutely have to read a file from a
memory stream?

It might be that there's a different way of going about things, but without
knowing more about your project, it's hard to offer suggestions.
--
My Site (under construction): http://deepsea.no-ip.com/AV/
Loading...