Solved

Play Resource AVI in MediaPlayer

Posted on 2004-04-26
15
883 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 27

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 27

Expert Comment

by:Ark
ID: 10926036
Sorry if I misunderstood your question, but AFAIK TAnimate(Delphi) = Animation control (VB, MS Common control 2)
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 27

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 27

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 27

Expert Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 57
message box in access 4 46
Using an encrypted  value to decrypt and display contents in vb6 9 51
how to Classify of email (pdf attachments) 7 32
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now