mci SendString problems-VBForums
Results 1 to 4 of 4

Thread: mci SendString problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    9

    mci SendString problems

    After getting back to this project I have ignored for a few months, I have been trying to use mci SendString to play an mp3 file as background music. I declare the function in the usual manner, and then try to use "play", "stop" and "close" to start playback, but with no success. The program runs in debug mode with no errors, but the music simply does not play.

    Using VB2015, I declare the function in Module1 as public, and other vars to manipulate stuff are public as well. I thought at first it was a path problem (I set up a var to concatenate Application.StartupPath with a subfolder) but even trying to play a file right from "C:\temp" does not work.

    Does anyone have any copy/paste code that would work for this? Maybe I am missing something specific to VB2015? Or doing something else wrong? I cannot figure out what.

    The music is not supposed to play until the initial form has been popped down, and the initial play code is in the load event of Form2. It is supposed to be stopped by click events by buttons and/or labels on other succeeding forms that may or may not be loaded. I start the whole app from Sub Main, which loads Form1, and then when the player clicks a button to pop up Form2, that is when the music pays.

    I can't use PlaySound as this is used to play other sounds when buttons/labels are clicked or moused over.

    Thanks in advance for any useful advice.

  2. #2
    Lively Member
    Join Date
    Nov 2017
    Posts
    111

    Re: mci SendString problems

    I don't have a specific fix to your problem, but rather a suggestion.

    Your description of the flow of how this is supposed to work is a great example of a common issue I see posted here, and that is unnecessary testing complexity.

    You've got somewhat of a Rube Goldberg setup to get to where the functionality is supposed to happen only after a series of events, loads, concatenations, etc.

    Start a new project with just one form that runs at startup, with the start/stop/whatever buttons you need, and one hard-coded string to the full path of a file you want to play, add your playback module, and go from there. You may find that your playback code as it stands works fine, the problem lies elsewhere, and that you've been chasing the wrong issue all along.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,538

    Re: mci SendString problems


  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    9

    Re: mci SendString problems

    Quote Originally Posted by OptionBase1 View Post
    I don't have a specific fix to your problem, but rather a suggestion.

    Your description of the flow of how this is supposed to work is a great example of a common issue I see posted here, and that is unnecessary testing complexity.

    You've got somewhat of a Rube Goldberg setup to get to where the functionality is supposed to happen only after a series of events, loads, concatenations, etc.

    Start a new project with just one form that runs at startup, with the start/stop/whatever buttons you need, and one hard-coded string to the full path of a file you want to play, add your playback module, and go from there. You may find that your playback code as it stands works fine, the problem lies elsewhere, and that you've been chasing the wrong issue all along.
    OptionBase1, I took your advice, built a whole new test app from scratch, got it to run, and very carefully ported over the relevant code to the main app. It all works now. There must have been some subtle thing wrong that the IDE was not picking up.

    When in doubt, crawl, then stand, then walk.

    I'm surprised after 18 years or so of .NET development, there isn't an easier way to plug in background music. I guess MS expects everybody to learn DirectX or use this old DLL. Oh well.

    As an aside, I need to convert to game music to MP3 to save space. Audacity wants me to install the LAME encoder for this, from here:

    https://lame.buanzo.org/

    Are the EXE installers on this site safe? Has anyone here used them? Reason I ask is this site has big green download arrows for possible malware and some exclamations about how the downloads are all malware-free, it makes me a bit nervous, I have been burned by sites that look like this before. AV says the windows version is ok, but that is not 100 percent proof, just wondering if anyone else has used it and can give a thumbs up.

    Thanks again.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.