none
View Video image in Access DB RRS feed

  • Question

  • Thanks for taking the time to read my question.

    I have a DB that iterates through all images in a folder and its subfolders and logs the file info and then returns what it thinks to be duplicates. I can then move through the groups of duplicates and flag the ones to delete. The one feature that is very helpful is that I am able to see all the pictures right in the form (Forms!frmMaintainPics!Pic1.Picture = PicPath 'PicPath is the file path and name to the picutre) so that I can do a final test to ensure they are in fact the same. There are some cases where the size, date and file name are the same but the pics are actually different.

    The db will also scan in video files however I am not able to show a preview picture of the video in the form and so just have a .jpg I use in place (Forms!frmMaintainPics!Pic1.Picture = PicPath 'PicPath is set to a static .jpg file), therefore all video's have the same picture.

    Is there a way to grab the preview picture of a video and show it in the form? Maybe there is a thumbnail I can reference somehow? I'd like to see the picture you see when in Windows Explorer for example.

    Thanks,
    Brad

    Monday, November 14, 2016 9:54 PM

Answers

  • Hi mbrad,

    As you had mentioned that you can loop through the video files in the folder and can able to access the path of the video file.

    MS Access supports Windows Media Player to use with in Access Form.

    so you just need to pass the path of video file to the Media Player to play the video.

    you need to reference the ActiveX Control Windows Media Player like mentioned below.

    example code to use Windows Media Player is mentioned below.

    Option Compare Database
     Option Explicit
     Dim i As Integer
     Dim wp As WindowsMediaPlayer
     Private Sub Command1_Click()
     On Error Resume Next
     If wp.playState = wmppsPlaying Then 'stop playing
     wp.Close
     End If
     End Sub
    
     Private Sub Command2_Click()
     On Error Resume Next
     lstfile.Selected(0) = True 'select the first item
     lstfile.ListIndex = 0
     i = lstfile.ListIndex
     wp.URL = lstfile.Column(0, 0) 'play the first item
    
    
     End Sub
    
    
     Private Sub Command6_Click()
    
     'set listbox's rowsourcetype
     lstfile.RowSourceType = "Value List"
     'clear listbox
     lstfile.RowSource = ""
     'reset i
     i = 0
     Dim fdialog As Office.FileDialog
     Dim fs As Variant
     'create filedilog object
     Set fdialog = Application.FileDialog(msoFileDialogFilePicker)
    
     With fdialog
     'add filters
     .Filters.Add "Ms.Access Files", "*.avi; *.mp4; *.dat; *.mp3; *.m4; *.wmv; *.wm; *.wma; *.asf", 1
     .InitialFileName = CurrentProject.Path
     If .show Then
     'loop through selected items
     For Each fs In .SelectedItems
    
     lstfile.AddItem fs 'add to listbox
    
     Next fs
     Else
     End If
     End With
     'clear filedialog object
     Set fdialog = Nothing
     End Sub
    
    
    
     Private Sub Form_Load()
     'create w media object
     Set wp = wplayer.Object
    
     End Sub
    
     Private Sub Form_Timer()
     'play all items in the list continuously
     If wp.playState = wmppsStopped Then
     i = i + 1
     If i < lstfile.ListCount Then
     lstfile.Selected(i) = True
     wp.URL = lstfile.Column(0, i)
     End If
     End If
     End Sub
    
     Private Sub Form_Unload(Cancel As Integer)
     Set wp = Nothing
     End Sub
    
     Private Sub lstfile_BeforeUpdate(Cancel As Integer)
     On Error Resume Next
     'play the item selected manually
     wp.URL = lstfile.Column(0, lstfile.ListIndex)
     'update i
     i = lstfile.ListIndex
     End Sub

    Reference:

    VBA example - Microsoft Access-video player

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 15, 2016 3:09 AM
    Moderator
  • I had forgotten about the ActiveX control. Seems like a good option for you.

    As with any ActiveX control, you have to:

    set wp = Me.WindowsMediaPlayer9a.Object

    to get to its object model.


    -Tom. Microsoft Access MVP

    • Marked as answer by mbrad Tuesday, November 15, 2016 2:31 PM
    Tuesday, November 15, 2016 2:29 PM

All replies

  • No; Access does not have a video control.

    But you can use ShellExecute API with the "open" verb to open the video in the default player, running it side-by-side to Access.


    -Tom. Microsoft Access MVP

    Monday, November 14, 2016 11:34 PM
  • Hi mbrad,

    As you had mentioned that you can loop through the video files in the folder and can able to access the path of the video file.

    MS Access supports Windows Media Player to use with in Access Form.

    so you just need to pass the path of video file to the Media Player to play the video.

    you need to reference the ActiveX Control Windows Media Player like mentioned below.

    example code to use Windows Media Player is mentioned below.

    Option Compare Database
     Option Explicit
     Dim i As Integer
     Dim wp As WindowsMediaPlayer
     Private Sub Command1_Click()
     On Error Resume Next
     If wp.playState = wmppsPlaying Then 'stop playing
     wp.Close
     End If
     End Sub
    
     Private Sub Command2_Click()
     On Error Resume Next
     lstfile.Selected(0) = True 'select the first item
     lstfile.ListIndex = 0
     i = lstfile.ListIndex
     wp.URL = lstfile.Column(0, 0) 'play the first item
    
    
     End Sub
    
    
     Private Sub Command6_Click()
    
     'set listbox's rowsourcetype
     lstfile.RowSourceType = "Value List"
     'clear listbox
     lstfile.RowSource = ""
     'reset i
     i = 0
     Dim fdialog As Office.FileDialog
     Dim fs As Variant
     'create filedilog object
     Set fdialog = Application.FileDialog(msoFileDialogFilePicker)
    
     With fdialog
     'add filters
     .Filters.Add "Ms.Access Files", "*.avi; *.mp4; *.dat; *.mp3; *.m4; *.wmv; *.wm; *.wma; *.asf", 1
     .InitialFileName = CurrentProject.Path
     If .show Then
     'loop through selected items
     For Each fs In .SelectedItems
    
     lstfile.AddItem fs 'add to listbox
    
     Next fs
     Else
     End If
     End With
     'clear filedialog object
     Set fdialog = Nothing
     End Sub
    
    
    
     Private Sub Form_Load()
     'create w media object
     Set wp = wplayer.Object
    
     End Sub
    
     Private Sub Form_Timer()
     'play all items in the list continuously
     If wp.playState = wmppsStopped Then
     i = i + 1
     If i < lstfile.ListCount Then
     lstfile.Selected(i) = True
     wp.URL = lstfile.Column(0, i)
     End If
     End If
     End Sub
    
     Private Sub Form_Unload(Cancel As Integer)
     Set wp = Nothing
     End Sub
    
     Private Sub lstfile_BeforeUpdate(Cancel As Integer)
     On Error Resume Next
     'play the item selected manually
     wp.URL = lstfile.Column(0, lstfile.ListIndex)
     'update i
     i = lstfile.ListIndex
     End Sub

    Reference:

    VBA example - Microsoft Access-video player

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 15, 2016 3:09 AM
    Moderator
  • Hi Deepak,

    Thank you so very much for your excellent reply.

    My only question is, my WMP control has the name "WindowsMediaPlayer9a" how do I reference it if I've dimentioned "wp" as WindowsMediaPlayer.

    In my case I'd like to have several WMP controls on my form to be able to play different video's to see if they are in fact the same.

    Below is a screen shot of my form. I hope it sheds light on what I'm trying to accomplish.

    Thanks,
    Brad

    Tuesday, November 15, 2016 2:11 PM
  • I had forgotten about the ActiveX control. Seems like a good option for you.

    As with any ActiveX control, you have to:

    set wp = Me.WindowsMediaPlayer9a.Object

    to get to its object model.


    -Tom. Microsoft Access MVP

    • Marked as answer by mbrad Tuesday, November 15, 2016 2:31 PM
    Tuesday, November 15, 2016 2:29 PM
  • Hi Tom.

    Thanks for the quick reply. I was playing around with something like that but couldn't get it just right.

    Thanks to both of you for your help.

    Have a great day!

    Brad

    • Marked as answer by mbrad Tuesday, November 15, 2016 2:31 PM
    • Unmarked as answer by mbrad Tuesday, November 15, 2016 2:31 PM
    Tuesday, November 15, 2016 2:31 PM