[Gambas-user] MediaPlayer
Mike Crean
mike.crean at y7mail.com
Mon Nov 16 04:51:48 CET 2020
Thanks Charlie and Benoit.
Benoit thanks for putting me on the right trail here is what I ended up with. It may help some one else.
' Gambas class file
'**** NOTE only a DrawinArea can be used as the video container and Cached must be set to TRUE. ****
'**** A PictureBox can also be used as long as it is inside the DrawingArea. ****
Private mp As New MediaPlayer
Public Sub Form_Open()
Form.Load
Form.Show
mp.URL = "v4l2:///dev/video0"
mp.SetWindow(PictureBox1)
mp.Play()
End
Public Sub Form_Close()
EndIt()
End
Public Sub EndIt()
Try Quit
End
Public Sub Button2_Click()
Dim theImage As Image = mp.Video.Image
theImage.Save(Application.Path &/ Format(Now, "ddmmyyyy_hhnnss") & ".jpg")
PictureBox1.Image = theImage
End
Best RegardsMike
On Monday, 16 November 2020, 1:02:05 am AWST, Benoît Minisini <g4mba5 at gmail.com> wrote:
Le 15/11/2020 à 09:06, Mike Crean via User a écrit :
> Hi all, I know I am probably missing a simple fix for my problem.
>
> I have a picture box on a form and I wish to display a webcam in it.
>
> When I try with the following code the web cam image floods the entire form
>
> can anyone point me in the write direction so it is contained in the
> picture box please.
>
>
> Best regards
>
> Mike
>
>
> Private mp As New MediaPlayer
>
>
> Public Sub Form_Open()
>
> Form.Load
>
> Form.Show
>
> PictureBox1.SetFocus()
>
> mp.URL = "v4l2:///dev/video0"
>
> mp.SetWindow(PictureBox1)
>
> mp.Play()
>
> End
>
>
> Public Sub Form_Close()
>
> EndIt()
>
> End
>
>
> Public Sub EndIt()
>
> Try Quit
>
> End
>
>
> Public Sub Button2_Click()
>
> Dim theImage As Image = mp.Video.Image
>
> theImage.Save(Application.Path &/ Format(Now, "ddmmyyyy_hhnnss") & ".jpg")
>
> PictureBox1.Image = theImage
>
> End
>
The SetWindow() method needs a control that had a real X11 (or wayland)
window, otherwise if will use the first parent control having a real
window, which is usually the toplevel one.
Hopefully, there is a trick, used in the 'gb.form.media' component (that
you can use as an example): using a DrawingArea with its Cached property
set to TRUE. This is the only way to have a control having its own
window whatever the GUI component in use.
Maybe I should made a dedicated control for that, so that the trick
becomes explicit?
Regards,
--
Benoît Minisini
----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201116/ee7d3899/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyCCTV.png
Type: image/png
Size: 48937 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201116/ee7d3899/attachment-0001.png>
More information about the User
mailing list