CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2009
    Posts
    4

    MCI not playing certain files

    Hi,

    Im trying to create a Media Player in .NET, I use this code to open a file:
    mciSendString("open " & filename & " alias music", 0, 0, 0)

    and I get the filename with:
    filename = Chr(34) & tbxFilename.Text & Chr(34)

    But if I try to play a file with a ! or a ' in the name, it says there was a problem while initializing MCI.

    Is there a way I can play these files or do I have to rename them?

    Thx, Don

  2. #2
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: MCI not playing certain files

    I'm not certain exactly how that'd be fixed, but there's a chance that one of the two standard escaping methods will work: \[CHAR] or %(HEX VALUE). E.g: %20 = ' ', "\"Hello" = "Hello

    Also, If you're interested, I did a lot of work on a similar project a couple of years ago - PM me if you to have some of the source code.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  3. #3
    Join Date
    Jan 2009
    Posts
    4

    Re: MCI not playing certain files

    Hmm, I can't get it to work by %21 or \!

    Hmm, it seems it just can't play certain songs, I found a song with a ' in it and worked...
    Last edited by Don Sandros; January 4th, 2009 at 01:20 PM.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: MCI not playing certain files

    Either 1) Rename the file, or 2) Copy the file somewhere with a NEW name, and open that file.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jan 2009
    Posts
    4

    Re: MCI not playing certain files

    I tried renaming the file manually and then playing it, but this doesn't solve the problem. I just found out it has nothing to do with the filename...

  6. #6
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: MCI not playing certain files

    What format is the file in? Does it have some form of DRM protection?
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  7. #7
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: MCI not playing certain files

    Quote Originally Posted by Don Sandros View Post
    ...
    try
    Code:
    try
        filename = """" & tbxFilename.Text & """"
        mciSendString("open " & filename & " alias music", 0, 0, 0)
    catch ex as exception
        msgbox (ex.message)
    end try
    and tell what was the message error. It should give a clue on why it fails.
    [Vb.NET 2008 (ex Express)]

  8. #8
    Join Date
    Jan 2009
    Posts
    4

    Re: MCI not playing certain files

    Quote Originally Posted by javajawa View Post
    What format is the file in? Does it have some form of DRM protection?
    Thx, after saving the file again it worked So I think they were DRM protected

    (Is it possible to remove DRM with some kind of quick tool? Saving all my mp3's again will take lots of time and will reduce the quality of the sound...)

  9. #9
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: MCI not playing certain files

    Legally, no. And We're all bound by the AUP here...
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

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

Featured