I have embed CefSharp in my application using C# but looks like browser rendering is not proper (screenshot is attached below). I tried to find the issue without a success.
This is how I am initializing CEF :
public Form1() {
InitializeComponent();
InitializeChromium();
}
public void InitializeChromium() {
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
chromeBrowser = new ChromiumWebBrowser("http://www.google.com");
chromeBrowser.Dock = DockStyle.Fill;
this.Controls.Add(chromeBrowser);
}
Error picture 01
I want to know why this is happening?, thank you.
Related
This Question is In reference with my previous question Embedding VLC player in WInform Application in .Net Core. Core.Intialize() Giving Exception
I want to run the player for certain time and during that time video should be on repeat. Currently code looks like this ...
Core.Initialize();
var libvlc = new LibVLC();
// Make VideoView control
VideoView vv = new VideoView();
vv.MediaPlayer = new MediaPlayer(libvlc);
vv.Dock = DockStyle.Fill;
// Add it to the form
Controls.Add(vv);
var uri = new Uri(#"C:\vid.3gp");
// Use command line options as Options for media playback (https://wiki.videolan.org/VLC_command-line_help/)
var media = new Media(libvlc, uri, ":input-repeat=65535");
vv.MediaPlayer.Play(media);
//Set fullscreen
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = Screen.PrimaryScreen.Bounds.Location;
How I can close the player after certain time. currently even if I close the form with the player video keeps playing in background till I close the whole application.
Just to inform the this winform application is created in .netcore3.1.
Regards.
Create MediaPlayer as class field and call it to start/pause/stop it in you WinForm application.
private LibVLC _libVlc;
private MediaPlayer _mediaPlayer;
...
// Call this method in your constructor/initializer
private void StartMediaPlayer(string videoUrl)
{
using var media = new Media(_libVlc, new Uri(videoUrl), ":input-repeat=65535");
_mediaPlayer = new MediaPlayer(_libVlc)
{
Media = media
};
_mediaPlayer.Play();
}
// Method to stop media player
private void button1_Click(object sender, EventArgs e)
{
_mediaPlayer.Stop();
}
I am currently developing a program where I can view and send data to an Arduino however I am unsure how to create a window Application that I can move the tabe inside it.
This Tab should be scaleable, pinnable, closeable, and can snap into corners or between other modules. Will I have to create this system From scratch or are there already packages out there that do this ?.
Example of what i try to do
all the telemetry data are in single tab, which can be moved or closed. I am trying to build a win form to do that Task
First of all I am trying to make a moveable Tabe , then scale it up with many modules at once. I am having trouble finding information about moveable Tabe in a winform so if you know of any information to help me out please let me know!
In Winforms, maybe you can try MDI. The link: Multiple-Document Interface (MDI) Applications is the document to create MDI Parent&Child you can refer to.
First, we need to set the "Main Form" as an MDIContainer.
public MainForm()
{
InitializeComponent();
this.IsMdiContainer = true;
}
Then, set the "Child Form"s' MdiParent to the "Main Form".
private void MainForm_Load(object sender, EventArgs e)
{
// Form1
MdiChildForm newMDIChild = new MdiChildForm();
newMDIChild.Size = new Size(200, 200);
newMDIChild.MdiParent = this;
newMDIChild.Show();
newMDIChild.Location = new Point(0, 0);
// Form2
MdiChildForm2 newMDIChild2 = new MdiChildForm2();
newMDIChild2.Size = new Size(500, 200);
newMDIChild2.MdiParent = this;
newMDIChild2.Show();
newMDIChild2.Location = new Point(210, 0);
}
The test result,
I have a little c# winforms app, that plays some youtube videos. To play them, i'm using cefsharp because the winforms browser (IE9) doesn't support it.
everything is working fine, but i'd like to change the audio source name displayed in the volume mixer to the name of the app. (Currently it is "CefSharp.BrowserSubProcess")
here's the code i'm using to initialize the browser object
public ChromiumWebBrowser Browser;
public void InitializeChromium(string url, string cachepath)
{
CefSettings settings = new CefSettings();
// Initialize cef with the provided settings
settings.CachePath = cachepath;
//Handle cookies, such as yt login
if (!Directory.Exists(Path.Combine(cachepath, "Extensions")))
{
Directory.CreateDirectory(Path.Combine(cachepath, "Extensions"));
}
Cef.Initialize(settings);
// Create a browser component
Browser = new ChromiumWebBrowser(url);
// Add it to the form and fill it to the form window.
this.Controls.Add(Browser);
Browser.Dock = DockStyle.Fill;
Browser.AddressChanged += Browser_AddressChanged;
Browser.TitleChanged += Browser_TitleChanged;
KeyDown += Browser_KeyDown;
}
It is possible?
if yes, do i need to use some special arguments?
thanks in advice.
I'm having problems with trying to save HTML source code into specific file. My goal is to save data that I get from "chromeBrowser.GetBrowser().MainFrame.ViewSource();" in "OnLoadingStateChanged" method into a file named "html.txt". Is it possible to do that?
public void InitializeChromiumWebBrowser()
{
CefSettings cefSettings = new CefSettings();
Cef.Initialize(cefSettings);
chromeBrowser = new ChromiumWebBrowser("https://google.com");
this.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
chromeBrowser.LoadingStateChanged += OnLoadingStateChanged;
}
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
{
if (!args.IsLoading)
chromeBrowser.GetBrowser().MainFrame.ViewSource();
}
I need exactly this method that is used in given code.
I've tried getting HTML Code through WebClient, HTTPWebRequest, GetSourceAsync, but none of those solutions work for my case.
I am having problems using the WaveformTimeLine class in the WPF Sound Visualization Library using the NAUDIO class library.I have followed the instructions they have put out in their documentation but it's just not working for me.
My code behind looks like:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private OpenFileDialog dialogBox = new OpenFileDialog();
private void open_Click(object sender, RoutedEventArgs e)
{
//Get Audio File
dialogBox.Filter = "Wave File (*.mp3 ; *.wav) | *.mp3;*.wav;";
if (dialogBox.ShowDialog() == true)
{
NAudioEngine.Instance.OpenFile(dialogBox.FileName);
fileLocation = dialogBox.FileName;
}
var soundEngine = NAudioEngine.Instance;
soundEngine.PropertyChanged += NAudioEngine_PropertyChanged;
soundEngine.OpenFile(fileLocation);
if (NAudioEngine.Instance.CanPlay) NAudioEngine.Instance.Play();
myWave = new WaveformTimeline();
myWave.RegisterSoundPlayer(soundEngine);
}
The code doesn't throw any errors but it also doesn't do anything too.Can someone with experience with this API or similar APIs please help me solve this problem.
Key mistake was the line
myWave = new WaveformTimeline();
After adding the WaveformTimeline control in XAML design view, you don't initialise the control again in the code behind because you will be given another instance of the WaveformTimeline object.