Einzelnen Beitrag anzeigen

Benutzerbild von Sunlight7
Sunlight7

Registriert seit: 17. Sep 2006
Ort: Sonnensystem, Zentral
1.522 Beiträge
 
Delphi 5 Standard
 
#17

Re: DSPack : Länge von Lied vor Abspielen herausbekommen

  Alt 18. Feb 2007, 20:23
Abend!

Du solltest Dateinamen in das 8+3 Format wandeln , da sonst MCI bei zu langen Dateinamen crasht.
Hier ein Auszug von meiner Komponente, welche MCI nutzt.

Delphi-Quellcode:
...

   CloseMedia;

   FIDString:='SMC'+IntToStr(Random(16777216));
   If UpperCase(ExtractFileExt(FileName))='.CDAthen
      goto OpenTrack;


OpenFile:
   // Nur im 8+3 Dateiformat öffnen, Dateienamen mit mehr als 64 Zeichen lassen MCI crashen!
   i:=mciSendString(PChar('open "'+SExtractShortFileName(FFileName)+'" alias '+FIDString), nil, 0, TSMCForm(SMCForm).Handle);
   If i<>0 then begin
      ShowErrorMessage(i);
      SetLastError(i);
      Exit;
   end;
   mciSendString(PChar('status "'+FIDString+'" length '), PC, 255, 0);
   FFrames:=StrToIntDef(PC, 0);
   mciSendString(PChar('status "'+FIDString+'" nominal frame rate'), PC, 255, 0);
   FFrameRate:=StrToIntDef(PC, 0) / 1000;
   Goto Resume;

   mciSendString(PChar('capability "'+FIDString+'" has video'), PC, 255, 0);
   FIsVideoDevice:=(PC='true');
   mciSendString(PChar('capability "'+FIDString+'" has audio'), PC, 255, 0);
   FIsAudioDevice:=(PC='true');

   // Test ob Audio im geladenen Media ist, falls dies ein Video ist
   // Achtung: Muß vor SetAudio sein !
   If FIsVideoDevice then begin
      mciSendString(PChar('status "'+FIDString+'" audio'), PC, 255, 0);
      FIsAudioDevice:=(PC='on');
   end;

   FFileName:=FileName;
   SavedMode:=smcNotReady;

   SendString('set', 'time format ms');
   If Assigned(FOnGetDisplayHandle) then FOnGetDisplayHandle(Self, FDisplayHandle);
   SetDisplayHandle(FDisplayHandle);

   // Video Größe
   If FIsVideoDevice then begin
      mciSendString(PChar('where "'+FIDString+'" source '), PC, 255, 0);
      s:=Copy(PC, 5, 255);
      If s<>'then begin
         For i:=1 to System.Length(s) do
            If s[i]=' then begin
               FVideoWidth:=StrToIntDef(Copy(s, 1, i-1), 0);
               FVideoHeight:=StrToIntDef(Copy(s, i+1, System.Length(s)-i), 0);
               Break;
            end;
      end;
      FDisplayRect:=Rect(0, 0, FVideoWidth, FVideoHeight);
   end;
   FDisplayWidth:=FVideoWidth;
   FDisplayHeight:=FVideoHeight;
   // Umgehen eines MCI Bug's bei .MP3 und .WMA
   If FIsVideoDevice then
      if (FVideoWidth<4) or (FVideoHeight<4) then FIsVideoDevice:=False;

   If Assigned(FOnSetDisplayRect) then try
      FOnSetDisplayRect(Self);
   except
   end;

   If FIsVideoDevice then SetDisplaySize(FDisplayRect, FStretchToWindow);
   If not FAutoPlay then UpdateDisplay;

   If not FPlayAudio then DisableAudio;
   If not FPlayVideo then DisableVideo;

   mciSendString(PChar('status "'+FIDString+'" length '), PC, 255, 0);
   FLength:=StrToIntDef(PC, 0);
   mciSendString(PChar('set "'+FIDString+'" seek exactly on'), PC, 255, TSMCForm(SMCForm).Handle);

   If FSpeed<>1000 then SetSpeed(FSpeed);

DoPlay:
   If FAutoPlay then Play;
...
Grüßle!
Windows: Ja - Microsoft: Nein -> www.ReactOS.org
  Mit Zitat antworten Zitat