Results 1 to 7 of 7

Thread: Problem Playing Video

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Problem Playing Video

    Hi, I'm using VB.NET 2005 and I can't seem to play any video file that is stored on my computer. I'm using WindowsMediaPlayer but it's not working. Here is my code that is not working:

    Private Sub PlayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayButton.Click

    'This should play the video file but is not working
    MediaPlayer1.URL = My.Application.Info.DirectoryPath & "Resources\video.wmv"
    MediaPlayer1.Ctlcontrols.play()


    I will appreciate your help.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Problem Playing Video

    My.Application.Info.DirectoryPath returns a path with no "\" at the end.. you need to add it in the next part of your string.. as so:

    MediaPlayer1.URL = My.Application.Info.DirectoryPath & "\Resources\video.wmv"

  3. #3
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Problem Playing Video

    Does it give you any errors? Have you verified that
    My.Application.Info.DirectoryPath & "Resources\video.wmv"
    gives you the correct path to the file?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Re: Problem Playing Video

    Thanks Kleinma. I had the "\" before but it did not work. I've tried it again but it still won't do anything. When I remove the file extension "wmv" then it gives me an alert message saying that "the file your are attempting to play has an extension that does not match the file format. Playing the file may result in unexpected behavior."

    When I add the file extension the alert disappears but nothing is happening.




    Quote Originally Posted by kleinma
    My.Application.Info.DirectoryPath returns a path with no "\" at the end.. you need to add it in the next part of your string.. as so:

    MediaPlayer1.URL = My.Application.Info.DirectoryPath & "\Resources\video.wmv"

  5. #5
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Problem Playing Video

    Have you confirmed My.Application.Info.DirectoryPath & "\Resources\video.wmv" is actually pointing to the directory that you expect?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Re: Problem Playing Video

    Hello mpdeglau:

    The video file is in the Resouces folder. It should have read ... &"\Resources\video.wmv"
    There is no error message but it still won't play. I've even imported a VB6 sample file that uses MediaPlayer and converted the file to VB.Net but the new file will not play at all. No error whatsoever.


    Quote Originally Posted by mpdeglau
    Does it give you any errors? Have you verified that
    My.Application.Info.DirectoryPath & "Resources\video.wmv"
    gives you the correct path to the file?

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Problem Playing Video

    Quote Originally Posted by bulungu
    Hello mpdeglau:

    The video file is in the Resouces folder. It should have read ... &"\Resources\video.wmv"
    There is no error message but it still won't play. I've even imported a VB6 sample file that uses MediaPlayer and converted the file to VB.Net but the new file will not play at all. No error whatsoever.

    is the resources folder off the BIN\debug folder? because that is where it is going to look for the file.

    for example, if your project files are located at "C:\myprojects\wmplayer\"

    your exe is compiled to "C:\myprojects\wmplayer\bin\debug"

    so your file would need to be located at

    "C:\myprojects\wmplayer\bin\debug\Resources\video.wmv"

    confirm that it is in the correct place.

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