Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I play MPEG video in my application?

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
How can I best play MPEG-3(or 4) movies in a resizable window in my VB6 application?
I tried, with success, the MCI API calls with the viewer ActiveX provided by catalyst but it only plays old AVI files with Indeo3.2 or earlier.
I did this so I can select and play movies AT a remote computer by remote control using winsock and TCPIP
Your help on MPEG would be greatly appreciated.
 
I think there's a nice media player control that ships with VB for doing this, but don't quote me.

mmilan
 
It only plays AVIs with primitive compression and MPG1
I cant find any updates for it.
I presumed there must be a better way?
 
some of the code below might be of use to you ??

VERSION 5.00
Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "MSDXM.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form CCS_Play
ClientHeight = 7590
ClientLeft = 1095
ClientTop = 690
ClientWidth = 9165
Icon = "CCS_Play.frx":0000
LinkTopic = "Form1"
ScaleHeight = 506
ScaleMode = 3 'Pixel
ScaleWidth = 611
Begin VB.CheckBox Check1
Caption = "Repeat"
Height = 165
Left = 1470
TabIndex = 8
Top = 6870
Width = 915
End
Begin VB.CommandButton Command3
Caption = "100 %"
Height = 375
Left = 5310
TabIndex = 7
Top = 7080
Width = 1155
End
Begin VB.CommandButton Command2
Caption = "Fit to Size"
Height = 375
Left = 3960
TabIndex = 6
Top = 7080
Width = 1185
End
Begin VB.CommandButton Command1
Caption = "Full Screen"
Height = 375
Left = 2640
TabIndex = 5
Top = 7080
Width = 1185
End
Begin VB.CommandButton Stop_Music
Caption = "&Stop"
Height = 375
Left = 6630
TabIndex = 4
ToolTipText = "Stop the Music"
Top = 7080
Width = 1170
End
Begin VB.CommandButton ExitMe
Caption = "&Exit"
Height = 390
Left = 7950
TabIndex = 3
ToolTipText = "Go to a Finish Routine"
Top = 7080
Width = 1170
End
Begin MSComDlg.CommonDialog Disc_Jockey
Left = 8730
Top = 7260
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Play_Sam
Caption = "&Play"
Height = 360
Left = 1350
TabIndex = 2
ToolTipText = "Play a Media File"
Top = 7080
Width = 1170
End
Begin VB.CommandButton Load_File
Caption = "&Open"
Height = 360
Left = 60
TabIndex = 1
ToolTipText = "Open a Media File"
Top = 7080
Width = 1170
End
Begin MediaPlayerCtl.MediaPlayer Orchestra
Height = 6825
Left = 30
TabIndex = 0
Top = 0
Width = 9090
AudioStream = -1
AutoSize = 0 'False
AutoStart = -1 'True
AnimationAtStart= -1 'True
AllowScan = -1 'True
AllowChangeDisplaySize= -1 'True
AutoRewind = 0 'False
Balance = 0
BaseURL = ""
BufferingTime = 5
CaptioningID = ""
ClickToPlay = -1 'True
CursorType = 0
CurrentPosition = -1
CurrentMarker = 0
DefaultFrame = ""
DisplayBackColor= 0
DisplayForeColor= 16777215
DisplayMode = 0
DisplaySize = 0
Enabled = -1 'True
EnableContextMenu= -1 'True
EnablePositionControls= -1 'True
EnableFullScreenControls= -1 'True
EnableTracker = -1 'True
Filename = ""
InvokeURLs = -1 'True
Language = -1
Mute = 0 'False
PlayCount = 0
PreviewMode = -1 'True
Rate = 1
SAMILang = ""
SAMIStyle = ""
SAMIFileName = ""
SelectionStart = -1
SelectionEnd = -1
SendOpenStateChangeEvents= -1 'True
SendWarningEvents= -1 'True
SendErrorEvents = -1 'True
SendKeyboardEvents= 0 'False
SendMouseClickEvents= 0 'False
SendMouseMoveEvents= 0 'False
SendPlayStateChangeEvents= -1 'True
ShowCaptioning = 0 'False
ShowControls = -1 'True
ShowAudioControls= -1 'True
ShowDisplay = 0 'False
ShowGotoBar = 0 'False
ShowPositionControls= -1 'True
ShowStatusBar = -1 'True
ShowTracker = -1 'True
TransparentAtStart= 0 'False
VideoBorderWidth= 0
VideoBorderColor= 0
VideoBorder3D = 0 'False
Volume = -600
WindowlessVideo = 0 'False
End
End
Attribute VB_Name = "CCS_Play"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


DefInt A-Z





Private Sub Command1_Click()

Orchestra.DisplaySize = mpFullScreen

End Sub

Private Sub Command2_Click()

Orchestra.DisplaySize = mpFitToSize

End Sub


Private Sub Command3_Click()

Orchestra.DisplaySize = mpDefaultSize

End Sub


Private Sub Form_Load()

Me.Show

If Len(Command()) Then
CCS_Play.Caption = Command
Orchestra.FileName = Command
Orchestra.Stop
Orchestra.SelectionStart = 0
End If


End Sub

Private Sub Load_File_Click()

On Error Resume Next
'On Error GoTo ErrHandler

Disc_Jockey.CancelError = True
Disc_Jockey.Filter = "MPEG (*.mpg)|*.mpg|Movie (*.mov)|*.mov|MIDI Sequence (*.mid; *.rmi)|*.mid; *.rmi|WAV Sound (*.wav)|*.wav|MP3 (*.mp3)|*.mp3|AVI (*.avi)|*.avi|MPEG (*.mpg)|*.mpg|AU (*.au)|*.au"
Disc_Jockey.ShowOpen

If Disc_Jockey.FileName <> "" Then
Orchestra.FileName = Disc_Jockey.FileName
Orchestra.AutoStart = False
Orchestra.Stop

CCS_Play.Caption = Disc_Jockey.FileTitle
End If

Orchestra.SelectionStart = 0
'ErrHandler: 'If an error occurs, exit the procedure.
'On Error GoTo 0
'MsgBox Disc_Jockey.FileName & " is not playable !", 16, "File Error"

End Sub

Private Sub Orchestra_EndOfStream(ByVal Result As Long)

If Check1.Value = 1 Then
Orchestra.Play
Else
Orchestra.Pause
End If


End Sub


Private Sub Play_Sam_Click()

On Error GoTo ErrorHandler

Orchestra.Play

Exit Sub

ErrorHandler:
On Error GoTo 0
MsgBox Disc_Jockey.FileName & " is not playable !", 16, "File Error"

End Sub


Private Sub ExitMe_Click()

Orchestra.Stop

Unload Me

End Sub

Private Sub Stop_Music_Click()

Orchestra.Stop

End Sub


MaxRace Software - Larry Meaux
ET_Analyst for DragRacers
Support Israel - Genesis 12:3
 
Thanks
The codecs must be the problem.
I downloaded WindowsMediaPlayer9 and used the WMP9.DLL as a component and it works excellently in my VB6 application as a skinless window if you set the UiMode property to "none"

However WMP9 has a problem. If you play a MPG4 then load another MPG4 movie, it plays jerkily (looks like 5 frames persecond). You have to close the player completely and reopen it to play smoothly. Doesnt happen if you play only AVI files. (Happens in both the native player and my app.)

Strongman: how are the codec files incorporated? do they actually modify the OCX or DLL file in the case of WMP9 or do they have to be distributed with my application package in some way?
If the codecs are in separate files, how does the player and the package wizard know they are there?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top