Solved

Play Resource AVI in MediaPlayer

Posted on 2004-04-26
15
885 Views
Last Modified: 2011-10-03
Hi.

I've got a form, onto which I have placed a MediaPlayer object.  I have created an RC file and compiled this into a RES file.  This RES file now holds an AVI file that I want to play with the MediaPlayer.

I've seen some solutions to this that involve saving the file so that you can open it directly from disk, or other solutions that can play a resource file as if using the windows "OPEN" command (opening the AVI in a seperate window - the associated AVI player), and neither of these solutions are any good to me.

I've been a Delphi programmer for many years now and am quite suprised by how difficult this task seems to be - surely I'm mistaken!

If I were to perform this task in Delphi, I would simply use the ResID or ResName property of the MediaPlayer (TAnimate, in the case of Delphi), and everything else is automatically done.

How can I play a compiled AVI resource, with a MediaPlayer on the form?

Example code would be appreciated.

Many thanks,

MoonCalf.
0
Comment
Question by:MoonCalf
  • 10
  • 5
15 Comments
 
LVL 28

Expert Comment

by:Ark
ID: 10923659
Hi

For external resources I used:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long

Private Const WM_USER = &H400
Private Const ACM_OPEN = (WM_USER + 100)
Private Const ACM_PLAY = (WM_USER + 101)
Private Const ACM_STOP = (WM_USER + 102)
Dim hModule As Long

Private Sub Command1_Click()
   hModule = LoadLibrary("shell32.dll")
   Call SendMessage(Animation1.hWnd, ACM_OPEN, hModule, ByVal 150&)
   Call SendMessage(Animation1.hWnd, ACM_PLAY, -1, ByVal 0&)
End Sub

Private Sub Command2_Click()
   Call SendMessage(Animation1.hWnd, ACM_STOP, 0, ByVal 0&)
   Call SendMessage(Animation1.hWnd, ACM_OPEN, 0, ByVal 0&)
   FreeLibrary hModule
End Sub

Private Sub Form_UnLoad()
   Call SendMessage(Animation1.hWnd, ACM_STOP, 0, ByVal 0&)
   Call SendMessage(Animation1.hWnd, ACM_OPEN, 0, ByVal 0&)
   FreeLibrary hModule
End Sub
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10925991
Hi Ark.

Firstly, I'm not using an external resource (DLL or such) - I'm compiling the RES file into the executable.

Secondly, how does the use of "Animation1" relate to the use of a MediaPlayer component dropped onto a form?

Could you please make this comment relevant to the question.

Thank you,

MoonCalf.
0
 
LVL 28

Expert Comment

by:Ark
ID: 10926036
Sorry if I misunderstood your question, but AFAIK TAnimate(Delphi) = Animation control (VB, MS Common control 2)
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:MoonCalf
ID: 10926297
I'll give that a go.

Ta.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926323
Ark - thanks for that, but it's not made a spot of difference.  I still don't know how to assign a resource to the control.  I've created an OCX version of the Delphi TAnimate control and I'm about to test that in VB.

I'll let you know how I get on.  (I'll obviously want to delete this question if this is the solution.)

Thanks again,

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926383
Bugger.

That didn't work.  Still need an answer to the question.

Thanks,

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926384
Bugger.

That didn't work.  Still need an answer to the question.

Thanks,

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926385
Bugger.

That didn't work.  Still need an answer to the question.

Thanks,

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926386
Bugger.

That didn't work.  Still need an answer to the question.

Thanks,

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10926390
Oops!
0
 
LVL 28

Accepted Solution

by:
Ark earned 250 total points
ID: 10933987
Hi
Did you try

   Call SendMessage(Animation1.hWnd, ACM_OPEN, App.hInstance, ByVal 101&) 'where 101 is ResID
   Call SendMessage(Animation1.hWnd, ACM_PLAY, -1, ByVal 0&)
0
 
LVL 28

Expert Comment

by:Ark
ID: 10934000
PS
You can have a look on my sample at http://www.freevbcode.com/ShowCode.Asp?ID=3185 for playing AVI without controls.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10947686
Thanks Ark, but I'm having problems getting this to work.  I know this is going to change things, but I think the reason I'm having problems is that the animation component seems unhappy with WMV files.  (It was an AVI but was about 1/2 a gig in size - compressing to a WMV makes it about 2.5 meg!)

Any ideas?

MoonCalf.
0
 
LVL 1

Author Comment

by:MoonCalf
ID: 10959837
Is that a no?

MoonCalf.
0
 
LVL 28

Expert Comment

by:Ark
ID: 10981711
Sorry, I still can not get it worked with compressed AVI :(
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 90
Macro: print each sheet to pdf using ExportAsFixedFormat 11 53
VBA filters 2 65
VB6 - Compare and highlight cell not the same 3 53
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question