X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d0ee33f5c6908b4ac5e1364381f0ef00942e3936..f3a65c3e49b45b8771ff5c6c9fab948f1c936593:/src/mac/carbon/mediactrl.cpp diff --git a/src/mac/carbon/mediactrl.cpp b/src/mac/carbon/mediactrl.cpp index 7bfdb8b1fb..d2eb4c053f 100644 --- a/src/mac/carbon/mediactrl.cpp +++ b/src/mac/carbon/mediactrl.cpp @@ -66,9 +66,13 @@ //uma is for wxMacFSSpec #include "wx/mac/uma.h" #include "wx/timer.h" +#ifndef __DARWIN__ #include #include #include //Standard QT stuff +#else +#include +#endif //Determines whether version 4 of QT is installed (Pretty much for classic only) Boolean _wxIsQuickTime4Installed (void) @@ -114,6 +118,9 @@ public: virtual double GetPlaybackRate(); virtual bool SetPlaybackRate(double dRate); + virtual double GetVolume(); + virtual bool SetVolume(double); + void Cleanup(); void FinishLoad(); @@ -261,19 +268,19 @@ bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, if ( ! #if wxUSE_CREATEMOVIECONTROL - ctrl->wxWindow::Create(parent, id, pos, size, - wxWindow::MacRemoveBordersFromStyle(style), - name) + ctrl->wxWindow::Create(parent, id, pos, size, + wxWindow::MacRemoveBordersFromStyle(style), + name) #else - ctrl->wxControl::Create(parent, id, pos, size, - wxWindow::MacRemoveBordersFromStyle(style), - validator, name) + ctrl->wxControl::Create(parent, id, pos, size, + wxWindow::MacRemoveBordersFromStyle(style), + validator, name) #endif ) return false; #if wxUSE_VALIDATORS - ctrl->SetValidator(validator); + ctrl->SetValidator(validator); #endif m_ctrl = ctrl; @@ -411,28 +418,28 @@ void wxQTMediaBackend::FinishLoad() movieTrackEnabledOnly) != NULL) { #if wxUSE_CREATEMOVIECONTROL - // - //Native CreateMovieControl QT control (Thanks to Kevin Olliver's - //wxQTMovie for some of this). - // - #define GetControlPeer(whatever) ctrl->m_peer - wxMediaCtrl* ctrl = (wxMediaCtrl*) m_ctrl; - Rect bounds = wxMacGetBoundsForControl(m_ctrl, - m_ctrl->GetPosition(), - m_ctrl->GetSize()); - - //Dispose of old control for new one - if (GetControlPeer(m_ctrl) && GetControlPeer(m_ctrl)->Ok() ) - GetControlPeer(m_ctrl)->Dispose(); - - //Options- - //kMovieControlOptionXXX - //HideController - hide the movie controller - //LocateTopLeft - movie is pinned to top left rather than centered in the control - //EnableEditing - Allows programmatic editing and dragn'drop - //HandleEditingHI- Installs event stuff for edit menu - forces EnableEditing also - //SetKeysEnabled - Allows keyboard input - //ManuallyIdled - app handles movie idling rather than internal timer event loop + // + //Native CreateMovieControl QT control (Thanks to Kevin Olliver's + //wxQTMovie for some of this). + // + #define GetControlPeer(whatever) ctrl->m_peer + wxMediaCtrl* ctrl = (wxMediaCtrl*) m_ctrl; + Rect bounds = wxMacGetBoundsForControl(m_ctrl, + m_ctrl->GetPosition(), + m_ctrl->GetSize()); + + //Dispose of old control for new one + if (GetControlPeer(m_ctrl) && GetControlPeer(m_ctrl)->Ok() ) + GetControlPeer(m_ctrl)->Dispose(); + + //Options- + //kMovieControlOptionXXX + //HideController - hide the movie controller + //LocateTopLeft - movie is pinned to top left rather than centered in the control + //EnableEditing - Allows programmatic editing and dragn'drop + //HandleEditingHI- Installs event stuff for edit menu - forces EnableEditing also + //SetKeysEnabled - Allows keyboard input + //ManuallyIdled - app handles movie idling rather than internal timer event loop ::CreateMovieControl( (WindowRef) ctrl->MacGetTopLevelWindowRef(), //parent @@ -447,9 +454,9 @@ void wxQTMediaBackend::FinishLoad() ::EmbedControl(ctrl->m_peer->GetControlRef(), (ControlRef)ctrl->GetParent()->GetHandle()); #else - // - //"Emulation" - // + // + //"Emulation" + // SetMovieGWorld(m_movie, (CGrafPtr) GetWindowPort( @@ -473,6 +480,11 @@ void wxQTMediaBackend::FinishLoad() m_ctrl->GetParent()->Layout(); m_ctrl->GetParent()->Refresh(); m_ctrl->GetParent()->Update(); + + //send loaded event + wxMediaEvent theEvent(wxEVT_MEDIA_LOADED, + m_ctrl->GetId()); + m_ctrl->AddPendingEvent(theEvent); } //--------------------------------------------------------------------------- @@ -576,6 +588,53 @@ wxLongLong wxQTMediaBackend::GetPosition() } //--------------------------------------------------------------------------- +// wxQTMediaBackend::GetVolume +// +// Gets the volume through GetMovieVolume - which returns a 16 bit short - +// +// +--------+--------+ +// + (1) + (2) + +// +--------+--------+ +// +// (1) first 8 bits are value before decimal +// (2) second 8 bits are value after decimal +// +// Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to +// 1 (full gain and sound) +//--------------------------------------------------------------------------- +double wxQTMediaBackend::GetVolume() +{ + short sVolume = GetMovieVolume(m_movie); + + if(sVolume & (128 << 8)) //negative - no sound + return 0.0; + + return (sVolume & (127 << 8)) ? 1.0 : ((double)(sVolume & 255)) / 255.0; +} + +//--------------------------------------------------------------------------- +// wxQTMediaBackend::SetVolume +// +// Sets the volume through SetMovieVolume - which takes a 16 bit short - +// +// +--------+--------+ +// + (1) + (2) + +// +--------+--------+ +// +// (1) first 8 bits are value before decimal +// (2) second 8 bits are value after decimal +// +// Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to +// 1 (full gain and sound) +//--------------------------------------------------------------------------- +bool wxQTMediaBackend::SetVolume(double dVolume) +{ + short sVolume = (short) (dVolume >= .9999 ? 1 << 8 : (dVolume * 255) ); + SetMovieVolume(m_movie, sVolume); + return true; +} + + //--------------------------------------------------------------------------- // wxQTMediaBackend::GetDuration // // Calls GetMovieDuration @@ -671,8 +730,3 @@ void wxQTMediaBackend::Move(int x, int y, int w, int h) FORCE_LINK_ME(basewxmediabackends); #endif //wxUSE_MEDIACTRL - - - - -