ممكن طلب

    • هذي بعض الأكواد ربما تفيدك في التعامل مع الفيديو

      1- تشغيل ملف فيديو

      كود المصدر

      1. 'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
      2. 'Add 2 CommandButtons to your form (named Command1 and Command2).
      3. 'When you press the first button the AVI movie will start to play.
      4. 'Even after the AVI Finish playing, it is still takes memory.
      5. 'To remove it from the memory press the second button.
      6. 'Insert this code to the module :
      7. Declare Function mciSendString Lib "winmm.dll" Alias _
      8. "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
      9. lpstrReturnString As String, ByVal uReturnLength As Long, _
      10. ByVal hwndCallback As Long) As Long
      11. 'Insert the following code to your form:
      12. Private Sub Command1_Click()
      13. Dim returnstring As String
      14. Dim FileName As String
      15. returnstring = Space(127)
      16. 'Replace c:\MyMovie.avi with the AVI file you want to play
      17. FileName = "c:\MyMovie.avi"
      18. erg = mciSendString("open " & Chr$(34) & FileName & _
      19. Chr$(34) & " type avivideo alias video", returnstring, 127, 0)
      20. erg = mciSendString("set video time format ms", returnstring, 127, 0)
      21. erg = mciSendString("play video from 0", returnstring, 127, 0)
      22. End Sub
      23. Private Sub Command2_Click()
      24. erg = mciSendString("close video", returnstring, 127, 0)
      25. End Sub
      عرض الكل


      2- تشغيل ملف فيديو في صندوق الصورة

      كود المصدر

      1. Private Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" _
      2. (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
      3. ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
      4. Private Declare Function mciGetErrorString Lib "winmm" Alias _
      5. "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, _
      6. ByVal uLength As Long) As Long
      7. Private Declare Function GetShortPathName Lib "kernel32" Alias _
      8. "GetShortPathNameA" (ByVal lpszLongPath As String, _
      9. ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
      10. Private Const WS_CHILD = &H40000000
      11. Private Sub PlayAVIPictureBox(FileName As String, ByVal Window As PictureBox)
      12. Dim RetVal As Long
      13. Dim CommandString As String
      14. Dim ShortFileName As String * 260
      15. Dim deviceIsOpen As Boolean
      16. 'Retrieve short file name format
      17. RetVal = GetShortPathName(FileName, ShortFileName, Len(ShortFileName))
      18. FileName = Left$(ShortFileName, RetVal)
      19. 'Open the device
      20. CommandString = "Open " & FileName & " type AVIVideo alias AVIFile parent " _
      21. & CStr(Window.hWnd) & " style " & CStr(WS_CHILD)
      22. RetVal = mciSendString(CommandString, vbNullString, 0, 0&)
      23. If RetVal Then GoTo error
      24. 'remember that the device is now open
      25. deviceIsOpen = True
      26. 'Resize the movie to PictureBox size
      27. CommandString = "put AVIFile window at 0 0 " & CStr(Window.ScaleWidth / _
      28. Screen.TwipsPerPixelX) & " " & CStr(Window.ScaleHeight / _
      29. Screen.TwipsPerPixelY)
      30. RetVal = mciSendString(CommandString, vbNullString, 0, 0&)
      31. If RetVal <> 0 Then GoTo error
      32. 'Play the file
      33. CommandString = "Play AVIFile wait"
      34. RetVal = mciSendString(CommandString, vbNullString, 0, 0&)
      35. If RetVal <> 0 Then GoTo error
      36. 'Close the device
      37. CommandString = "Close AVIFile"
      38. RetVal = mciSendString(CommandString, vbNullString, 0, 0&)
      39. If RetVal <> 0 Then GoTo error
      40. Exit Sub
      41. error:
      42. 'An error occurred.
      43. 'Get the error description
      44. Dim ErrorString As String
      45. ErrorString = Space$(256)
      46. mciGetErrorString RetVal, ErrorString, Len(ErrorString)
      47. ErrorString = Left$(ErrorString, InStr(ErrorString, vbNullChar) - 1)
      48. 'close the device if necessary
      49. If deviceIsOpen Then
      50. CommandString = "Close AVIFile"
      51. mciSendString CommandString, vbNullString, 0, 0&
      52. End If
      53. 'raise a custom error, with the proper description
      54. Err.Raise 999, , ErrorString
      55. End Sub
      56. Private Sub Command1_Click()
      57. 'replace 'c:\myfile.avi' with the name of the AVI file you want to play
      58. PlayAVIPictureBox "c:\goeye.avi", Picture1
      59. End Sub
      عرض الكل


      3- لتشغيل ملف فيديو في Picture

      كود المصدر

      1. Private Sub Form_Load()
      2. MMControl1.FileName = ("c:\FileName.dat")
      3. MMControl1.Command = "open"
      4. MMControl1.hWndDisplay = Picture1.hWnd
      5. End Sub




      نتمنى أن تكون قد استفدت من هذه الأكواد