Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Formless multimedia control software. It is used t...
Author:
Kumaran
E-mail:
Click to e-mail author
Submitted:
1/15/2001
Version:
VB6
Compatibility:
VB6
Category:
Multimedia
Views:
16559
Formless multimedia control software. It is used to adjust the speed of playing.
Declarations:
First take common dialog ActiveX control and rename is as DLG. And add 12 command buttons on the form and rename the command buttons name as the program used name and also rename the form name. Other informations as given in comments. Best of Luck.
Code:
'Media Player (MPlayer) ' 'Author : R. Kumaran 'Address : rkumaran2000@hotmail.com ' 'About : 'This program play media file with user selection 'speed and also explain how to create an irregular form. 'This program give best result only on 800x600 resolution. ' 'API Functions : ' 'GetShortPathName() - is used to get sortestpath of long path 'mciSendString() - is used for multimedia operations. 'CreateEllipticRgn - is used to select particular region 'CombineRgn() - is used to combine selected regions 'SetWindowRgn() - is used to display selected regions of form ' 'User defined Functions : ' 'CurrentPos : is used to get current position of media playing state 'MediaLength : is used to get length of media 'IsValidState : is used to find the media file is on open state or not 'MediaStatus : is used to find media status (playing,paused,stopped,recording,...) 'ShortPath : is used to get shortest path of long path '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Option Explicit Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Dim speed As Long 'To control the speed of playing 'To conver the long path to short path Function ShortPath(sPath As String) As String Dim ShortPathName As String If Right$(sPath, 1) <> "\" Then sPath = sPath & "\" End If ShortPathName = Space$(255) GetShortPathName sPath, ShortPathName, Len(ShortPathName) ShortPath = Left$(ShortPathName, Len(Trim$(ShortPathName)) - 2) End Function 'To find the length of the media Function MediaLength() As Long Dim sLength As String * 255, lNullChar As Long mciSendString "status mmfile length", sLength, 255, 0 'To find the null character position lNullChar = InStr(sLength, Chr$(0)) 'Return the length of the media MediaLength = CLng(Val(Left$(sLength, lNullChar - 1))) End Function 'To find the current position of the media Function CurrentPos() As Long Dim lNullChar As Long, sCurPos As String * 255 mciSendString "status mmfile position", sCurPos, 255, 0 lNullChar = InStr(sCurPos, Chr$(0)) CurrentPos = CLng(Val(Left$(sCurPos, lNullChar - 1))) End Function 'To find the status of the video Function MediaStatus() As String Dim lNullChar As Integer, sStatus As String * 255 mciSendString "status mmfile mode", sStatus, 255, 0 lNullChar = InStr(sStatus, Chr$(0)) MediaStatus = UCase$(Left$(sStatus, lNullChar - 1)) End Function 'To find valid state for stop or close Function IsValidState() As Boolean If MediaStatus = "PLAYING" Or MediaStatus = "PAUSED" Or MediaStatus = "STOPPED" Then IsValidState = True Else IsValidState = False End If End Function Private Sub cmdAbout_Click() If MediaStatus = "PLAYING" Then cmdPause_Click MsgBox "Programmed by Kumaran " & Chr$(10) + "rkumaran2000@hotmail.com", vbInformation cmdPlay_Click Else MsgBox "Programmed by Kumaran " & Chr$(10) + "rkumaran2000@hotmail.com", vbInformation End If End Sub Private Sub cmdBackward_Click() Dim MStatus As String, lPos As Long MStatus = MediaStatus 'To move 5 percent of media length towards back lPos = CInt(CurrentPos - (MediaLength * 0.05)) If IsValidState Then If lPos > 0 Then mciSendString "seek mmfile to " & lPos, "", 0, 0 If MStatus = "PLAYING" Then cmdPlay_Click End If End If End If End Sub Private Sub cmdClose_Click() If MediaStatus = "PLAYING" Or MediaStatus = "PAUSED" Or MediaStatus = "STOPPED" Then mciSendString "close mmfile", "", 0, 0 End If End Sub Private Sub cmdDecreaseSpeed_Click() If speed - 50 >= 100 Then speed = speed - 50 mciSendString "set mmfile speed " & speed, "", 0, 0 End If End Sub Private Sub cmdExit_Click() If MediaStatus = "PLAYING" Or MediaStatus = "PAUSED" Then cmdClose_Click End If Unload Me End Sub Private Sub cmdFastBackward_Click() If IsValidState Then mciSendString "seek mmfile to start", "", 0, 0 mciSendString "play mmfile from 1 to 2", "", 0, 0 End If End Sub Private Sub cmdFastForward_Click() If IsValidState Then mciSendString "seek mmfile to end", "", 0, 0 End If End Sub Private Sub cmdForward_Click() Dim MStatus As String, lPos As Long MStatus = MediaStatus 'To move 5 percent of media lenght toward forward lPos = CLng(CurrentPos + (MediaLength * 0.05)) If IsValidState Then If lPos < MediaLength Then mciSendString "seek mmfile to " & lPos, "", 0, 0 If MStatus = "PLAYING" Then cmdPlay_Click End If End If End If End Sub Private Sub cmdIncreaseSpeed_Click() If speed + 50 <= 2000 Then speed = speed + 50 mciSendString "set mmfile speed " & speed, "", 0, 0 End If End Sub Private Sub cmdOpen_Click() Dim Extension As String, LastFile As String LastFile = DLG.FileName DLG.FileName = "" DLG.Filter = "All Media Files (*.wav;*.mid;*.mp3;*.mp2;*.dat;*.mpg;*.avi;*.mov)|*.wav;*.mid;*.mp3;*.mp2;*.dat;*.mpg;*.avi;*.mov|Wav Files (*.wav)|*.wav|Mp3 Files (*.mp3)|*.mp3|MP2 Files (*.mp2)|*.mp2|MPG Files (*.mpg)|*.mpg|AVI Files (*.avi)|*.avi}|MOV Files (*.mov)|*.mov|VCD Files (*.dat)|*.dat|All Files (*.*)|*.*" DLG.DialogTitle = "Select Media file" If MediaStatus = "STOPPED" Or MediaStatus = "PLAYING" Or MediaStatus = "PAUSED" Then cmdClose_Click End If DLG.ShowOpen If DLG.FileName <> "" Then mciSendString "open " + ShortPath(DLG.FileName) + " alias mmfile", "", 0, 0 Extension = UCase$(Right$(ShortPath(DLG.FileName), 3)) If Extension = "DAT" Or Extension = "MPG" Or Extension = "MOV" Or Extension = "AVI" Or Extension = "MP2" Then mciSendString "put mmfile window at 0 0 800 480", "", 0, 0 End If speed = 1000 Else DLG.FileName = LastFile End If End Sub Private Sub cmdPause_Click() If MediaStatus = "PLAYING" Then mciSendString "pause mmfile", "", 0, 0 End If End Sub Private Sub cmdPlay_Click() If MediaStatus = "STOPPED" Then mciSendString "play mmfile", "", 0, 0 ElseIf MediaStatus = "PAUSED" Then mciSendString "resume mmfile", "", 0, 0 End If End Sub 'To set the elliptical form Private Sub Form_Load() speed = 1000 'Normal speed Dim rgn2 As Long, rgn1 As Long rgn2 = CreateEllipticRgn(20, 20, 460, 70) 'First elliptical region rgn1 = CreateEllipticRgn(130, 77, 348, 100) 'Second elliptical region CombineRgn rgn2, rgn2, rgn1, 2 'Combine first and second elliptical region SetWindowRgn Me.hWnd, rgn2, True 'Display the region End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement