Skip to content

Commit

Permalink
Example - AudioHandler now extends CefSharp.Handler.AudioHandler
Browse files Browse the repository at this point in the history
Fixes compile error as IAudioHandler now implements IDisposable
  • Loading branch information
amaitland committed Jun 4, 2021
1 parent a6ff42e commit d8abfa6
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions CefSharp.Example/Handlers/AudioHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,45 @@

namespace CefSharp.Example.Handlers
{
public class AudioHandler : IAudioHandler
public class AudioHandler : Handler.AudioHandler
{
private ChannelLayout channelLayout;
private int channelCount;
private int sampleRate;

bool IAudioHandler.GetAudioParameters(IWebBrowser chromiumWebBrowser, IBrowser browser, ref AudioParameters parameters)
protected override bool GetAudioParameters(IWebBrowser chromiumWebBrowser, IBrowser browser, ref AudioParameters parameters)
{
//Cancel Capture
return false;
}

void IAudioHandler.OnAudioStreamError(IWebBrowser chromiumWebBrowser, IBrowser browser, string errorMessage)
protected override void OnAudioStreamError(IWebBrowser chromiumWebBrowser, IBrowser browser, string errorMessage)
{
base.OnAudioStreamError(chromiumWebBrowser, browser, errorMessage);
}

protected override void OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, AudioParameters parameters, int channels)
{
this.channelLayout = parameters.ChannelLayout;
this.sampleRate = parameters.SampleRate;
this.channelCount = channels;
}

void IAudioHandler.OnAudioStreamPacket(IWebBrowser chromiumWebBrowser, IBrowser browser, IntPtr data, int noOfFrames, long pts)
protected override void OnAudioStreamPacket(IWebBrowser chromiumWebBrowser, IBrowser browser, IntPtr data, int noOfFrames, long pts)
{
//NOTE: data is an array representing the raw PCM data as a floating point type, i.e. 4-byte value(s)
//Based on and the channelLayout value passed to IAudioHandler.OnAudioStreamStarted
//you can calculate the size of the data array in bytes.
//See https://github.com/cefsharp/CefSharp/issues/2806 for discussion on implementing an example.
}

void IAudioHandler.OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, AudioParameters parameters, int channels)
protected override void OnAudioStreamStopped(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
this.channelLayout = parameters.ChannelLayout;
this.sampleRate = parameters.SampleRate;
this.channelCount = channels;
base.OnAudioStreamStopped(chromiumWebBrowser, browser);
}

void IAudioHandler.OnAudioStreamStopped(IWebBrowser chromiumWebBrowser, IBrowser browser)
protected override void Dispose(bool disposing)
{

base.Dispose(disposing);
}
}
}

0 comments on commit d8abfa6

Please sign in to comment.