Вопрос

I have a simple WinForms C# application that embeds a ShockWave COM component on a form. I have a Test button that when clicked, calls the Play() method on the component. When I click the button nothing happens. The YouTube player is plainly visible in the ShockWave component with a video still and the player chrome in the frame, with a big Play button on it. But it doesn't start playing.

Sample code:

private void button1_Click(object sender, EventArgs e)
{
    axShockwaveFlash1.Play();
}

Does anyone know how to fix this? I'm wondering if it's because the ShockWave component might need to have "requires click to play" or some other registry/system setting cleared before the Play() method works? If that happens to be the case, then how can I do that programmatically so a new install works perfectly without putting the user through some kind of a pre-setup hassle?

Это было полезно?

Решение

With Youtube videos and AxShockwaveFlash objects the Play() method doesn't function, however, there is a nice workaround for this.

The secret is adding ?autoplay=1 to the end of the URL containing the video you wish to play.

Something like this will provide the desired effect:

private void button1_Click(object sender, EventArgs e)
{
    string path = @"http://www.youtube.com/v/Q-h4ulFK2Ek?autoplay=1";
    axShockwaveFlash1.Load(0, path);
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top