Browse Source

Fix for MovieComponent on older OSX SDKs. Updated video page in big demo app.

tags/2021-05-28
jules 8 years ago
parent
commit
84da06214d
2 changed files with 15 additions and 16 deletions
  1. +10
    -15
      examples/Demo/Source/Demos/VideoDemo.cpp
  2. +5
    -1
      modules/juce_video/native/juce_mac_MovieComponent.mm

+ 10
- 15
examples/Demo/Source/Demos/VideoDemo.cpp View File

@@ -24,7 +24,7 @@
#include "../JuceDemoHeader.h" #include "../JuceDemoHeader.h"
#if JUCE_QUICKTIME || JUCE_DIRECTSHOW
#if JUCE_MAC || JUCE_DIRECTSHOW
//============================================================================== //==============================================================================
// so that we can easily have two video windows each with a file browser, wrap this up as a class.. // so that we can easily have two video windows each with a file browser, wrap this up as a class..
@@ -50,7 +50,7 @@ public:
fileChooser.setCurrentFile (file, true); fileChooser.setCurrentFile (file, true);
} }
void paintOverChildren (Graphics& g)
void paintOverChildren (Graphics& g) override
{ {
if (isDragOver) if (isDragOver)
{ {
@@ -59,28 +59,28 @@ public:
} }
} }
void resized()
void resized() override
{ {
videoComp.setBoundsWithCorrectAspectRatio (Rectangle<int> (0, 0, getWidth(), getHeight() - 30), videoComp.setBoundsWithCorrectAspectRatio (Rectangle<int> (0, 0, getWidth(), getHeight() - 30),
Justification::centred); Justification::centred);
fileChooser.setBounds (0, getHeight() - 24, getWidth(), 24); fileChooser.setBounds (0, getHeight() - 24, getWidth(), 24);
} }
bool isInterestedInDragSource (const SourceDetails&) { return true; }
bool isInterestedInDragSource (const SourceDetails&) override { return true; }
void itemDragEnter (const SourceDetails&)
void itemDragEnter (const SourceDetails&) override
{ {
isDragOver = true; isDragOver = true;
repaint(); repaint();
} }
void itemDragExit (const SourceDetails&)
void itemDragExit (const SourceDetails&) override
{ {
isDragOver = false; isDragOver = false;
repaint(); repaint();
} }
void itemDropped (const SourceDetails& dragSourceDetails)
void itemDropped (const SourceDetails& dragSourceDetails) override
{ {
setFile (dragSourceDetails.description.toString()); setFile (dragSourceDetails.description.toString());
isDragOver = false; isDragOver = false;
@@ -88,8 +88,8 @@ public:
} }
private: private:
#if JUCE_QUICKTIME
QuickTimeMovieComponent videoComp;
#if JUCE_MAC
MovieComponent videoComp;
#elif JUCE_DIRECTSHOW #elif JUCE_DIRECTSHOW
DirectShowComponent videoComp; DirectShowComponent videoComp;
#endif #endif
@@ -100,11 +100,7 @@ private:
void filenameComponentChanged (FilenameComponent*) override void filenameComponentChanged (FilenameComponent*) override
{ {
// this is called when the user changes the filename in the file chooser box // this is called when the user changes the filename in the file chooser box
#if JUCE_QUICKTIME
if (videoComp.loadMovie (fileChooser.getCurrentFile(), true))
#elif JUCE_DIRECTSHOW
if (videoComp.loadMovie (fileChooser.getCurrentFile())) if (videoComp.loadMovie (fileChooser.getCurrentFile()))
#endif
{ {
// loaded the file ok, so let's start it playing.. // loaded the file ok, so let's start it playing..
@@ -114,8 +110,7 @@ private:
else else
{ {
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Couldn't load the file!",
r.getErrorMessage());
"Couldn't load the file!", String());
} }
} }


+ 5
- 1
modules/juce_video/native/juce_mac_MovieComponent.mm View File

@@ -54,7 +54,11 @@ struct MovieComponent::Pimpl
player = [[AVPlayer alloc] initWithURL: url]; player = [[AVPlayer alloc] initWithURL: url];
player.actionAtItemEnd = AVPlayerActionAtItemEndPause; player.actionAtItemEnd = AVPlayerActionAtItemEndPause;
player.masterClock = CMClockGetHostTimeClock(); player.masterClock = CMClockGetHostTimeClock();
player.automaticallyWaitsToMinimizeStalling = NO;
if ([player respondsToSelector: @selector (setAutomaticallyWaitsToMinimizeStalling:)])
[player performSelector: @selector (setAutomaticallyWaitsToMinimizeStalling:)
withObject: nil];
[player pause]; [player pause];
playerLayer = [[AVPlayerLayer playerLayerWithPlayer: player] retain]; playerLayer = [[AVPlayerLayer playerLayerWithPlayer: player] retain];


Loading…
Cancel
Save