Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: play windows media player from tmemory stream



Permlink Replies: 5 - Last Post: Jan 10, 2017 9:45 AM Last Post By: roca robin
roca robin

Posts: 140
Registered: 9/10/06
play windows media player from tmemory stream
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 8, 2017 10:55 PM
time to surrender, I did what I can but it can't be found anywhere.

WindowsMediaPlayer1.URL := 'http://127.0.0.1:80/sample.mp4';

that plays the file from internet Stream,

does anyone knows how to play from a tmemory stream? or sendmessage to windows media player to play the tmemory stream?

i hope it's possible in delphi,

thank you

I write this code, but still there's no way I can't get it to work:

procedure FromMemToPlay_inWindowsMediaPlayer;
type TCopyDataStruct = packed record
dwData: DWORD;
cbData: DWORD;
lpData: Pointer;
end;
var
rStream: TResourceStream;
MyCopyDataStruct: TCopyDataStruct;
hTargetWnd: HWND;
ms:tmemoryStream;
begin
ms := tmemorystream.Create;
rStream := TResourceStream.Create(hInstance, pchar('fromMyResource'), RT_RCDATA);
rStream.Seek(0, soFromBeginning);
rStream.SaveToStream(ms);
rStream.Free;
ms.Position:=0;

hTargetWnd := FindWindow(nil,PChar('Windows Media Player'));
if hTargetWnd=0 then begin showmessage('Windows not Found 0'); exit; end;
with MyCopyDataStruct do
begin
dwData := 0;
cbData := ms.Size;
lpData := ms.Memory;
end;
SendMessage(hTargetWnd, WM_COPYDATA, Longint(Mutex), Longint(@MyCopyDataStruct));

end;

added snip code

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: play windows media player from tmemory stream [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 9:31 AM   in response to: roca robin in response to: roca robin
roca wrote:

WindowsMediaPlayer1.URL := 'http://127.0.0.1:80/sample.mp4';

that plays the file from internet Stream

What exactly is WindowsMediaPlayer1 declared as? That is not a native VCL
component. Is it a 3rd party component? An imported ActiveX control?

Have you tried using a "res:" URL with WMP's URL or FileName property?

res Protocol
https://msdn.microsoft.com/en-us/library/jj710218.aspx

If WMP supports "res:" URLs, it would be able to play the media directly
from your app's resource without you having to extract it first.

Otherwise, you would have to either:

1. extract the media to a temp file and then play that

2. run an HTTP server inside your app, such as with Indy's TIdHTTPServer
component, and have it return your media resource data when requested.

I write this code, but still there's no way I can't get it to work:

You can't pass a media file in memory to WMP across process boundaries using
a window message, not even WM_COPYDATA. Wherever did you get that idea?

--
Remy Lebeau (TeamB)
roca robin

Posts: 140
Registered: 9/10/06
Re: play windows media player from tmemory stream
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 2:17 PM   in response to: roca robin in response to: roca robin
What exactly is WindowsMediaPlayer1 declared as? That is not a native VCL
It's a Native VCL TMediaPlayer
component. Is it a 3rd party component? An imported ActiveX control?
It's from Delphi
Have you tried using a "res:" URL with WMP's URL or FileName property?
I will try,

I have tried this one too, using TEncoding but I don't know the exact solution,
...
...
rStream.SaveToStream(ms);
rStream.Free;
ms.Position:=0;

Lbuffer := ms.Memory;
SetLength(Lbuffer, ms.Size);
LEncoding:= nil;
DestEncoding:= TEncoding.UTF8;
LOffset := TEncoding.GetBufferEncoding(Lbuffer, LEncoding);
Lbuffer := LEncoding.Convert(LEncoding, DestEncoding, Lbuffer,
LOffset, Length(LBuffer) - LOffset);
LByteOrderMark := DestEncoding.GetPreamble;

However I will try to google that res you said

thank you
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: play windows media player from tmemory stream [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 3:52 PM   in response to: roca robin in response to: roca robin
roca wrote:

It's a Native VCL TMediaPlayer

TMediaPlayer only supports media in physical files and devices (CDROMs, etc),
not media in memory or resources.

I have tried this one too, using TEncoding but I don't know the exact
solution

Wy are you trying to use TEncoding? You are not dealing with textual data.

--
Remy Lebeau (TeamB)
roca robin

Posts: 140
Registered: 9/10/06
Re: play windows media player from tmemory stream [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 5:00 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
roca wrote:

It's a Native VCL TMediaPlayer

TMediaPlayer only supports media in physical files and devices (CDROMs, etc),
not media in memory or resources.

I have tried this one too, using TEncoding but I don't know the exact
solution

Wy are you trying to use TEncoding? You are not dealing with textual data.

--
Remy Lebeau (TeamB)

Wy are you trying to use TEncoding? You are not dealing with textual data.
Sorry, I thought differently... I test it with StreamToString with TEncoding

TMediaPlayer only supports media in physical files and devices (CDROMs, etc),
not media in memory or resources.
Yes, I understand, I''m new to this field

I tried the Windows Media Player, it work once but after I restart my computer it doesn't now.
I'll try to use FFmpeg
roca robin

Posts: 140
Registered: 9/10/06
Re: play windows media player from tmemory stream
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 2:45 PM   in response to: roca robin in response to: roca robin
thank you so much for the help
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02