?
Solved

Play Resource AVI in MediaPlayer

Posted on 2004-04-26
15
Medium Priority
?
892 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 750 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

850 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