Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

C# - MP3s spelen op bepaalde tijdstippen

Pagina: 1
Acties:

  • abbastijn
  • Registratie: Augustus 2002
  • Laatst online: 02-11 15:46
Ik ben voor mijn stage aan de slag met een programma dat op bepaalde tijdstippen een MP3 moet afspelen. Het afspelen van de MP3's zelf lukt al wel, met winmm.dll. Ik heb ook al een Timer die om de seconde events triggert. Dat werkt allemaal.

Het probleem zit m in het verbinden van het spelen van de MP3 op het tijdstip. Als ik een break gebruik zie ik duidelijk dat alles netjes wordt gecalled, precies zoals wanneer ik de mp3 gewoon afspeel, hij speelt alleen gewoon niet! Geen exceptions, niets. Zie ik iets over het hoofd?

There's so much comedy on television. Does that cause comedy in the streets?


  • Reptile209
  • Registratie: Juni 2001
  • Laatst online: 14:47

Reptile209

- gers -

Probeer eens om in plaats van via die dll een shell execute van je mp3-tje te doen, om uit te sluiten dat het toch in je uiteindelijke aanroep zit. En post eens wat (relevante) code, misschien zie je wat over het hoofd.

Zo scherp als een voetbal!


  • abbastijn
  • Registratie: Augustus 2002
  • Laatst online: 02-11 15:46
Dat kan pas morgen, m'n code staat op de PC op m'n stage. Ik zal even wat code zoeken van waaruit ik dat MP3 aanroepen heb gebruikt.

There's so much comedy on television. Does that cause comedy in the streets?


  • abbastijn
  • Registratie: Augustus 2002
  • Laatst online: 02-11 15:46
Dit is een stukkie van de code (CodeProject).

Open en Play voor het initializen van de speler en het spelen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
        public void Open(string sFileName)
        {
            Pcommand = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
            mciSendString(Pcommand, null, 0, 0);
            isOpen = true;
        }

        public void Play(bool loop)
        {
            if (isOpen)
            {
                Pcommand = "play MediaFile";
                if (loop)
                    Pcommand += " REPEAT";
                mciSendString(Pcommand, null, 0, 0);
            }
        }


Die roep ik dus na elkaar aan als mijn variabele 'Tick' een bepaalde waarde heeft (1 tick per seconde).

There's so much comedy on television. Does that cause comedy in the streets?


  • farlane
  • Registratie: Maart 2000
  • Laatst online: 30-11 00:17
Misschien moet je even de return waarde van mciSendString controleren.

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • abbastijn
  • Registratie: Augustus 2002
  • Laatst online: 02-11 15:46
En bij die return value pointer (2e parameter van mciSendString) kan ik gewoon een string opgeven? Ik ben niet zo'n programmeer-crack, dus vergeef me mijn noobisch vraagjes... :)

There's so much comedy on television. Does that cause comedy in the streets?


  • Reptile209
  • Registratie: Juni 2001
  • Laatst online: 14:47

Reptile209

- gers -

Van de MSDN:
MCIERROR mciSendString(
LPCTSTR lpszCommand,
LPTSTR lpszReturnString,
UINT cchReturn,
HANDLE hwndCallback
);
Parameters

lpszCommand

Pointer to a null-terminated string that specifies an MCI command string. For a list, see Multimedia Command Strings.

lpszReturnString

Pointer to a buffer that receives return information. If no return information is needed, this parameter can be NULL.

cchReturn

Size, in characters, of the return buffer specified by the lpszReturnString parameter.

hwndCallback

Handle to a callback window if the "notify" flag was specified in the command string.

Return Values
Returns zero if successful or an error otherwise. The low-order word of the returned DWORD value contains the error return value. If the error is device-specific, the high-order word of the return value is the driver identifier; otherwise, the high-order word is zero. For a list of possible error values, see MCIERR Return Values.

To retrieve a text description of mciSendString return values, pass the return value to the mciGetErrorString function.
Bron: MSDN.

Op deze pagina vind je de mogelijke (non-zero) foutcodes die je functie terugstuurt als DWORD. Kijk daar eens naar, of pass de waarde door naar mciGetErrorString en bekijk 'm als tekst.

De return-string parameter kan je volgens mij idd null laten, omdat je geen antwoord van de functie nodig hebt.

Zo scherp als een voetbal!


  • abbastijn
  • Registratie: Augustus 2002
  • Laatst online: 02-11 15:46
Het is gelukt! Het lag aan het thread van waaruit ik het aanriep. Bedankt voor de suggesties! _/-\o_

There's so much comedy on television. Does that cause comedy in the streets?

Pagina: 1