Reputation: 19
Can someone tell me how to embedd a simple (video) mediaplayer in VB.NET? .Net 6.0 (in vs2022) does not seem to support a mediaplayer.
Thanks
Upvotes: 0
Views: 2295
Reputation: 189
First u add VLC or media player object, here i post how to add media player in tool and how to play simple video files.
By default, 'Windows Media Player' control is not provided in the Toolbox, we have to add it into the toolbox if required. Inorder to add 'Windows Media Player' control into toolbox
Right click on 'General' tab (or anyother tab) in toolbox ->select 'Choose Items...' ->select 'COM Components' tab ->select 'Windows Media Player' ->click on 'OK' button.
Once u add media player, control will appear in VS tool bar, and from that u drag to ur form design.
Below the code to play video and audio files.
Imports System
Imports System.Windows.Forms
Namespace mymediaplayer Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnBrowse_Click(ByVal sender As Object, ByVal e As EventArgs)
openFileDialog1.Filter = "(mp3,wav,mp4,mov,wmv,mpg)|*.mp3;*.wav;*.mp4;*.mov;*.wmv;*.mpg|all files|*.*"
If openFileDialog1.ShowDialog() = DialogResult.OK Then axWindowsMediaPlayer1.URL = openFileDialog1.FileName
End Sub
End Class
End Namespace
Thanks and Regards Aravind
Upvotes: 1