Developing multimedia player with PB

Source: Internet
Author: User
Tags insert objet ole

PB (PowerBuilder) as a good database front-end development tool, well received by the vast number of database developers, now the database involves more and more multimedia applications, and PowerBuilder did not like VB, Delphi, such as the provision of multimedia development control, But it is not that the use of PowerBuilder can not develop multimedia. Here are three ways to develop multimedia using PowerBuilder (to play video file avi for example).

I. The use of OLE methods

Open the form of the multimedia you want to play, click the OLE control, the system pops up the Insert Object dialog box, select the CreateNew page, select a video clip, place the OLE control on the form, and write a script for the form's Open event ( For example, to play the video file for Sample.avi): Ole_1.inserfile ("Sample.avi") run the form, double-click the OLE, the video will play out.

Ii. using the method of MCI

This method invokes the Windows API function Mcisendstringa, so first declare the function. Select the Declare/local External functions menu item, pop-up the Declare Local External Functions dialog box, and declare a partial external function: function Long Mcisendstringa ( Red string Scommand,ref string Returnstr,int ilength,unitucallback). Put a command button cb_play on the form with the text "play" in the Cb_play Click event Input Script:

String Ls_command,ls_buffer,ls_filename

Filename=″sample.avi″

Ls_buffer=fill (Char (0), 255)

Ls_command=″open″+ls_filemane+″type AVIVideo alias Avi″

Mcisendstringa (Ls_command,ls_buffer,255,handle (parent))

Ls_command=″play avi Notify″

Mcisendstringa (Ls_command,ls_buffer,255,handle (parent))

Run the form and click the button to play the video.

Third, the use of OCX control

The WINDOWS95 system provides a Amovie.ocx control that provides a number of properties and functions that can be programmed to modify its properties and call its functions to control multimedia and develop high-quality multimedia players. Here's an example of developing a multimedia player with playback and stop capabilities.

On the form that you want to play, click the OLE control, the system pops up the Insert Objet dialog box, select the Insert Control page, choose Activemoviecontrolobject, and place the custom OLE control on the form. Then put two command buttons Cb_play and cb_stop on the form, with the text assigned to play and stop respectively.

In the form, open event input script:

Ole_1.Objet.Filename (″sample.avi″)

The script for the V Cb_play Click event is:

Ole_1.Object.play ()

The script for the Cb_stop Click event is:

Ole_1.object.stop ()

Such a simple multimedia player is developed, if you want to more control of multimedia, call the control of the corresponding functions and modify its properties can be. As for the events, properties, and functions of the Amovie.ocx control, you can view it by clicking the browser icon.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.