I'm trying to use bind my application with youtube video playing in cefsharp browser but it's not working. I don't get what is wrong with my code:
c#
private async void Music_Play_Pause_Button_Click(object sender, EventArgs e){ try { //bring javascript method string script = "toggleVideoPlayback();"; var response = await music_player.EvaluateScriptAsync(script); if (response.Success && response.Result != null) { bool isPlaying = Convert.ToBoolean(response.Result); MessageBox.Show($"Video playback toggled: {(isPlaying ? "Playing" : "Paused")}"); } else { MessageBox.Show("Failed to toggle video playback."); } } catch (Exception ex) { MessageBox.Show($"Error toggling video playback: {ex.Message}"); }}javascript
function toggleVideoPlayback() { var videoElement = document.getElementById('player'); if (videoElement) { if (videoElement.paused) { videoElement.play(); } else { videoElement.pause(); } return !videoElement.paused; } else { return false; }}javascript and cs file is in the same folder and the message that I set to check, which is "Failed to toggle video playback." is the only thing that shows up. As you can see in my code, I expect when button is clicked, I want video to be paused or played