1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxMediaCtrl docs
4 %% Author: Ryan Norton <wxprojects@comcast.net>
8 %% Copyright: (c) Ryan Norton
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxMediaCtrl
}}\label{wxmediactrl
}
14 wxMediaCtrl is a class that allows a way to convieniently display types of
15 media, such as videos, audio files, natively through native codecs.
17 wxMediaCtrl uses native backends to render media, for example on Windows
18 there is a ActiveMovie/DirectShow backend, and on Macintosh there is a
21 wxMediaCtrl is not currently available on unix systems.
23 \wxheading{Derived from
}
25 \helpref{wxControl
}{wxcontrol
}
27 \wxheading{Include files
}
31 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{Rendering media
}\label{renderingmediawxmediactrl
}
35 wxMediaCtrl can generally, depending upon the backend, render
36 and display pretty much any kind of media that the native system can -
37 such as an image, mpeg video, or mp3 (without license restrictions -
38 sense it relies on native system calls that may not technically
39 have mp3 decoding available, for example, it falls outside the
40 realm of licensing restrictions).
42 For general operation, all you need to do is call
43 \helpref{wxMediaCtrl::Load
}{wxmediactrlload
} to load the file
44 you want to render, then call
\helpref{wxMediaCtrl::Play
}{wxmediactrlplay
}
45 to show the video/audio of the media.
47 More complex operations are generally more heavily dependant on the
48 capabilities of the backend. For example, QuickTime cannot set
49 the playback rate of certain streaming media - while DirectShow is
50 slightly more flexible in that regard.
52 \membersection{Operation
}\label{operationwxmediactrl
}
54 When wxMediaCtrl plays a file, it plays until the stop position
55 is reached (currently the end of the file/stream). Right before
56 it hits the end of the stream, it fires off a EVT
\_MEDIA\_STOP
57 event to its parent window, at which point the event handler
58 can choose to veto the event, preventing the stream from actually
63 //connect to the media event
64 this->Connect(wxMY_ID, wxEVT_MEDIA_STOP, (wxObjectEventFunction)
65 (wxEventFunction)(wxMediaEventFunction) &MyFrame::OnMediaStop);
68 void MyFrame::OnMediaStop(const wxMediaEvent& evt)
72 m_mediactrl->SetPosition(
73 m_mediactrl->GetDuration() <<
1
80 When wxMediaCtrl stops, either by the EVT
\_MEDIA\_STOP not being
81 vetoed, or by manually calling
82 \helpref{wxMediaCtrl::Stop
}{wxmediactrlstop
}, where it actually
83 stops is not at the beginning, rather, but at the beginning of
84 the stream. That is, when it stops and play is called, playback
85 is gauranteed to start at the beginning of the media. This is
86 because some streams are not seekable, and when stop is called
87 on them they return to the beginning, thus wxMediaCtrl tries
88 to keep consistant for all types of media.
90 \membersection{Choosing a backend
}\label{choosingbackendwxmediactrl
}
92 Generally, you should almost certainly leave this part up to
93 wxMediaCtrl - but if you need a certain backend for a particular
94 reason, such as QuickTime for playing .mov files, all you need
95 to do to choose a specific backend is to pass the
96 name of the backend class to
97 \helpref{wxMediaCtrl::Create
}{wxmediactrlcreate
}.
99 The following are valid backend identifiers -
101 \begin{twocollist
}\itemsep=
0pt
102 \twocolitem{{\bf wxMEDIABACKEND
\_DIRECTSHOW}}{
103 Use ActiveMovie/DirectShow. Requires wxUSE
\_DIRECTSHOW to be
104 enabled, requires linkage with the static library strmiids.lib,
105 and is available on Windows Only.
}
106 \twocolitem{{\bf wxMEDIABACKEND
\_QUICKTIME}}{
107 Use QuickTime. Windows and Mac Only.
}
108 \twocolitem{{\bf wxMEDIABACKEND
\_MCI}}{
109 Use Media Command Interface. Windows Only.
}
112 \membersection{wxMediaCtrl::wxMediaCtrl
}\label{wxmediactrlwxmediactrl
}
114 \func{}{wxMediaCtrl
}{\void}
116 Default constructor - you
\tt{must
} call Create before calling any other methods
119 \func{}{wxMediaCtrl
}{
120 \param{wxWindow*
}{parent
},
121 \param{const wxString\&
}{fileName = wxT("")
},
122 \param{wxWindowID
}{id
},
123 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
124 \param{const wxSize\&
}{size = wxDefaultSize
},
125 \param{long
}{style =
0},
126 \param{const wxString\&
}{szBackend = wxT("")
},
127 \param{const wxValidator&
}{validator = wxDefaultValidator
},
128 \param{const wxString\&
}{name = wxPanelNameStr
}
131 Constructor that calls
\helpref{Create
}{wxmediactrlcreate
}. You may prefer to call
\helpref{Create
}{wxmediactrlcreate
} directly to check to see if wxMediaCtrl is available on the system.
133 \docparam{parent
}{parent of this control. Must not be NULL.
}
134 \docparam{id
}{id to use for events
}
135 \docparam{fileName
}{If not empty, the path of a file to open.
}
136 \docparam{pos
}{Position to put control at.
}
137 \docparam{size
}{Size to put the control at and to stretch movie to.
}
138 \docparam{style
}{Optional styles.
}
139 \docparam{szBackend
}{Name of backend you want to use, leave blank to make
140 wxMediaCtrl figure it out.
}
141 \docparam{validator
}{validator to use.
}
142 \docparam{name
}{Window name.
}
145 \membersection{wxMediaCtrl::Create
}\label{wxmediactrlcreate
}
148 \param{wxWindow*
}{parent
},
149 \param{const wxString\&
}{fileName = wxT("")
},
150 \param{wxWindowID
}{id
},
151 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
152 \param{const wxSize\&
}{size = wxDefaultSize
},
153 \param{long
}{style =
0},
154 \param{const wxString\&
}{szBackend = wxT("")
},
155 \param{const wxValidator&
}{validator = wxDefaultValidator
},
156 \param{const wxString\&
}{name = wxPanelNameStr
}
159 Creates this control. Returns
\tt{false
} if it can't load the movie located at
\tt{fileName
} or it cannot load one of its native backends.
161 If you specify a file to open via
\tt{fileName
} and you don't specify a backend to use, wxMediaCtrl tries each of its backends until one that can render the path referred to by
\tt{fileName
} can be found.
163 \docparam{parent
}{parent of this control. Must not be NULL.
}
164 \docparam{id
}{id to use for events
}
165 \docparam{fileName
}{If not empty, the path of a file to open.
}
166 \docparam{pos
}{Position to put control at.
}
167 \docparam{size
}{Size to put the control at and to stretch movie to.
}
168 \docparam{style
}{Optional styles.
}
169 \docparam{szBackend
}{Name of backend you want to use, leave blank to make
170 wxMediaCtrl figure it out.
}
171 \docparam{validator
}{validator to use.
}
172 \docparam{name
}{Window name.
}
175 \membersection{wxMediaCtrl::GetDuration
}\label{wxmediactrlgetduration
}
177 \func{wxLongLong
}{GetDuration
}{\void}
179 Obtains the length - the total amount of time the movie has in milliseconds.
182 \membersection{wxMediaCtrl::GetPosition
}\label{wxmediactrlgetposition
}
184 \func{wxLongLong
}{GetPosition
}{\void}
186 Obtains the current position in time within the movie in milliseconds.
189 \membersection{wxMediaCtrl::GetState
}\label{wxmediactrlgetstate
}
191 \func{wxMediaCtrlState
}{GetState
}{\void}
193 Obtains the state the playback of the movie is in -
196 \begin{twocollist
}\itemsep=
0pt
197 \twocolitem{{\bf wxMEDIASTATE
\_STOPPED}}{The movie has stopped.
}
198 \twocolitem{{\bf wxMEDIASTATE
\_PAUSED}}{The movie is paused.
}
199 \twocolitem{{\bf wxMEDIASTATE
\_PLAYING}}{The movie is currently playing.
}
203 \membersection{wxMediaCtrl::Load
}\label{wxmediactrlload
}
205 \func{bool
}{Load
}{\param{const wxString\&
}{fileName
}}
207 Loads the file that
\tt{fileName
} refers to. Returns false if loading fails.
209 \membersection{wxMediaCtrl::Pause
}\label{wxmediactrlpause
}
211 \func{bool
}{Pause
}{\void}
213 Pauses playback of the movie.
216 \membersection{wxMediaCtrl::Play
}\label{wxmediactrlplay
}
218 \func{bool
}{Play
}{\void}
220 Resumes playback of the movie.
223 \membersection{wxMediaCtrl::SetPosition
}\label{wxmediactrlsetposition
}
225 \func{bool
}{SetPosition
}{\param{wxLongLong
}{where
}}
227 Seeks to a position within the movie.
230 \membersection{wxMediaCtrl::Stop
}\label{wxmediactrlstop
}
232 \func{bool
}{Stop
}{\void}
236 See
\helpref{Operation
}{operationwxmediactrl
} for an overview of how stopping works.