Hello I have an application that used to allow me to watch videos from youtube, but now the screen is completely black, I cannot view videos. I am using axmediaplayer and here is my code.
private void Form1_Load(object sender, EventArgs e)
{
// play video in embedded media player
axWindowsMediaPlayer1.URL = "http://www.youtube.com/v/Of9JCZ6zraQ";
}
Is it a change made on youtube or does any one know alternatives? it used to work before but not it is not working any more. does any one know what the problem is please?
Related
I have some code that takes opens my webcam via Emgu upon loading Form1. The problem I have, though, is that I can only load the first frame.
I have tried to use Webcam() to create a video capture, but it only takes the first frame. If I assign this code to a button, it will take only 1 frame upon each button press. I have tried to create a continuation of the video capture using Webcam2(), but the the picturebox had 1 FPS and would exponentially use more memory overtime.
I know it is not my computer as I was able to use webcam via emgu using its facial recognition viewer (I used the guide at https://www.youtube.com/watch?v=ZSxHyp4OZx0 to test this out). Unfortunately, while I am creating a a similar project, I am using AWS for the facial recognition. Still, I was able to run the Emgu camera viewer without any issues or bad framerates. My Laptop is a 2022 high end gaming laptop.
Here is the code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
showit();
//Application.Idle += Webcam2;
//Webcam();
}
private void Webcam2(object sender, EventArgs e)
{
VideoCapture capture = new VideoCapture();
pictureBox1.Image = capture.QueryFrame().ToBitmap();
}
private void Webcam()
{
VideoCapture capture = new VideoCapture();
pictureBox1.Image = capture.QueryFrame().ToBitmap();
}
}
Any idea what is going on?
I am working on a project and want to play a video from my computer with window media player on a window form , but its only playing audio and no video , i have added the wmp.dll
private void button1_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = #"C:\Users\Admin\Desktop\d1.mp4";
}
enter image description here
I have a axWindowsMediaPlayer on WinForm with uiMode=none. I am using my custom controls to handle playback. I am using this method to associate a trackBar with axWindowsMediaPlayer.
I want to change the video position (jump to specific time) when the user scrolls the trackBar, just like windows media player.
private void trackBar_Scroll(object sender, EventArgs e)
{
if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;
}
}
This is not working. I have checked many Stackoverflow answers including this, this, and the Microsoft documentation but none is working.
I have two objectives:
When playing media, the trackBar should show the current position of the media file being played. This is working fine.
When the user scrolls the trackBar, the media player should change the video current position based on the trackBar value. This is not working.
Any help will be highly appreciated.
I solved the issue. The problem was not with the media player, the problem was with the media files being played with the axWindowsMediaPlayer.
axWindowsMediaPlayer plays the files such as MKV fine, but if the proper codecs are not installed, the Ctlcontrols mainly the Trackbar does not work from code or UI. With natively supported formats, this code works perfectly fine.
private void trackBar_Scroll(object sender, EventArgs e)
{
if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;
}
For media files not natively supported, their codecs need to be installed. For details of supported file formats, see this KB article File types supported by Windows Media Player
I am creating a game, I want to display a short tutorial video to the player after they have registered. I am using a windows media player control. I don't know how to hide the video after it has finished playing ?
I tried using the following:
WMP.Ctlcontrols.play();
Thread.Sleep(3000);
WMP.Dispose();
I am using the disposing as a way to close down the video. I tried hide and close as well but they close the video before it's finished playing, after 3 seconds.
You can handle PlayStateChange event of control and check if e.newState==1, it means the playing has been stopped. Then you can hide the control.
void axWindowsMediaPlayer1_PlayStateChange(object sender,
AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(e.newState== 1) // Stopped
axWindowsMediaPlayer1.Hide();
}
I am using Aforge .NET framework to get a webcam in my app but I always get an all gray image frame.
this.videoSource = new VideoCaptureDevice(this.Moniker);
this.videoSource.DesiredFrameSize = GetHighestResolution(this.videoSource.VideoCapabilities);
this.videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
this.videoSource.Start();
The vent handler:
private void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.outputBox.Image = (Bitmap)eventArgs.Frame.Clone();
}
This should do the trick. DesiredFrameSize is set to the highest value the cam can support.
Any hints why the image is always gray? Even when writing it do disk...
Edit: To add: The same problem occurs with the sample application SimplePlayer from Aforge samples. My webcam is a Logitech QuickCam Pro 9000.
Edit2: The same goes for small DesiredFramesizes.
maybe the camera isnt wrapped around directshow (some sort of directx stuff).
some camera's come with their own driver, or different inner working.
I have some highspeed industrial camera's, with simmilar issues.
I had to retrieve the raw images from them using diffrent methods, then do aforge stuff on those images.
Maybe check your code using older cheap USB2 camera's