AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Syntax SendMCICommand

Ein Thema von Dunkelbunt27 · begonnen am 22. Jul 2012 · letzter Beitrag vom 18. Aug 2014
 
Benutzerbild von Dunkelbunt27
Dunkelbunt27

Registriert seit: 10. Aug 2010
232 Beiträge
 
Delphi XE Professional
 
#28

AW: Syntax SendMCICommand

  Alt 25. Jul 2012, 16:19
Zitat:
Dann füge die neue Declaration auch in der Classe ein ups. hast du ja.
Ansonsten ja auch bei Destroy..
Naja, ist sie doch, oder?
EDIT: Hab dein Edit nicht gesehen, sorry

Das ist die MCIPlayer unit...
Delphi-Quellcode:
unit MCIPlayer;
interface

uses Windows, Messages, mmsystem, StrUtils, SysUtils, Dialogs;

type
   TMCIPlayer = class
   private
     { private-Deklarationen }
     command: PWideChar;
     return: array [0..255] of Widechar;
     resultSize: Integer;
   protected
     { protected-Deklarationen }
   public
     { public-Deklarationen }
     duration: Integer;
     paused: Bool;
     function getPosition(alias: string): Integer;
     procedure play(alias: string);
     procedure pausePlay(alias: string);
     procedure stop(alias: string);
     constructor Create(fileName: string; dtype: string; alias: string; autoplay: Bool);
     destructor Destroy(alias: string); override; {<<<<<<<<<<<}
   end;

implementation

constructor TMCIPlayer.Create(fileName: string; dtype: string; alias: string; autoplay: Bool);
 var
   lResult: cardinal;
 begin
  //Variablen initiieren
   paused := FALSE;
   resultSize := 255;

   // We want to play a File.
   command := PWideChar('open "' + fileName + '" type ' + dtype + ' alias ' + alias + ' wait');
   lResult := mciSendString(command, return, resultSize, 0);

   if lResult <> 0 then
   begin
     mciGetErrorString(lResult, return, 255);
     ShowMessage('MCI error:'  + return);
       duration := 0;
    end;

   // Calculate duration
    command := ('set mciplayer time format milliseconds wait');
    mciSendString(command, return, resultSize, 0);

   command := ('status mciplayer length wait');
    mciSendString(command, return, resultSize, 0);
    if (StrLen(return) > 0) then
       duration := StrToInt(return)
    else
   duration := 0;

   if autoplay then
       play;
end;

destructor TMCIPlayer.Destroy(alias: string);
 begin
   command := ('close '+ alias +' wait');
   mciSendString(command, return, resultSize, 0);
 end;

function TMCIPlayer.getPosition(alias: string): Integer;
 begin
    command := ('status '+ alias +' position wait');
    mciSendString(command, return, resultSize, 0);
   if (StrLen(return) > 0) then
        result := StrToInt(return)
     else
     result := 0;
end;

procedure TMCIPlayer.pausePlay(alias: string);
 begin
     paused := not paused;
    if paused then
     begin
        command := ('pause '+ alias +' notify');
       mciSendString(command, return, resultSize, 0);
     end else
     begin
        command := ('resume '+ alias +' notify');
       mciSendString(command, return, resultSize, 0);
     end;
 end;

procedure TMCIPlayer.play(alias: string);
begin
  command := ('play ' + alias + ' notify');
  mciSendString(command, return, resultSize, 0);
end;

procedure TMCIPlayer.stop(alias: string);
 begin
    command := ('stop '+ alias +' notify');
   mciSendString(command, return, resultSize, 0);
end;

end.
FG Dunkelbunt
"Wer zuletzt lacht hat den höchsten Ping"
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz