Results 1 to 39 of 39

Thread: Windows Mobile Application

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    20

    Windows Mobile Application

    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.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  3. #3
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    Hey,

    Which instructions are you following?

    Gary

  5. #5
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

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

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  7. #7
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Windows Mobile Application

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    Hi Pete,

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

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  11. #11
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Windows Mobile Application

    Project>Add Reference then browse for the dll
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  12. #12
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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 ?

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  14. #14
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    Not too sure what you mean, what path should I set to find the files?

  15. #15
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    Well this path:

    Code:
    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

  16. #16
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    I understand what you mean now, just trying to figure out the correct place to put them.

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  18. #18
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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?

  19. #19
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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:

    Code:
    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

  20. #20
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  21. #21
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    Hey,

    Are there no exceptions or error messages thrown?

    Can you post the exact code that you are using?

    Gary

  22. #22
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  24. #24
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Windows Mobile Application

    HI,
    just tried it and I can hear, but not see.

    Try this instead...



    Code:
     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
    Last edited by petevick; Apr 10th, 2009 at 02:47 AM.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  25. #25
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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:

    Code:
    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

  26. #26
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  27. #27
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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:

    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, "")
    Process.Start(info)
    End Sub
    
    End Class
    Gary

  28. #28
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    Thanks, it still cannot find the specified file, where exactly should it be sitting?

  29. #29
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    Hey,

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

    Code:
    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

  30. #30
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Windows Mobile Application

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  31. #31
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  32. #32
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  33. #33
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  34. #34
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

    And the MessageInterceptor

    Hope that helps!!

    Gary

  35. #35
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  36. #36
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  37. #37
    Member
    Join Date
    Oct 2008
    Posts
    57

    Re: Windows Mobile Application

    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.

  38. #38
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Windows Mobile Application

    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

  39. #39
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Windows Mobile Application

    Loads of tutorials here with code in C# and VB

    You can always use one of the many on-line translators to translate from c# to vb
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width