Autor Beitrag
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: So 07.05.06 13:06 
Hallo zusammen!

Ich bin gerade an einem Projekt bei dem ich auf den Windwos Media Encoder zugreife. Ich hab zwar das SDK dazu, aber leider gibt es da keine Beispiele für Delphi.

Ich erzeuge zur Laufzeit einen Encoder vom Typ TWMEncoder. Mein Problem ist jetzt dass ich von diesem das OnStateChange Ereignis brauche. Allerdings:

1. Weiß ich nicht wie ich das machen soll
2. Hab ich es nur als VB.Net Code

Ich will jetzt nicht dass mir jemand den ganzen Code übersetzt, dass sollte ich eigentlich selber hinbekommen, ich weiß nur wie gesagt nicht so richtig wie ich das ganze anstellen soll.

Ich hoffe mal ihr wisst was ich meine.

Ich habs jetzt mal so versucht (und hoffe mal dass es nicht kompletter Schwachsinn ist), aber das Programm läuft so leider nicht.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Encode;
var Encoder : TWMEncoder;
    ...
begin
 ...
 //wenn ich diese Zeile weglasse, dann läuft das Programm aber das OnStateChange Ereignis natürlich nicht...
 Encoder.OnStateChange := MyOnStateChange;
 Encoder := TWMEncoder.Create(self);
 ...
end;

procedure TForm1.MyOnStateChange(ASender: TObject; enumState: TOleEnum);
begin
 ShowMessage(TimeToStr(Now));
end;




ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
   
Private Sub Encoder_OnStateChange(ByVal enumState As WMEncoderLib.WMENC_ENCODER_STATE) Handles glbEncoder.OnStateChange

        '****************************************************************************************
        ' Purpose: Traps the encoder RunState to evaluate and set a variety of variables.
        '
        ' Parameters: enumState (WMENC_ENCODER_STATE) The current encoder run state
        '
        ' Return Value: None
        '
        '****************************************************************************************

        Dim strRunState As String

        If enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_STARTING Then

            strRunState = "Encoder Starting"

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING Then

            If glbTwoPassEncoding = True Then
                If glbPassNumber = 1 Then
                    strRunState = "Encoder Running Pass 1 of 2 (No Preview)"
                Else
                    strRunState = "Encoder Running Pass 2 of 2"
                End If
            Else
                strRunState = "Encoder Running Pass 1 of 1"
            End If

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_END_PREPROCESS Then

            strRunState = "Encoder End Preprocess"
            glbPassNumber = 2

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSING Then

            strRunState = "Encoder Pausing"

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED Then

            strRunState = "Encoder Paused"

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPING Then

            strRunState = "Encoder Stopping"

        ElseIf enumState = WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED Then

            strRunState = "Encoder Stopped"
            If glbboolBatchComplete = True Then
                strRunState = "Batch Complete"
                StatusBarPanel_PercentComplete.Text = "Ready"
                Timer_PercentComplete.Enabled = False
                sEnableButtons(False)
                sCountBatch()
            End If

            sRemoveSrcGrpColl()

            glbboolStartNext = True

        End If

        StatusBarPanel_EncoderRunState.Text = strRunState

    End Sub

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart