Add AudioThumbnail to a Viewport

Hey guys, I’m new to JUCE and want to add an AudioThumbnail to a viewport.
I got a parent component, wich is viewed in the viewport. Adding stuff like buttons and sliders via addAndMakeVisible() works fine, but since i cant add a AudioThumbnail via addAndMakeVisible(),
i have no idea how to do it. Any ideas?

Put your Component inside a ViewPort and in your Component in paint() use AudioThumbnail::drawChannels()


Thanks for your reply. I already tried to make my own class inheriting from Component, wrapping an AudioThumbnail inside of it, like in the FilePlayback-Demo from the examples. The problem is, I get a Runtime error, when trying to set the Bounds of my Component. My Class basically looks like this:

class LayerThumbnail    :       public Component,
    LayerThumbnail(AudioFormatManager& formatManager,

 	void paint(Graphics& g) override

		if (thumbnail.getTotalLength() > 0.0)
			thumbArea.removeFromBottom(scrollbar.getHeight() + 4);
			thumbnail.drawChannels(g, getLocalBounds(),
				visibleRange.getStart(), visibleRange.getEnd(), 1.0f);
			g.drawFittedText("(No audio file selected)", getLocalBounds(), Justification::centred, 2);

	 void resized() override

	AudioTransportSource& transportSource;
	Slider& zoomSlider;
	ScrollBar scrollbar;

	AudioThumbnailCache thumbnailCache;
	AudioThumbnail thumbnail;

In PluginEditor.h, I add:

ScopedPointer<LayerThumbnail> thumbnail;
AudioFormatManager formatManager;
AudioSourcePlayer audioSourcePlayer;
AudioTransportSource transportSource;

and in PluginEditor.cpp:

	thumbnail = new LayerThumbnail(formatManager, transportSource, zoomSlider);

wich works fine, but when i try to do

void ThumbAudioProcessorEditor::resized()
	thumbnail->setBounds(10, 10, 150, 50);

it compiles, and when I run it in Debugmode, it throws this exception:

Looks like you haven’t given LayerThumbnail a size anywhere. Therefore its width is zero in resized()

Ok now I gave LayerThumbnail a size via setSize() in its constructor, but the error is the same, when i try to set its Bounds in the PluginEditor. Do I have to do anything else to make it work? In the JUCE Demo it works just by creating an object of LayerThumbnail and adjust its size via SetBounds()