Multimedia software. Tools for creating multimedia applications

Tools for creating multimedia applications

Review What is multimedia Multimedia in Delphi TMediaPlayer component Two types of programs that use multimedia

1. Review

Delphi makes it easy and simple to include multimedia objects such as sounds, videos and music into the program. IN this section discusses how to do this using the built-in Delphi component TMediaPlayer. The management of this component in the program and obtaining information about the current state are discussed in detail.

2. What is multimedia

There is no exact definition of what it is. But in this moment and in this place, it is probably better to give as much as possible general definition and to say that “multimedia” is a term that refers to almost all forms of animation, sound, video that are used on a computer.

Giving such a general definition, it must be said that in this section we are dealing with a subset of multimedia, which includes:

1. Show video in Microsoft's format Video for Windows (AVI).

2. Play sounds and music from MIDI and WAVE files.

This task can be accomplished using dynamic library Microsoft Multimedia Extensions for Windows (MMSYSTEM. DLL), the methods of which are encapsulated in the TMediaPlay component, located on the System page of the Delphi Component Palette.

Playing media files may require some hardware and software. So, to play sounds you need sound card.

3. Multimedia in Delphi

Delphi has a TMediaPlayer component that gives you access to all the basic media programming features. This component is very easy to use. In fact, it's so simple that many novice programmers will find it easier to create their first program that plays video or music rather than displaying the classic "Hello World" message.

Ease of use can be perceived in two ways:

This section does not describe the details of internal calls to multimedia functions when the component is running. All you need to know is that the component is called TMediaPlayer, and that it gives access to a set of routines created by Microsoft called the Media Control Interface (MCI). These routines give the programmer easy access to a wide range of multimedia devices. Actually working with TMediaPlayer is intuitive and obvious.

4. TMediaPlayer component

First, let's create a new project, then place the TMediaPlayer component (System Palette page) on the form, as shown in Figure 1.

Fig.1: TMediaPlayer component on the form.

The TMediaPlayer component is designed like a device control panel with buttons. Just like on a tape recorder, there are buttons for “play”, “rewind”, “record”, etc.

Having placed the component on the form, you will see that the Object Inspector contains the "FileName" property (see Fig. 2). Click twice

DIV_ADBLOCK63">

Fig.3: Playing AVI on the panel.

5. Two types of multimedia programs

Sometimes you need to provide users with an easy way to play as wide a range of files as possible. This means that you will need to give the user access to the hard drive or CD-ROM, and then allow him to select and play the appropriate file. In this case, the form usually contains TMediaPlayer, which provides playback control.

Sometimes a programmer may want to hide the existence of a TMediaPlayer component from the user. That is, play sound or video without the user caring about its source. In particular, sound can be part of a presentation. For example, showing a graph on the screen may be accompanied by an explanation written in WAV file. During the presentation, the user does not even know about the existence of TMediaPlayer. It works in the background. To do this, the component is made invisible (Visible = False) and controlled programmatically.

6. Example program with multimedia

In this section we will look at an example of building an application with multimedia of the first type. Create a new project (File | New Project). Place TMediaPlayer on the form; place a TOpenDialog class OpenDialog1 component to select a file. In the Filter property for it, specify the required file extensions:

AVI File(*.avi)|*.avi

WAVE File(*.wav)|*.wav

MIDI file(*.MID)|*.mid

Place a Button1 button of the TButton class on the form. Let the OpenDialog1 dialog be called when this button is pressed and the selected file will be played.
Create an OnClick event handler for Button1:

Procedure TForm1.Button1Click(Sender:TObject);

with OpenDialog1 do

if Execute then begin

MediaPlayer1. FileName:=FileName;

MediaPlayer1.Open;

MediaPlayer1.Play;

The appearance of the form is shown in Fig. 4

Fig. 4: Initial view of the project

Save the project, run it, select required file and double click on it with the mouse. MediaPlayer should play this file in a separate window.

As mentioned above, the video can be played inside a form, for example, in a panel. Let's slightly modify the project and add a TPanel there (see Fig. 5). In the Display property for MediaPlayer1, specify Panel1. It is necessary to remove the inscription from the panel (Caption)

and property BevelOuter = bvNone. To switch from a window to a panel during playback, place a TCheckBox on the form and write in the OnClick event handler for it:

procedure TForm1.CheckBox1Click(Sender: TObject);

Start_From: Longint;

with MediaPlayer1 do begin

if FileName="" then Exit;

Start_From:=Position;

Panel1.Refresh;

if CheckBox1.Checked then

Position:=Start_From;

Launch the project and play the video. Click on the CheckBox.

While the program is running, you may need to display Current state the MediaPlayer object and the video itself (time elapsed since the start of playback, length of the video). For this, the TMediaPlayer object has the corresponding properties and events: Length, Position, OnNotify, etc. Let's add a progress indicator (TGauge) to the project, which will display in percentage how much time has passed (see Fig. 6). You can use a timer to update the indicator readings. Place a TTimer object on the form, set its Interval = milliseconds). In the OnTimer event handler you need to write:

procedure TForm1.Timer1Timer(Sender: TObject);

with MediaPlayer1 do

if FileName<>"" then

Gauge1.Progress:=Round(100*Position/Length);

Launch the project, select the file (AVI) and double-click on it. When playing a video, the progress indicator should display the percentage corresponding to the elapsed time (see Fig. 6).

Annotation: In this lecture we will discuss the possibilities of using a natural-intuitive approach in modern multimedia applications. The synergy of a new interface approach and multimedia technology makes it possible to create a new generation of software that is extremely interactive and efficient in use. As an example, we will consider graphics editor with gesture control and voice control in standard service applications.

The presentation for this lecture can be downloaded.

5.1. Brief concept of multimedia and multimedia applications

Multimedia (multimedia) is a collection of computer technology simultaneous use of several information environments: graphics, text, video, photography, animation, sound effects, sound, human speech.

Multimedia technologies are a set of modern digital media audio, television, visual and virtual communications that allow you to enter, save, process and reproduce text, audiovisual, graphic, three-dimensional and other information.

Linking multimedia elements into a single project is done using software. The results of presenting media elements on screen and media controls are called user interface, and hardware and software that provide multimedia playback - by the platform.

Types of multimedia include:

  • Linear media - simplest form presentations of multiple media elements, where the user can only passively view the media elements, and the sequence of viewing the media elements is determined by the script.
  • Nonlinear (interactive) multimedia is a form of representation of multiple multimedia elements in which the user is given the opportunity to select and control elements in a dialogue mode.
  • Hypermedia is interactive multimedia in which the user is presented with a structure of related media elements that he can select sequentially.
  • Live video is a form of multimedia that instantly broadcasts a data stream from one device to another, allowing the user to view video and audio in real time.

In general, multimedia can be understood as a multimedia shell program, a product made on the basis of multimedia technology, and computer equipment. Since multimedia technologies are complex, individual elements of these technologies are characterized by multi-medium and dialogue with the user. Multimedia resources, for example, contain different kinds information, their essential feature is the active interaction of the resource and the person.

Multimedia technology is one of the new technological forms information society. It opens up a fundamentally new level of information processing and interactive interaction between a person and a computer. Distinctive feature modern multimedia technologies is their ability not only to produce a certain product intended for consumption, but also to have an indirect impact on the person using them. New types of processing and provision of information, new ways of accessing information allow us to diversify our culture, promote the global exchange of cultural values, information and knowledge, and promote more intensive communication between people.

The historical specificity of the modern electronic communication system is that, unlike previous forms and stages of cultural development of mankind, the current one is characterized by the global scale of its distribution and impact on all spheres of public life.

Because the information exchange- a necessary component of social life, then media technologies, as a mediating link in human activity, are one of the methods of communication, a condition for human activity. At the same time, integration in one system of various sources and forms of information in conditions open access fundamentally changed the nature of communication. Electronic digital media resources create technical feasibility the existence of a supersaturated information field, which almost everywhere surrounds modern man.

Multimedia, in addition to significantly accelerating communication processes, allows you to organize the processes of production, storage and dissemination of information at a qualitatively new level.

Actively introducing itself into the business environment, multimedia influences the course of economic development society, giving birth to a new direction - e-business. Multimedia technologies are widely used in advertising activities, in marketing management and in organizing the promotion of goods and services. various methods. Multimedia technologies are becoming an independent business and professional field of activity, a subject of business.

It is impossible to overestimate the importance of multimedia in the development of the entertainment industry, the creation computer games, film industry.

Multimedia should also be considered as an art, where a special place belongs to visual and figurative methods of transmitting information. How new form artistic creativity, multimedia is not so much a product of the technological revolution as a digital embodiment of ideas that did not find prospects for implementation in the traditional framework of fine art and other types of culture. At the same time, the computer becomes another promising tool for all arts, an alternative environment capable of reconstructing culture in a new way and creating its own art; it is recognized as a means of creating types of art. Several areas of computer art have emerged: digital music, interactive performance, computer graphics and animation. One of the main advantages of these types of creativity is the openness of the artistic space.

One of the ways to use multimedia productively is in learning. Multimedia technology allows you to increase the degree of assimilation of the studied material, as it provides the opportunity for synergetic learning. This means ensuring simultaneous visual and auditory perception of the material, active participation in managing its presentation, and returning to those sections that require re-analysis. The role of multimedia technologies in the development of distance education is especially great. In the future, the role of multimedia in education will increase, as the knowledge that provides high level professional qualifications are always subject to rapid change.

There are a large variety of software tools for working with multimedia files. Such applications can be divided into several main categories:

  • Image creation and processing tools
  • Tools for creating and processing 2D and 3D graphics
  • Tools for creating and processing video and animation
  • Sound creation and processing tools
  • Presentation Creation Tools

Computer representation graphic information implemented using a raster or vector approach. In the first case, the image is divided into pixels, the color of each pixel is encoded with a certain number of bits. Vector images are saved as a geometric description of the objects that make up the drawing.

Graphic editors are focused on manipulating existing images and have a set of tools that allow you to adjust any aspect of the image. Professional graphic editors support working with layers and exporting objects from programs vector graphics, have a full set of tools for color correction, retouching, adjusting contrast and color saturation, masking, creating various color effects imitating certain artistic techniques.

In vector graphics programs, objects and images that are saved as a geometric description exist independently of each other, which allows you to change the layer, location and any other attributes of the object at any time, creating an arbitrary composition. In such programs, illustrations are created using free-form shapes, their scaling, rotation, deformation, as well as the degree of transparency and color filling. Modern programs vector graphics also contain tools for working with raster images and texts.

Three-dimensional graphics are implemented by creating frames of objects, defining the materials that cover them, arranging all objects into a single scene, installing lighting and a visualization point - the camera. For 3D animation, you need to configure the movement of scene objects and set the number of frames. The movement of objects in three-dimensional space is specified using trajectories, key frames, and using formulas connecting the movement of parts of complex structures. After setting the desired motion, lighting and materials, the rendering process is launched, during which the characteristics of all objects in the scene are calculated and a sequence of images is generated. 2D animation also uses the traditional frame-by-frame principle, but uses 2D images to create the sequence.

There are a lot of options for video editing software products. Professional video editors allow you to edit multiple videos and audio channels and edit video clips into a single composition. They contain sets of transitions between frames, synchronize sound and image, and also support editing and saving the most popular video file formats.

Programs for working with sound can be divided into two: large groups: sound editors focused on digital technologies sound recording, and sequencer programs.

Sequencers are designed for creating music; they are used to encode musical compositions; they are used for arrangement, allowing you to register individual parts, assign instrument timbres, build levels and balances of channels, and introduce musical touches. Sound editors Allows you to record audio in real time HDD computer and transform it using the capabilities digital processing audio frequencies and combining different channels.

Presentation tools, originally designed to create electronic slides to help illustrate a presenter's message, are now becoming increasingly multimedia oriented. There are a large number of such programs, differing in the set of visual and animation effects, presentation management methods and the set of supported multimedia files for importing as slide content. In essence, a presentation is an information product that combines all multimedia formats into one whole.

The prospects for multimedia are diverse; the areas of application will expand, including due to the emergence of new information technologies and methods of information processing. A competent combination of multimedia with other technologies will contribute to their more dynamic development and even greater integration into all spheres of society.

In order to implement effective and useful multimedia applications using Intel Perceptual Computing technology, first of all, it is necessary to clearly define which multimedia formats and to what extent will be involved in specific application and what technologies are needed to work with these multimedia formats. The success of such applications will largely depend on how experienced the developers are in using certain plug-in libraries of functions that process the multimedia stream. Such an application will be useful to the user only if it correctly processes multimedia content and is correctly implemented with technical point vision. Therefore, before starting to develop a multimedia application using Intel Perceptual Computing, it is necessary to study in detail the principles and features of multimedia stream processing technology, function libraries and sample programs.

Only if control using Intel Perceptual Computing technology complements useful and correctly working multimedia functionality will the developer be able to realize all the benefits of the synergy of multimedia and Perceptual Computing.

5.2. Benefits of using the Intel Perceptual Computing SDK when developing multimedia applications new type human-computer interfaces, we can talk about the emergence of a new generation of multimedia applications with a much wider range of processing capabilities various types files and data streams. Managing multimedia files now goes beyond the classical concepts of human-computer interaction and turns into an exciting creative process. The use of Perceptual Computing technology increases the degree of interactivity of multimedia applications, which in themselves are an effective tool for engagement. The symbiosis of multimedia technologies and Perceptual Computing is especially effective in the educational and entertainment spheres of human activity, but can also be used for commercial and advertising purposes, at various presentations and demonstrations.

With the right combination of two technologies, ready-made applications allow both solving simple and everyday user problems and acting as a flexible and complex tool in various fields, including media art and the digital industry. With the help of Perceptual Computing, you can facilitate the management of complex software systems that use several multimedia technologies and make parallel work, for example, with graphics and sound that are more user-friendly. With the thoughtful aggregation of several multimedia technologies in one application, the user is given more opportunities to work with digital information, which is only enhanced when using gesture or voice control.

One of the most common ways to combine multimedia and Perceptual Computing technologies is to create various simulators that allow you to train specific skills, including simulators for playing musical instruments. Applications that allow the user to play virtual musical instruments are not fundamentally new, but the use of a gesture interface allows one to achieve much greater realism. Another advantage of such simulators over standard non-gestural implementations is the ability to simultaneously control the application with both hands, which also brings virtual musical instruments closer to real ones.

The simplest example of a music simulator is the Drummer application, which allows you to simulate playing drums (Fig. 5.1). The main function of the application is to record audio and music tracks. The user can assemble a drum kit from several items, start a recording session, stop recording. The simulator uses gestures of both hands. Preference is given to dynamic gestures, using capture gestures to move application objects, a double thumbs up gesture is used to stop recording. Voice control not provided in the application.


Rice. 5.1.

Another use case for Intel Perceptual Computing is as a conductor of a virtual orchestra (Fig. 5.2). The application monitors the frequency and size of the user's gestures and, depending on these characteristics, changes the volume and speed of the music track being played. The program is controlled using characteristic conductor gestures, and the gestures must correspond to the size of the musical beat of the composition being played. In fact, the program recognizes the sequences of horizontal and vertical strokes that make up the conductor's movements. Additional functionality is graphic display currently active orchestral parts. Similar application can be implemented as an add-on to any popular program, reading and reproducing music tablature.


Rice. 5.2.

Since developers are not limited in any way in the choice of multimedia technologies and ways of using them, more functionally complex implementations of music simulators are possible, intended for both educational and leisure purposes, combining several multimedia technologies. It is possible to create simulators with different levels complexity or using additional devices, such as a portable multimedia projector. A good example of such an application would be software package, teaching the user to play the virtual piano. Displaying using a projector virtual keys on a horizontal surface, the application changes the color of the keys that need to be pressed at one time or another during the playing composition. At the same time, the movements of the user’s hands and the keys closed by his fingers are monitored. By “pressing” a key, the corresponding sound is played, which makes it clear to the user how correctly he is playing the composition. You can also add to the main functionality the display of notes and a moving player marker. More simple implementation

This type of application is an imitation of playing a xylophone. Another type of multimedia application with a dominant musical component is synthesizers. They are applicable mainly for entertainment purposes, but their gestural implementations can potentially become an integral attribute of digital art. One of the implementations of this type of synthesizer is the JOY application (Fig. 5.3). During its development, not only audio technologies were used, but also various tools for graphic modeling and image generation. When the application starts, the user selects an audio track and starts playback. The composition consists of 10 tracks, which are controlled by raising and lowering your fingers. Changing the distance between the hands changes the reverberation (reflection) effect of the sound. Vertical movement of the palms in different directions regulates the vibration frequency, the sound balance and echo change as the palms move away and approach the camera with depth sensors. At the same time, video management occurs. The active ones are displayed as dots on the screen.


audio tracks

, geometric objects also depend on the number of raised fingers recognized by the application, and pulsate in accordance with the rhythm of the song being played. Rice. 5.3. Real-time video generation control can be implemented as

Implementation of applications that generate a video stream from 2D images is simpler and suitable for developers who are just beginning to become familiar with graphics technologies and tools. The video stream created using such applications contains mainly abstract graphic images, which deform and change over time. There are a large number of different libraries containing classes and methods for working with graphic objects, their properties and characteristics, the use of which will simplify the creation of the animation part of the application. In this case, the implementation of control through a gesture interface is carried out by separating the functions of editing the properties of a graphic object with the functions of changing the trajectory and speed of its movement. To facilitate application management and create harmonious animation, it is recommended to select one main graphic object, and implement the behavior of all others as dependent on the characteristics and properties of the main object. As an example of the distribution of management functions graphic object

You can consider an option when the size of the object and its position on the screen are adjusted by gestures of one hand, and characteristics such as color, shape, angle of rotation are set using gestures of the other hand. An additional function of such an application can be saving the generated video stream to a file with the possibility of subsequent playback using any multimedia player. Generation of a three-dimensional video stream in real time (Fig. 5.4) is carried out according to a similar principle, however, it is more challenging task , since it requires the developer to understand the principles of construction 3D images and advanced 3D library skills. The graphical component of such an application can be implemented as the spatial movement of a cluster of several homogeneous objects with varying properties, for example, several cubes of different sizes in different shades of green or more complex 3D models , for example, imitation of a chaotically moving school of fish. For the convenience of implementing graphics management functions, it is recommended to set one main element

, and make all parameters of all other objects dependent on the position and state of the main object. It is recommended to separate the management of object properties and their location, as in the case of two-dimensional graphics. In this case, it is possible to implement changing the viewpoint by controlling the position of the user's face and, when tilting the head, rotate the three-dimensional scene in the appropriate direction. It is also possible to develop a system voice commands, controlling the three-dimensional scene and environment surrounding the main objects. For example, you can provide options for controlling the background shade, the degree of illumination and transparency of objects, and simulating additional effects that, using various textures, simulate various real-world phenomena, for example, sea water, hurricane winds, strong flames. A similar technique will be acceptable for applications that generate two-dimensional video. graphics editor(Fig. 5.5) provides functionality for creating and editing volumetric bodies from simple elements, as well as individually setting color properties for each element that makes up the created body. Control over the application is carried out using two cursors, which are controlled by simple gesture commands - two open palms and movements of the index fingers. A three-dimensional object is created from basic elements - cubes of the same size, for each of them it is possible to determine a color from a palette-spectrum.

Implemented three-dimensional workspace control capabilities such as rotating around an object, zooming in, zooming out and moving

What is multimedia

Multimedia in Delphi

TMediaPlayer component

Two types of programs that use multimedia

Review

  1. Delphi makes it easy and simple to include multimedia objects such as sounds, videos and music into the program. IN Example program with multimedia this lesson
  2. What is multimedia
  3. discusses how to do this using Delphi's built-in TMediaPlayer component. The management of this component in the program and obtaining information about the current state are discussed in detail.

There is no exact definition of what it is. But at this moment and in this place, it is probably better to give the most general definition possible and say that “multimedia” is a term that applies to almost all forms of animation, sound, video that are used on the computer.

To give such a general definition, it must be said that in this lesson we are dealing with a subset of multimedia, which includes:

2. Play sounds and music from MIDI and WAVE files.

1. Display video in Microsoft's Video for Windows (AVI) format.

This task can be accomplished using the Microsoft Multimedia Extensions dynamic library for Windows (MMSYSTEM.DLL), the methods of which are encapsulated in the TMediaPlay component located on the System page of the Delphi Component Palette. software. So to play sounds you need a sound card. For AVI playback Windows 3.1 (or WFW) requires Microsoft Video software to be installed.

  1. Multimedia in Delphi
  2. Delphi has a TMediaPlayer component that gives you access to all the basic media programming features. This component is very easy to use. In fact, it's so simple that many novice programmers will find it easier to create their first program that plays video or music rather than displaying the classic "Hello World" message.

Ease of use can be perceived in two ways:

 On the one hand, this makes it possible for anyone to create multimedia applications.

 On the other hand, you may find that not all features are implemented in the component. If you want to use low-level functions, you will have to dig quite deep using the Delphi language.

This lesson does not describe the details of internal calls to multimedia functions when the component is running. All you need to know is that the component is called TMediaPlayer, and that it gives access to a set of routines created by Microsoft called the Media Control Interface (MCI). These routines give the programmer easy access to a wide range of multimedia devices. Actually working with TMediaPlayer is intuitive and obvious.

  1. TMediaPlayer component

First, let's create a new project, then place the TMediaPlayer component (System Palette page) on the form, as shown in Figure 1.

Fig.1: TMediaPlayer component on the form.

The TMediaPlayer component is designed like a device control panel with buttons. Just like on a tape recorder, there are buttons for “play”, “rewind”, “record”, etc.

Having placed the component on the form, you will see that the Object Inspector contains the "FileName" property (see Fig. 2). Click twice

Fig.2: TMediaPlayer properties in the Object Inspector

on this property and select the file name with AVI extension, WAV or

M.I.D. In Fig. 2, the AVI file DELPHI.AVI is selected. Next you need to set the AutoOpen property to True.

After completing these steps, the program is ready to run. After launching the program, click green button“play” (far left) and you will see a video (if you selected AVI) or hear the sound (if you selected WAV or MID). If this does not happen or an error message appears, then two options are possible:

  1. You entered wrong name file.
  2. You have not configured multimedia correctly in Windows. This means that either you do not have the appropriate hardware, or you have not installed necessary drivers. Drivers are installed and configured in Control Panel, hardware requirements are given in any book on multimedia (you need a sound card, for example, compatible with Sound Blaster).

So, you have the opportunity to play AVI, MIDI and WAVE files simply by specifying the file name.

Another important property of the TMediaPlayer component is Display. Initially, it is not filled and the video is played in a separate window. However, you can use, for example, a panel as a screen to display the video. You need to place the TPanel component on the form and remove the text from the Caption property. Next, for TMediaPlayer, in the Display property, select Panel1 from the list. After this, you need to run the program and click the “play” button (see Fig. 3)

Fig.3: Playing AVI on the panel.

      1. Two types of multimedia programs
      2.  Sometimes you need to provide users with an easy way to play as wide a range of files as possible. This means that you will need to give the user access to the hard drive or CD-ROM, and then allow him to select and play the appropriate file. In this case, the form usually contains TMediaPlayer, which provides playback control.

 Sometimes a programmer may want to hide the existence of a TMediaPlayer component from the user. That is, play sound or video without the user caring about its source. In particular, sound can be part of a presentation. For example, displaying a graph on the screen may be accompanied by an explanation recorded in a WAV file. During the presentation, the user does not even know about the existence of TMediaPlayer. It works in the background. To do this, the component is made invisible (Visible = False) and controlled programmatically.

      Example program with multimedia

In this chapter, we will look at an example of building an application with type 1 multimedia. Create a new project (File | New Project). Place TMediaPlayer on the form; place the components TFileListBox, TDirectoryListBox, TDriveComboBox, TFilterComboBox to select the file. In the FileList property for DirectoryListBox1 and FilterComboBox1, set FileListBox1. In the DirList property for DriveComboBox1, put DirectoryListBox1. In the Filter property for FilterComboBox1, specify the required file extensions:

AVI File(*.avi)|*.avi

WAVE File(*.wav)|*.wav

MIDI file(*.MID)|*.mid

Let it be double click with the mouse in FileListBox1 the selected file will be played. In the OnDblClick event handler for FileListBox1, specify

Procedure TForm1.FileListBox1DblClick(Sender:TObject);

with MediaPlayer1 do

FileName:=FileListBox1.FileName;

The appearance of the form is shown in Fig. 4

Fig. 4: Initial view of the project

Save the project, run it, select the desired file and double-click on it. MediaPlayer should play this file in a separate window.

As mentioned above, the video can be played inside a form, for example, in a panel. Let's slightly modify the project and add a TPanel there (see Fig. 5). In the Display property for MediaPlayer1, specify Panel1. It is necessary to remove the inscription from the panel (Caption)

and property BevelOuter = bvNone. To switch from a window to a panel during playback, place a TCheckBox on the form and write in the OnClick event handler for it:

procedure TForm1.CheckBox1Click(Sender: TObject);

Start_From: Longint;

with MediaPlayer1 do begin

if FileName="" then Exit;

Start_From:=Position;

if CheckBox1.Checked then

Position:=Start_From;

Launch the project and play the video. Click on the CheckBox.


  Fig.5: Added a panel for video playback and a window/panel switch.

During program execution, you may need to display the current state of the MediaPlayer object and the video itself (time elapsed since the start of playback, length of the video). For this, the TMediaPlayer object has the corresponding properties and events: Length, Position, OnNotify, etc. Let's add a progress indicator (TGauge) to the project, which will display in percentage how much time has passed (see Fig. 6). You can use a timer to update the indicator readings. Place a TTimer object on the form, set its Interval = 100 (100 milliseconds). In the OnTimer event handler you need to write:

procedure TForm1.Timer1Timer(Sender: TObject);

with MediaPlayer1 do

if FileName<>"" then

Gauge1.Progress:=Round(100*Position/Length);

Launch the project, select the file (AVI) and double-click on it. When playing a video, the progress indicator should display the percentage corresponding to the elapsed time (see Fig. 6).


  Fig.6: Complete application for playing AVI, WAV and MDI files.

In this chapter, we will look at an example of building an application with type 1 multimedia. Create a new project (File | New Project). Place TMediaPlayer on the form; place the components TFileListBox, TDirectoryListBox, TDriveComboBox, TFilterComboBox to select the file. In the FileList property for DirectoryListBox1 and FilterComboBox1, set FileListBox1. In the DirList property for DriveComboBox1, put DirectoryListBox1. In the Filter property for FilterComboBox1, specify the required file extensions:

AVI File(*.avi)|*.avi

WAVE File(*.wav)|*.wav

MIDI file(*.MID)|*.mid

Let the selected file be played by double-clicking the mouse in FileListBox1. In the OnDblClick event handler for FileListBox1, specify

Procedure TForm1.FileListBox1DblClick(Sender:TObject);

with MediaPlayer1 do

FileName:=FileListBox1.FileName;

The appearance of the form is shown in Fig. 4.

Fig.4. Initial view of the project

Save the project, run it, select the desired file and double-click on it. MediaPlayer should play this file in a separate window.

As mentioned above, the video can be played inside a form, for example, in a panel. Let's slightly modify the project and add a TPanel there (Fig. 5). In the Display property for MediaPlayer1, specify Panel1. You need to remove the caption from the panel (Caption) and the property BevelOuter = bvNone. To switch from a window to a panel during playback, place a TCheckBox on the form and write in the OnClick event handler for it:



procedure TForm1.CheckBox1Click(Sender: TObject);

Start_From: Longint;

with MediaPlayer1 do begin

if FileName="" then Exit;

Start_From:=Position;

if CheckBox1.Checked then

Position:=Start_From;

Launch the project and play the video. Click on the CheckBox.

Rice. 5. Added panel for video playback and

window/panel switch.

During program execution, you may need to display the current state of the MediaPlayer object and the video itself (time elapsed since the start of playback, length of the video). For this, the TMediaPlayer object has the corresponding properties and events: Length, Position, OnNotify, etc. Let's add a progress indicator (TGauge) to the project, which will display in percentage how much time has passed (see Fig. 6). You can use a timer to update the indicator readings. Place a TTimer object on the form, set its Interval = 100 (100 milliseconds). In the OnTimer event handler you need to write:

procedure TForm1.Timer1Timer(Sender: TObject);

with MediaPlayer1 do

if FileName<>"" then

Gauge1.Progress:=Round(100*Position/Length);

Launch the project, select the file (AVI) and double-click on it. When playing a video, the progress indicator should display the percentage corresponding to the elapsed time (see Fig. 6).

Figure 6: Completed playback application

AVI, WAV and MDI files.

3. RESEARCH OBJECTS, EQUIPMENT, MATERIALS AND VISUAL Aids

3.1. IBM compatible computer.

3.2. Installed operating system Windows.

3.3. Installed application Borland Delphi.

3.4. reference system Borland Delphi applications.

4. WORK TASK

4.1. Studying the theoretical principles of programming in the Borland Delphi environment.

4.2. Completing the teacher’s individual programming assignment within the limits of the issues discussed in this laboratory work.

5. PROCEDURE FOR PERFORMANCE OF THE WORK

5.1. Familiarize yourself with the theoretical principles of this laboratory work.

5.2. Complete individual programming assignments from the teacher.

Exercise 1

Using multimedia components, create a program that allows you to select and view video images

Task 2

Supplement the program with the ability to determine the time and size of the file being played

5.3. Prepare a work report.

5.4. Protect laboratory work by answering the teacher's questions.

6.1. Description of the purpose of the work.

6.2. Basic theoretical principles of the work

6.4. Description of the methodology for completing an individual task.

7. CHECK QUESTIONS

8. LIST OF SOURCES USED

8.1. Delphi 7: [most complete guide] / A.D. Khomonenko [and others]; under the general editorship of A.D. Khomonenko. - St. Petersburg. : BHV - St. Petersburg, 2007 .- 1216 p. : ill. (7 copies)

8.2. Programming in Delphi 7 / P. G. Darakhvelidze, E. P. Markov. - St. Petersburg: BHV-Petersburg, 2004 .- 784c. : ill. (1 copy)

8.3 Osipov D. Delphi. Professional programming. - St. Petersburg: Symbol-Plus, 2006. -1056 p., ill.