?
Solved

Play Resource AVI in MediaPlayer

Posted on 2004-04-26
15
Medium Priority
?
890 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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