⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediactrl.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
📖 第 1 页 / 共 2 页
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name:        mediactrl.tex%% Purpose:     wxMediaCtrl docs%% Author:      Ryan Norton <wxprojects@comcast.net>%% Modified by:%% Created:     11/7/2004%% RCS-ID:      $Id: mediactrl.tex,v 1.12 2006/10/25 00:52:12 VZ Exp $%% Copyright:   (c) Ryan Norton%% License:     wxWindows license%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{\class{wxMediaCtrl}}\label{wxmediactrl}wxMediaCtrl is a class that allows a way to convieniently display types of media, such as videos, audio files, natively through native codecs.wxMediaCtrl uses native backends to render media, for example on Windowsthere is a ActiveMovie/DirectShow backend, and on Macintosh there is a QuickTime backend.\wxheading{See also}\helpref{wxMediaEvent}{wxmediaevent}\wxheading{Derived from}\helpref{wxControl}{wxcontrol}\wxheading{Include files}<wx/mediactrl.h>\latexignore{\rtfignore{\wxheading{Members}}}\membersection{Rendering media}\label{renderingmediawxmediactrl}Depending upon the backend, wxMediaCtrl can renderand display pretty much any kind of media that the native system can - such as an image, mpeg video, or mp3 (without license restrictions -since it relies on native system calls that may not technicallyhave mp3 decoding available, for example, it falls outside therealm of licensing restrictions).For general operation, all you need to do is call \helpref{wxMediaCtrl::Load}{wxmediactrlload} to load the fileyou want to render, catch the EVT\_MEDIA\_LOADED event,and then call \helpref{wxMediaCtrl::Play}{wxmediactrlplay} to show the video/audio of the media in that event.More complex operations are generally more heavily dependant on thecapabilities of the backend.  For example, QuickTime cannot setthe playback rate of certain streaming media - while DirectShow is slightly more flexible in that regard.\membersection{Operation}\label{operationwxmediactrl}When wxMediaCtrl plays a file, it plays until the stop positionis reached (currently the end of the file/stream).  Right beforeit hits the end of the stream, it fires off a EVT\_MEDIA\_STOPevent to its parent window, at which point the event handlercan choose to veto the event, preventing the stream from actuallystopping.Example:\begin{verbatim}//connect to the media eventthis->Connect(wxMY_ID, wxEVT_MEDIA_STOP, (wxObjectEventFunction)(wxEventFunction)(wxMediaEventFunction) &MyFrame::OnMediaStop);//...void MyFrame::OnMediaStop(const wxMediaEvent& evt){    if(bUserWantsToSeek)    {        m_mediactrl->SetPosition(            m_mediactrl->GetDuration() << 1                                );        evt.Veto();    }}\end{verbatim}When wxMediaCtrl stops, either by the EVT\_MEDIA\_STOP not beingvetoed, or by manually calling \helpref{wxMediaCtrl::Stop}{wxmediactrlstop}, where it actuallystops is not at the beginning, rather, but at the beginning ofthe stream.  That is, when it stops and play is called, playbackis gauranteed to start at the beginning of the media.  This is because some streams are not seekable, and when stop is calledon them they return to the beginning, thus wxMediaCtrl triesto keep consistant for all types of media.Note that when changing the state of the media through Play()and other methods, the media may not actually be in thewxMEDIASTATE\_PLAYING, for example. If you are relying on themedia being in certain state catch the event relevant to the state.See \helpref{wxMediaEvent}{wxmediaevent} for the kinds of eventsthat you can catch.\membersection{Video size}\label{videosizewxmediactrl}By default, wxMediaCtrl will scale the size of the video to therequested amount passed to either it's constructor or Create().After calling Load or performing an equivilant operation, youcan subsequently obtain the "real" size of the video (if thereis any) by calling GetBestSize(). Note that the actual resulton the display will be slightly different when ShowPlayerControlsis activated and the actual video size will be less thenspecified due to the extra controls provided by the native toolkit.In addition, the backend may modify GetBestSize() to include thesize of the extra controls - so if you want the real size of thevideo just disable ShowPlayerControls().The idea with setting GetBestSize to the size of the video isthat GetBestSize is a wxWindow-derived function that is calledwhen sizers on a window recalculate. What this means is thatif you use sizers by default the video will show in it'soriginal size without any extra assistance needed from the user.\membersection{Player controls}\label{playercontrolswxmediactrl}Normally, when you use wxMediaCtrl it is just a window for the video toplay in.  However, some toolkits have their own media player interface.For example, QuickTime generally has a bar below the video with a slider.A special feature available to wxMediaCtrl, you can use the toolkit's interface instead ofmaking your own by using the \helpref{ShowPlayerControls()}{wxmediactrlshowplayercontrols}function.  There are several options for the flags parameter, withthe two general flags being wxMEDIACTRLPLAYERCONTROLS\_NONE which turns offthe native interface, and wxMEDIACTRLPLAYERCONTROLS\_DEFAULT which letswxMediaCtrl decide what native controls on the interface. Be sure to reviewthe caveats outlined in \helpref{Video size}{videosizewxmediactrl} beforedoing so.\membersection{Choosing a backend}\label{choosingbackendwxmediactrl}Generally, you should almost certainly leave this part up towxMediaCtrl - but if you need a certain backend for a particularreason, such as QuickTime for playing .mov files, all you need to do to choose a specific backend is to pass thename of the backend class to \helpref{wxMediaCtrl::Create}{wxmediactrlcreate}.The following are valid backend identifiers -\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf wxMEDIABACKEND\_DIRECTSHOW}}{ Use ActiveMovie/DirectShow.  Uses the native ActiveMovie(I.E. DirectShow) control. Default backend on Windows andsupported by nearly all Windows versions, even someWindows CE versions. May display a windows media playerlogo while inactive. }\twocolitem{{\bf wxMEDIABACKEND\_QUICKTIME}}{Use QuickTime.  Mac Only.WARNING: May not working correctly embedded in a wxNotebook.}\twocolitem{{\bf wxMEDIABACKEND\_GSTREAMER}}{Use GStreamer.  Unix Only. Requires GStreamer 0.8 alongwith at the very least the xvimagesink, xoverlay, andgst-play modules of gstreamer to function. You need the correctmodules to play the relavant files, for example the mad moduleto play mp3s, etc.}\twocolitem{{\bf wxMEDIABACKEND\_WMP10}}{Uses Windows Media Player 10 (Windows only) - works on mobilemachines with Windows Media Player 10 and desktop machines witheither Windows Media Player 9 or 10}\end{twocollist}Note that other backends such as wxMEDIABACKEND\_MCI can now befound at wxCode.\membersection{Creating a backend}\label{creatingabackendwxmediactrl}Creating a backend for wxMediaCtrl is a rather simple process. Simply derivefrom wxMediaBackendCommonBase and implement the methods you want. The methodsin wxMediaBackend correspond to those in wxMediaCtrl except for CreateControlwhich does the actual creation of the control, in cases where a custom controlis not needed you may simply call wxControl::Create.You need to make sure to use the DECLARE\_CLASS and IMPLEMENT\_CLASS macros.The only real tricky part is that you need to make sure the file in compiledin, which if there are just backends in there will not happen and you may needto use a force link hack (see http://www.wxwidgets.org/wiki/index.php/RTTI).This is a rather simple example of how to create a backend in the\helpref{wxActiveXContainer}{wxactivexcontainer} documentation.\membersection{wxMediaCtrl::wxMediaCtrl}\label{wxmediactrlwxmediactrl}\func{}{wxMediaCtrl}{\void}Default constructor - you \tt{must} call Create before calling any other methodsof wxMediaCtrl.\func{}{wxMediaCtrl}{        \param{wxWindow* }{parent},         \param{wxWindowID }{id},         \param{const wxString\& }{fileName = wxT("")},        \param{const wxPoint\& }{pos = wxDefaultPosition},         \param{const wxSize\& }{size = wxDefaultSize},         \param{long }{style = 0},         \param{const wxString\& }{szBackend = wxT("")},        \param{const wxValidator& }{validator = wxDefaultValidator},        \param{const wxString\& }{name = wxPanelNameStr}                   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -