Visual Basic 6 Black Book:Multimedia
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Playing MPG Files
The Testing Department is calling again. Your new program, SuperDuperMultimedia4U, is terrificbut how about playing MPG format files? No problem, you say.
You can play MPG format files with the multimedia control. How do you display the images in the MPG file? You connect the multimedia control to a picture box using the picture boxs hWnd property, placing that handle in the multimedia controls hWndDisplay property. Opening the file itself makes the buttons in the multimedia control active.
Lets see an example; here, well play an MPG file named, say, demo.mpg. Add a multimedia control, MMControl1, to a program now, as well as a picture box, Picture1, in which well play demo.mpg. We also add a label, Label1, to display the multimedia controls status.
When the form loads, we load the multimedia controls FileName property with the name of the file we want to open:
Private Sub Form_Load()
MMControl1.FileName = "c:\demo.mpg"
...
End Sub
Next we connect the picture boxs hWnd property to the multimedia controls hWndDisplay property to connect the picture box to the multimedia control:
Private Sub Form_Load()
MMControl1.FileName = "c:\demo.mpg"
MMControl1.hWndDisplay = Picture1.hWnd
...
End Sub
Finally, we open the file, which enables the buttons in the multimedia control:
Private Sub Form_Load()
MMControl1.FileName = "c:\demo.mpg"
MMControl1.hWndDisplay = Picture1.hWnd
MMControl1.Command = "Open"
End Sub
Now when users click the buttons in the multimedia control, they can play, stop, and restart the MPG file as they like. The animation appears in the picture box Picture1.
Besides playing the MPG file, we can display what the multimedia control is doing (for example, playing, stopped, and so forth) in a label, Label1, by adding this code to the multimedia controls StatusUpdate event handler:
Private Sub MMControl1_StatusUpdate()
Dim strMode As String
strMode = ""
Select Case MMControl1.Mode
Case mciModeReady
strMode = "Ready."
Case mciModeStop
strMode = "Stopped."
Case mciModeSeek
strMode = "Seeking."
Case mciModePlay
strMode = "Playing."
Case mciModeRecord
strMode = "Recording."
Case mciModePause
strMode = "Paused."
End Select
Label1.Caption = strMode
End Sub
Finally, we stop and close the multimedia control when the form is unloaded:
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop"
MMControl1.Command = "Close"
End Sub
Thats itmultimedia controls can play files in this format just as they can play AVI files; our MPG player is a success. The code for this example is located in the mpgplayer folder on this books accompanying CD-ROM.
Keeping Track Of Multimedia Command Execution Using Notification
You can gain more control over the multimedia control using the Notify property and the Done event. When you set a multimedia controls Notify property to True, youll get notification when the control finishes executing commands. How does it notify you? It generates a Done event.
In fact, when you set Notify to True, your program is only supposed to be notified when the multimedia control is finished with the next command, but in fact, Done events appear to be generated for every command as long as Notify is True.
Lets see an example. Here, we add a multimedia control, MMControl1, to a program and set its Notify property to True when the form loads:
Private Sub Form_Load()
MMControl1.FileName = "C:\WINDOWS\MEDIA\DING.WAV"
MMControl1.Command = "Open"
MMControl1.Notify = True
End Sub
When the control finishes executing a command, it fires a Done event, which we catch in an event handler procedure:
Private Sub MMControl1_Done(NotifyCode As Integer)
End Sub
Here, the event handler procedure is passed a notification code, NotifyCode, which can take these values:
mciSuccessful1; command completed successfully
mciSuperseded2; command was superseded by another command
mciAborted4; command was aborted by the user
mciFailure8; command failed
In this example, we just display a message box, indicating to the user that the multimedia command is finished:
Private Sub MMControl1_Done(NotifyCode As Integer)
MsgBox "Finished the multimedia command."
End Sub
Using multimedia notification, you can coordinate your multimedia actionsfor example, if you have two multimedia controls, you might not want to start playing sounds with one until the other is finished playing its own sounds.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
761 (2)A0893 764 10761 763mbdch20 7612009 test lo[1]pgiid&764demo cgi 764764 768mbdch20 764759 761757 761więcej podobnych podstron