Code: Alles auswählen.
CLASS z_cl_media DEFINITION INHERITING FROM cl_gui_control.
PUBLIC SECTION.
TYPE-POOLS cntl .
METHODS constructor IMPORTING parent TYPE REF TO cl_gui_container.
METHODS dispatch REDEFINITION.
METHODS setdatasource IMPORTING filename TYPE string.
ENDCLASS.
CLASS z_cl_media IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
clsid = 'MediaPlayer.MediaPlayer'
parent = parent
lifetime = 2
EXCEPTIONS
OTHERS = 1.
ENDMETHOD.
METHOD dispatch.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD.
METHOD setdatasource.
CALL METHOD set_property
EXPORTING
property = 'FileName'
value = filename.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD.
ENDCLASS.
"-Variables———————————————————
DATA ref_media TYPE REF TO z_cl_media.
"-GUI—————————————————————
SELECTION-SCREEN BEGIN OF BLOCK media.
PARAMETERS pa_dummy(1).
SELECTION-SCREEN END OF BLOCK media.
"-Main————————————————————–
AT SELECTION-SCREEN.
IF ref_media IS INITIAL.
CREATE OBJECT ref_media
EXPORTING
parent = cl_gui_container=>screen9
EXCEPTIONS
OTHERS = 1.
ENDIF.
CALL METHOD ref_media->setdatasource
EXPORTING
filename = 'D:\temp\cartoon004.wav'.
CALL SCREEN 1000.