Hi everyone. i was wondering if anyone new any good tutorials on how to make a picturebox play a video in vb.net 2010 WITHOUT using the windows media player component. i want this to be 100% my program. thx in advance!

Dani AI

Generated

For : playing video inside a PictureBox without dropping in the Windows Media Player control is doable but involves one of three routes: (A) use a media API wrapper (DirectShow via DirectShow.NET or Media Foundation), (B) decode with FFmpeg and paint frames manually, or (C) write a full decoder (not recommended). ’s suggestion to study open‑source players is sensible for implementation details, but a focused how‑to helps get a working prototype faster.

Practical minimal plan (pick one API):

  1. Pick decoder layer: DirectShow for broad compatibility, Media Foundation for modern Windows, or FFmpeg for wide codec support.
  2. Build/instantiate the decoder and request RGB frames (not YUV). Use a SampleGrabber (DirectShow) or SourceReader (Media Foundation) or ffmpeg to produce raw frames.
  3. Convert raw frame buffer to a managed Bitmap with LockBits + Marshal.Copy (avoid SetPixel). Update the PictureBox.Image on the UI thread and dispose the previous Bitmap.
  4. Drive display timing from frame timestamps (decoder timestamps or a high‑resolution timer). Audio must be handled separately (DirectSound/WASAPI or ffmpeg audio output).

Example VB.NET snippet to update PictureBox from a decoded byte[] (32bpp BGRA):

' buffer: Byte() with width*w height*h in 32bpp BGRA
Dim bmp As New Bitmap(w, h, Imaging.PixelFormat.Format32bppArgb)
Dim rect As New Rectangle(0, 0, w, h)
Dim bmpData = bmp.LockBits(rect, Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat)
System.Runtime.InteropServices.Marshal.Copy(buffer, 0, bmpData.Scan0, buffer.Length)
bmp.UnlockBits(bmpData)

If pictureBox.InvokeRequired Then
  pictureBox.Invoke(New MethodInvoker(Sub()
    Dim oldImg = pictureBox.Image
    pictureBox.Image = bmp
    If oldImg IsNot Nothing Then oldImg.Dispose()
  End Sub))
Else
  Dim oldImg = pictureBox.Image
  pictureBox.Image = bmp
  If oldImg IsNot Nothing Then oldImg.Dispose()
End If

Troubleshooting tips: mismatched pixel format or stride causes color/garbage lines—convert YUV->RGB and respect stride. Avoid UI-thread decoding (use background thread + Invoke). Use buffering/double‑buffered drawing for flicker, and prefer LockBits over per‑pixel operations for speed. If the goal is learning, extracting frames with ffmpeg and playing them in a timer loop is a simple proof of concept before integrating real‑time decoding.

Recommended Answers

All 3 Replies

You might be able to get source code from one of these open source programs.

no i want a tutorial

You probably won't find any tutorials, you might have to actually THINK out of the box.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.