PDA

Click to See Complete Forum and Search --> : Windows Mobile Application


nicols
Apr 8th, 2009, 07:37 AM
Hi, I am currently using VB to develop an application for Windows Mobile 6 SDK. I need to extract a video from a database and display using Wndows Media Player, but I am having problems accessing AxWindowsMediaPlayer from
the Windows Mobile application, does anyone have any ideas on this, it would be of great help????
Thanks.

gep13
Apr 8th, 2009, 09:34 AM
Hey,

Welcome to the forums!!

There is actually a Windows Mobile Development Forum here, which is where this question should get answered.

I will get a Moderator to move the thread for you.

What problems are you having? Are you getting any error messages?

Gary

nicols30
Apr 8th, 2009, 10:27 AM
Thanks, i'm not getting any errors its just following instructions i've addeda reference to the Media PLayer and should appear in the toolbox for use but this is'nt happenin. I'm starting to think it is already built within the mobile application and if so the problem is referencing it via the code to play videos.

gep13
Apr 8th, 2009, 10:56 AM
Hey,

Which instructions are you following?

Gary

nicols30
Apr 8th, 2009, 11:28 AM
The instructions I followed were to right-click on the toolbar, choose items, and check the Windows Media Player from the COM components. The media player should then be displayed on the toolbar. It works when using normal VB code but not when using a smart device. This leads me to believe the media player is built into the mobile application but if so how can I access it???

gep13
Apr 8th, 2009, 11:30 AM
Hey,

This may well come down to the fact that the Media Control component that you are wanting to use is not supported in the Compact Framework. Not everything that works on a PC will work on a Mobile Device.

I haven't personally played with doing this, but I am sure there is a solution out there, I will try and remember and have a google for it, and post back.

Gary

nicols30
Apr 8th, 2009, 11:32 AM
Thanks for your help it is much appreciated, it is a pice of coursework for my Masters degree and i'm kinda stuck with it at the minute.

Regards,

John.

petevick
Apr 8th, 2009, 01:04 PM
Hi,
You could try adding C:\windows\system32\wmp.dll as a reference for your project. ...

Dim player As New WMPLib.WindowsMediaPlayer()
player.URL = "<path of your file>"
player.settings.volume = 100
player.controls.play()

This courtesy of MSDN forums.

Alternately you could shell/shellexexute the file name, which would start media player for you.

Pete

nicols30
Apr 8th, 2009, 02:48 PM
Hi Pete,

Thanks for your response, but where do i add the reference ?

gep13
Apr 9th, 2009, 12:53 AM
Hey,

In your solution explorer, there should be a references folder, right click on that and click add reference.

In the window that opens up, browse to the dll that Pete pointed you to, and then you should be able to use the code that he has provided.

Hope that helps!

Gary

petevick
Apr 9th, 2009, 01:07 AM
Project>Add Reference then browse for the dll

nicols30
Apr 9th, 2009, 06:24 AM
Hi, thanks that worked I can now reference the player in the code, however i've added the following code to a button to pay the video but nothing happens.

Dim player As New WMPLib.WindowsMediaPlayer()
Dim lake As String = "C:\Users\nicols\Desktop\Goals1\Lake.wmv"
player.URL = lake
player.settings.volume = 100
player.controls.play()

Can you help further, thanks ?

gep13
Apr 9th, 2009, 06:27 AM
Hey,

Is that the path that you are trying to use?!?

If so, I don't see how this will work. That path is to a file that is on the Desktop of your machine, not on the file system of the Windows Mobile Device, so as such, the Media Player on the Windows Mobile Device will not be able to find it and play it.

Gary

nicols30
Apr 9th, 2009, 08:15 AM
Not too sure what you mean, what path should I set to find the files?

gep13
Apr 9th, 2009, 08:21 AM
Well this path:


C:\Users\nicols\Desktop\Goals1\Lake.wmv


Is on your desktop machine, right?

Your desktop isn't on the Mobile Device. I am assuming you are using the Emulator for testing your application, but that doesn't mean that the Mobile Device can access your desktop, it knows nothing about the Desktop.

Isn't, you either need to reference a file with respect to where the exe is running on the Mobile Device, or you need to access the file system on the Mobile Device.

When using the Emulator, click start, programs, then file explorer to see what I mean.

Gary

nicols30
Apr 9th, 2009, 09:18 AM
I understand what you mean now, just trying to figure out the correct place to put them.

gep13
Apr 9th, 2009, 09:31 AM
Consider this then....

Are you providing the video files with your application? If so, it would make sense for them to exist within the same folder as the exe for your application.

Or are you expecting users of your application to select the video file that they want to watch? If so, you will need to provide a mechanism for them to select the file.

Gary

nicols30
Apr 9th, 2009, 10:38 AM
I will be provideing video files with the application.
Ive tried copying the video file into the bin\Debug folder where the exe application is
but it still cannot find it, am I putting it in the correct place?

gep13
Apr 9th, 2009, 10:43 AM
Hey,

One way to do this is as follows:

1) Create a folder which will hold all of the video files
2) Add the video files to the solution (Add Existing Item) and put them in this folder
3) In the solution explorer, select the video file, and then look at the properties window for the file
4) Set the Copy to Output Directory property to Copy Always and the Build Action to content

Having done that, you should be able to reference the file relative to the exe, so you should be able to do this:


Dim player As New WMPLib.WindowsMediaPlayer()
Dim lake As String = "Lake.wmv"
player.URL = lake
player.settings.volume = 100
player.controls.play()


Hope that helps!!

Gary

nicols30
Apr 9th, 2009, 11:12 AM
I really thought that would have solved it, i've added the video as an existing item, but again when i click the play button on the form nothing happens, it seems as if it still can't find it.

gep13
Apr 9th, 2009, 11:18 AM
Hey,

Are there no exceptions or error messages thrown?

Can you post the exact code that you are using?

Gary

nicols30
Apr 9th, 2009, 03:44 PM
Hi, there are no error messages or exceptions just nothing happens, I probably have left something out, just not too familiar with this, here is the code.

Public Class Form1
Private Sub Playbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Playbtn.Click

Dim player As New WMPLib.WindowsMediaPlayer()
Dim lake As String = "Test.wmv"
player.URL = lake
player.settings.volume = 100
player.controls.play()

End Sub

End Class

Thanks again for your help it is mkuch appreciated.

John.

gep13
Apr 10th, 2009, 01:17 AM
Hey,

Can you try which a different file, maybe an mp3, or a different type of video file, it could be that the device is not able to play the video.

Can you try loading the video file with the Window Media Application on the device? Does this work? If it doesn't then it is a safe bet that the Media Player Control won't be able to either.

One other thing that you might want to do, is to use the full path to the video file, this can be done using:

http://msdn.microsoft.com/en-us/library/ms229654.aspx

One thing that I am not clear on though, is that I don't see how the code that has been suggested is going to make the control appear on the form surface, it doesn't add the control to the form's controls collection, so I think I must be missing something. I did a quick google, and everything that I can find uses the same code, so not sure what the code is doing under the surface.

Gary

petevick
Apr 10th, 2009, 02:43 AM
HI,
just tried it and I can hear, but not see.

Try this instead...



Dim strFile As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) & "\anthem.wmv"
Dim info As New ProcessStartInfo(strFile, "")
Process.Start(info)

replacing 'anthem.wmv' witht the name of your file.

The line
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase )
gets your current path so you can find the file.

Process.start shells the file, which should start WMP

OpenNetCF provide an interface to play videos, but I am assuming you can't use 3rd party controls

Pete

gep13
Apr 10th, 2009, 02:52 AM
Ah, now that is something that I didn't think to try :) I am guessing that would be the same as me.

I tried to do this:


Me.Controls.Add(player)


But this gave me an error, saying that it couldn't convert it to a control. I haven't read up on the wmp.dll, but I am assuming that this is by design.

Gary

nicols30
Apr 10th, 2009, 05:46 AM
Hi, almost got it, it is invoking the media player on the device but saying the system cannot find the specified file, I am using the follwing code

Public Class Form1
Private Sub Playbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Playbtn.Click
Dim strFile As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) & "\Test.wmv"
Dim info As New ProcessStartInfo(strFile, "\Test.wmv")
Process.Start(info)
Dim player As New WMPLib.WindowsMediaPlayer()
Dim lake As String = "\Test.wmv"
player.URL = lake
player.settings.volume = 100
player.controls.play()

End Sub

End Class

Can you tell me what I am doing wrong,

Thanks John.

gep13
Apr 10th, 2009, 05:50 AM
Hey,

If you are using the code that Pete suggested, then you don't need the MediaPlayer code anymore.

And in terms of using Process.Start, you are appending Test.wmv twice, which is not required.

Instead, the code should look like this:


Public Class Form1
Private Sub Playbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Playbtn.Click
Dim strFile As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) & "\Test.wmv"
Dim info As New ProcessStartInfo(strFile, "")
Process.Start(info)
End Sub

End Class


Gary

nicols30
Apr 10th, 2009, 05:56 AM
Thanks, it still cannot find the specified file, where exactly should it be sitting?

gep13
Apr 10th, 2009, 06:04 AM
Hey,

Can you step through the code, and set a break point on this line:


Dim info As New ProcessStartInfo(strFile, "")


What are the contents of strFile?

With that in hand, use the File Explorer on the Mobile Device to ensure that the file is located where you are telling the application it should be.

Gary

petevick
Apr 10th, 2009, 08:20 AM
Have you set the properties of your file lake.wmv to always copy to the device

The messages suggest that the file you want is either not on the device, or certainly not in the folder you are expecting it to be

Pete

nicols30
Apr 10th, 2009, 08:38 AM
Hey guys, finally got the video to play thanks very much for your help. Must crack on with the rest of the application, I am sending an SMS from the cellular emulator to the device which in turn will invoke the video, can you give me any pointers in simulating SMS and indeed adding functionality to them?
Thanks again for your help on this I would've been lost without it.

John.

gep13
Apr 10th, 2009, 08:41 AM
Hey,

You can simulate an incoming SMS message by simply having the emulator send a text to itself.

While in the emulator, start a new message, and text the following number:

14250010001

And the text will be sent and come into itself.

Hope that makes sense!!

Gary

nicols30
Apr 10th, 2009, 08:54 AM
yeah already got the emulator sending a text to the application just have to write some code to sort of intercept the message so that it is actually the incoming message that kicks off my application.
I am trying to stimulate a video alert being sent by an SMS (Goal in a football match), the idea being when the device receives the message the user will then be given the option of watching the video.

gep13
Apr 10th, 2009, 08:59 AM
Ah ok, I see what you are after, have a look at the following:

http://www.dotnetfordevices.com/snippets/12.html

It is a very good series of WebCasts that builds up a full line of business application for a Mobile Device, which includes intercepting incoming text messages and creating code that acts on the contents of that message.

Specifically, you are going to want to look at the following:

Microsoft.WindowsMobile.PocketOutlook.MessageInterception (http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.messageinterception.aspx)

And the MessageInterceptor (http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.messageinterception.messageinterceptor.aspx)

Hope that helps!!

Gary

nicols30
Apr 10th, 2009, 09:04 AM
Sounds good, i'll get cracking with it right now, hopefully i won't have to bother you again, but I can promise nothing haha.

John.

gep13
Apr 10th, 2009, 09:07 AM
Ha Ha, no worries, everyone here is happy to help, and 9 times out of 10 you learn something new when you are helping out other people, so it's all good.

Feel free to post back with other questions as well. If this question has been answered though, remember to follow the links in my signature to close it off, and you can always start another thread which has a specific question.

Gary

nicols30
Apr 11th, 2009, 11:37 AM
Hi again, most of the webcasts here http://www.dotnetfordevices.com/snippets/12.html

are for C# do you know were I canfind some for VB?

John.

gep13
Apr 11th, 2009, 12:02 PM
Hey,

I am not aware of any of the webcasts being made fot VB, but I seem t rememebr that there was source code available though.

Try not to let the fact that it is in C# put you off, it if the classes that are being used that's important, not the language. once you know how to do it, you can find out how to write it in VB.

Gary

petevick
Apr 12th, 2009, 01:09 AM
Loads of tutorials here (http://msdn.microsoft.com/en-us/netframework/bb495180.aspx) with code in C# and VB

You can always use one of the many on-line translators to translate from c# to vb