embedded youtube in shockwave flash object winforms not working - c#

I'm trying to embed a youtube video in a winforms application.
When I click I button, a new panel pops up with the video in it and it should play.
However, it doesn't. There's just a black box and nothing happens. Here's what the code looks like for that button:
private void module1_summary_nextpic_Click(object sender, EventArgs e)
{
activePanel.Visible = false;
activePanel = module1_content;
module1_content.Size = module1_panel.Size;
activePanel.Visible = true;
doc1.LoadMovie(0, "http://youtu.be/2Vb8dg_un-A");
doc1.Play();
}
any ideas as to why it's not showing/playing? i'm using vs2012.
edit: i've tried this solution here: https://stackoverflow.com/questions/17666243/calling-play-on-c-sharp-shockwave-component-doesnt-start-youtube-video-playba?rq=1 with no avail.

There is a problem with your link. Link should be like this:
http://www.youtube.com/v/2Vb8dg_un-A
That will make youtube video embbeded. Also, if you want to make it to autoplay just add &autoplay=1 at the end of the link.

Related

Using the VLC ActiveX plugin to watch youtube videos C#

Recently I have started messing around with the VLC ActiveX plugin trying to play youtube videos in a WindowsFormApplication and I have run into some issues that I couldn't find any mention of or solution to. For simplicity I made a new project to demonstrate my problems:
private void button1_Click(object sender, EventArgs e)
{
Player.playlist.play();
}
private void button2_Click(object sender, EventArgs e)
{
url = textBox1.Text;
Player.playlist.add(url);
listBox1.Items.Add(url);
}
2 buttons, play and add to playlist.
Problem 1:
Audio cuts out a few seconds before the end of the video.
Problem 2:
I have been unable to get the control to play the next video in the playlist. It just reaches the end of the first video. If I click the play button again, it plays the first video. One thing I thought might be causing it was the AutoPlay property but it's set to true.
Problem 3:
The Player.playlist.next function, like most thing doesn't have a description and does not let me go to the next video in the playlist.
Problem 4:
The AutoLoop property does not work, assuming that it's supposed to get the control to loop a video.
Problems number 2 and 3 make me think that the songs aren't being added to the playlist correctly, but again I was unable to find any way to confirm or solve that issue.
Using VisualStudio 2015, VLC plugin version, as stated in the control properties, 3.0.1 Vetinari.
(edit) after testing I know that the videos are added to the playlist, but still it won't autoplay the next in playlist at the end.

How to hide MediaPlayer control in UWP

I am using MedialPlayer control to play sound effects in my app as explained here. Sounds are short sound effects that play "in the background" when something happens in the app, user should not see any sort of media playback control.
Code is fairly straight forward, looks something like this:
MediaPlayer mPlayer = new MediaPlayer();
mPlayer.Source = MediaSource.CreateFromUri(pathUri);
mPlayer.Play();
This works well, except, when user presses volume control button on the keyboard, a mini media player control appears next to volume control and the user can press play button to play the last sound again (see picture). I want to hide this. User should not see this or be able to replay sounds.
Solutions offered in question 14578867 do not work. Properties mentioned in the answers do not exist (e.g. IsPlayPauseVisible, uImode, IsInteractive). I tried using similar properties from SystemMediaTransportControls but it makes no difference. I think these are meant for the control that appears in the app (which I do not have), not for the "OS media control" that I want to hide.
mPlayer.SystemMediaTransportControls.IsEnabled = false;
mPlayer.SystemMediaTransportControls.IsPlayEnabled = false;
How can I disable/hide this?
Here is a step-by-step guide to replicate the issue:
Create a new Windows Universal Visual C# Blank App
Add a button to MainPage.xaml and mp3 file to assets
Paste below code to MainPage.cs
Run the app, click button
On the keyboard press volume up button
Observe the "media control" with play button next to volume control (see image above).
Pressing play button plays the sound again. If you are quick you can also pause the playback. SystemMediaTransportControls properties make no difference.
using Windows.Media.Core;
using Windows.Media.Playback;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
namespace App2
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void Button_Tapped(object sender, TappedRoutedEventArgs e)
{
MediaPlayer mPlayer = new MediaPlayer();
mPlayer.Source = MediaSource.CreateFromUri(new System.Uri("ms-appx:///Assets/clap.mp3"));
mPlayer.SystemMediaTransportControls.IsPlayEnabled = false;
mPlayer.SystemMediaTransportControls.IsEnabled = false;
mPlayer.Play();
}
}
}
It seems it is caused by the MediaPlayer is not ready, when we set false to the MediaPlayer.SystemMediaTransportControls.IsPlayEnabled.
We should be able to add MediaOpened event of the MediaPlayer, then we can set false to the MediaPlayer.SystemMediaTransportControls.IsPlayEnabled in the MediaOpened event.
For example:
MediaPlayer mPlayer;
private void Button_Click(object sender, RoutedEventArgs e)
{
mPlayer = new MediaPlayer();
mPlayer.Source = MediaSource.CreateFromUri(new System.Uri("ms-appx:///Assets/xxxxx.mp3"));
mPlayer.MediaOpened += MPlayer_MediaOpened;
mPlayer.Play();
}
private void MPlayer_MediaOpened(MediaPlayer sender, object args)
{
mPlayer.SystemMediaTransportControls.IsEnabled = false;
}
If you just disable the button that in SystemMediaTransportControls, you should be able to set false to MediaPlayer.CommandManager.IsEnabled.
If you are using MediaPlayer to play media, you can get an instance of the SystemMediaTransportControls class by accessing the MediaPlayer.SystemMediaTransportControls property. If you are going to manually control the SMTC, you should disable the automatic integration provided by MediaPlayer by setting the CommandManager.IsEnabled property to false.+
If you disable the MediaPlaybackCommandManager of the MediaPlayer by setting IsEnabled to false, it will break the link between the MediaPlayer the TransportControls provided by the MediaPlayerElement, so the built-in transport controls will no longer automatically control the playback of the player. Instead, you must implement your own controls to control the MediaPlayer.
For more info, see Set up transport controls.
For example:
_mediaPlayer = new MediaPlayer();
_systemMediaTransportControls = _mediaPlayer.SystemMediaTransportControls;
_mediaPlayer.CommandManager.IsEnabled = false;

windows media player c#

I am very new at c# and visual studio and now i am learning all the tools.
At first i tried adding background sound to my form. I added a wav file trhough resources and i changed it's build action to embedded resources so that i can "play" the .exe file without problems at any other pc.Then i wrote this and it worked.
namespace audio
{
public partial class Form1 : Form
{
SoundPlayer sp = new SoundPlayer(Properties.Resources.back_sound);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
sp.Play();
}
}
}
Now i want to play a video file with windows media player.I added it through COM components and i added it to my form.I can make it play any video just by adding the video file at the debug folder and write this.
private void button1_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = "video.AVI";
}
But as before i want to add it to my resources so that i can execute the .exe file to aby other pc and by this way, i cant
I tried with ( following the same pattern with the sound file)
AxWindowsMediaPlayer player = new AxWindowsMediaPlayer(Properties.Resources.video);
( and inside the button player.play();)
and
WindowsMediaPlayer player = new WindowsMediaPlayer(Properties.Resources.video);
( and inside the button player.play();)
but no luck.
Can anyone help me, please?
Thanks in advance
UPDATE:
I tried a lot of things and nothing worked, so i thought that it would better to stream the videos directly from youtube. I went to COM components and i added to my form a SHOCKWAVE FLASH OBJECT. I took the url i wanted, i transformed it ( from www.youtube.com/watch?v=xxxxxxxxxxxx to www.youtube.com/v/xxxxxxxxxxxx) i added it to the movie section of the flash object. It is working but only on my computer. If i execute the .exe in any other pc it doesnt work. It says that System.IO.FileNotFoundException.
What can i do to make it work?

Implementing activeX control to view PowerPoint slides in Windows forms using c#, not showing control

I'm working on a project and I need to embed a PowerPoint viewer in windows forms. I'm using the following activeX control: http://www.daolnwod.com/free-powerpoint-viewer-activex.html.
I activated the control to be used with the form designer's toolbox and dragged it into my form. I then edited the code in the InitializeComponent() method to the following:
this.axPowerPointViewer1 = new AxPOWERPOINTVIEWERLib.AxPowerPointViewer();
((System.ComponentModel.ISupportInitialize)(this.axPowerPointViewer1)).BeginInit();
this.axPowerPointViewer1.Enabled = true;
this.axPowerPointViewer1.Location = new System.Drawing.Point(0, 0);
this.axPowerPointViewer1.Name = "axPowerPointViewer1";
this.axPowerPointViewer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPowerPointViewer1.OcxState")));
this.axPowerPointViewer1.Size = new System.Drawing.Size(925, 573);
this.axPowerPointViewer1.TabIndex = 5;
//this.axPowerPointViewer1.CreateControl();
this.Controls.Add(this.axPowerPointViewer1);
((System.ComponentModel.ISupportInitialize)(this.axPowerPointViewer1)).EndInit();
And in my Forms constructor
public Form1()
{
InitializeComponent();
axPowerPointViewer1.Show();
bool loaded = axPowerPointViewer1.LoadFile(#"C:\Debug\test2.ppt"); // loaded = false
string z = axPowerPointViewer1.GetSlideCount().ToString();
}
However, when I'm opening the form nothing shows up. The code compiles but I can't see my test slide that I've been working on. I have created 2 buttons for 'Previous' and 'Next' slides but debugging gives me a slide location of 0 every time so something must be wrong and I can't seem to find it.
UPDATE
The problem has been solved. It seems I didn't call axPowerPointviewer1.InitControl(). It still has a few troubles, sometimes it won't display the first slide at startup. If things keep running smoothly I'll post an answer to this problem.
The problem is in initialising the control. In order for the control to fully function you need to call the InitControl() method so call calling the following code should make the program work:
private void Form1_Load(object sender, EventArgs e)
{
this.axPowerPointViewer1.InitControl();
}

Autopopulate textboxes in Sieble CRM system, trough webBrowser1 in c#

Do any have any experience how this cold be done, if you look at the image im looking for a solution to programacly change the Name field to somehing else stored inn a variable from a other textbox.
i was thinking of using something like
private void button1_Click(object sender, EventArgs e)
{
var xBox = textbox1.value;
webBrowser1.Document.All.GetElementsByName("Name")[0].SetAttribute("Value", xBox);
}
but i dont know the name of the Textbox, and Sieble seems to be a java thing? so i cant see the source behind it? does anyone know how to solve this issue. im making a automate app to help at work for handeling over 100 cases a day. Instead of typing the names, im looking for a solution to populate by the click of a button.
I cant handel this by the sieble API because we dont have contorle of the Siebel develompent, and wold take years to get the Sieble department to implement somthing like this in to the GUI. so im making a desktop app that can handel the issue.
Sounds like you need to just search through the html (manually) until you find the names/ids of the fields you need to set.
Also, if the site supports Firefox, try using Firebug. In Firebug's inspect mode you can mouse over a text field and get the id of it.
My solution to this was using cordinates, and simulate keys klicks, im using Global Mouse and Keyboard Library for this, found at this location http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx
private void button1_Click(object sender, EventArgs e)
{
this.Location = new Point(0, 0);
inputBlocker();
xX = int.Parse(this.Location.X.ToString());
yY = int.Parse(this.Location.Y.ToString());
defaultMousePos();
//Thread.Sleep(600);
Cursor.Position = new Point(Cursor.Position.X + 1185, Cursor.Position.Y + 254);
//Thread.Sleep(600);
MouseSimulator.DoubleClick(MouseButton.Left);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.E);
KeyboardSimulator.KeyPress(Keys.S);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.O);
KeyboardSimulator.KeyPress(Keys.K);
KeyboardSimulator.KeyPress(Keys.Enter);
needUnblock = true;
inputBlocker();
}
#Darkmage - Is this a winforms application ?.If so did you not have any issues with loading the siebel activeX controls in the .NET webroswer control?

Categories

Resources