• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Audio/Video Playback Development<a name="EN-US_TOPIC_0000001051930589"></a>
2
3## When to Use<a name="section186634310418"></a>
4
5Audio and video playback is a process to decode audio and video files or stream data and play them by an output device. During the process, playback tasks are managed.
6
7## Available APIs<a name="section125479541744"></a>
8
9The following table describes APIs available for audio and video playback.
10
11**Table  1**  APIs available for media playback
12
13<a name="table1139164071320"></a>
14<table><thead align="left"><tr id="row85501040111310"><th class="cellrowborder" valign="top" width="15.959999999999999%" id="mcps1.2.4.1.1"><p id="p755044051316"><a name="p755044051316"></a><a name="p755044051316"></a>API</p>
15</th>
16<th class="cellrowborder" valign="top" width="47.77%" id="mcps1.2.4.1.2"><p id="p1755024018131"><a name="p1755024018131"></a><a name="p1755024018131"></a>Function</p>
17</th>
18<th class="cellrowborder" valign="top" width="36.27%" id="mcps1.2.4.1.3"><p id="p8550134015131"><a name="p8550134015131"></a><a name="p8550134015131"></a>Description</p>
19</th>
20</tr>
21</thead>
22<tbody><tr id="row14550164011132"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p55505406135"><a name="p55505406135"></a><a name="p55505406135"></a>Player</p>
23</td>
24<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p15550240191312"><a name="p15550240191312"></a><a name="p15550240191312"></a>int32_t SetSource(const Source &amp;source);</p>
25</td>
26<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p125502402132"><a name="p125502402132"></a><a name="p125502402132"></a>Sets the playback source for the player.</p>
27</td>
28</tr>
29<tr id="row155044001318"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p255064021310"><a name="p255064021310"></a><a name="p255064021310"></a>Player</p>
30</td>
31<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p10550104014132"><a name="p10550104014132"></a><a name="p10550104014132"></a>int32_t Prepare();</p>
32</td>
33<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p155503406138"><a name="p155503406138"></a><a name="p155503406138"></a>Prepares the playback environment.</p>
34</td>
35</tr>
36<tr id="row165502040141313"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p3550174081313"><a name="p3550174081313"></a><a name="p3550174081313"></a>Player</p>
37</td>
38<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p9550144011310"><a name="p9550144011310"></a><a name="p9550144011310"></a>int32_t Play();</p>
39</td>
40<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p255094041314"><a name="p255094041314"></a><a name="p255094041314"></a>Starts playback.</p>
41</td>
42</tr>
43<tr id="row855064010130"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p3550840151318"><a name="p3550840151318"></a><a name="p3550840151318"></a>Player</p>
44</td>
45<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p195501409137"><a name="p195501409137"></a><a name="p195501409137"></a>bool IsPlaying()</p>
46</td>
47<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p255114020137"><a name="p255114020137"></a><a name="p255114020137"></a>Checks whether the player is playing.</p>
48</td>
49</tr>
50<tr id="row1555111402135"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p05511840151313"><a name="p05511840151313"></a><a name="p05511840151313"></a>Player</p>
51</td>
52<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p16551340151314"><a name="p16551340151314"></a><a name="p16551340151314"></a>int32_t Pause();</p>
53</td>
54<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p14551164021311"><a name="p14551164021311"></a><a name="p14551164021311"></a>Pauses playback.</p>
55</td>
56</tr>
57<tr id="row155511740111315"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p185515403139"><a name="p185515403139"></a><a name="p185515403139"></a>Player</p>
58</td>
59<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p19551184031318"><a name="p19551184031318"></a><a name="p19551184031318"></a>int32_t Stop();</p>
60</td>
61<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p555154041312"><a name="p555154041312"></a><a name="p555154041312"></a>Stops playback.</p>
62</td>
63</tr>
64<tr id="row1255118400138"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p6551114081317"><a name="p6551114081317"></a><a name="p6551114081317"></a>Player</p>
65</td>
66<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p8551154015135"><a name="p8551154015135"></a><a name="p8551154015135"></a>int32_t Rewind(int_64 mSeconds, int32_t mode);</p>
67</td>
68<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p1255184019138"><a name="p1255184019138"></a><a name="p1255184019138"></a>Changes the playback position.</p>
69</td>
70</tr>
71<tr id="row195511640141312"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1455164061314"><a name="p1455164061314"></a><a name="p1455164061314"></a>Player</p>
72</td>
73<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p5551340151313"><a name="p5551340151313"></a><a name="p5551340151313"></a>int32_t SetVolume(float leftVolume, float rightVolume);</p>
74</td>
75<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p19551940181320"><a name="p19551940181320"></a><a name="p19551940181320"></a>Sets player volume, including volume of left and right channels.</p>
76</td>
77</tr>
78<tr id="row19551144015130"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p2055113408131"><a name="p2055113408131"></a><a name="p2055113408131"></a>Player</p>
79</td>
80<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1055124011314"><a name="p1055124011314"></a><a name="p1055124011314"></a>int32_t SetVideoSurface(Surface *surface)</p>
81</td>
82<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p1355104041311"><a name="p1355104041311"></a><a name="p1355104041311"></a>Sets a surface for video playback.</p>
83</td>
84</tr>
85<tr id="row1355174010135"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p85511140161313"><a name="p85511140161313"></a><a name="p85511140161313"></a>Player</p>
86</td>
87<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p155114401137"><a name="p155114401137"></a><a name="p155114401137"></a>int32_t EnableSingleLooping(bool loop)</p>
88</td>
89<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p05513403130"><a name="p05513403130"></a><a name="p05513403130"></a>Enables loop playback.</p>
90</td>
91</tr>
92<tr id="row185511040151319"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p3552124010139"><a name="p3552124010139"></a><a name="p3552124010139"></a>Player</p>
93</td>
94<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p6552144021318"><a name="p6552144021318"></a><a name="p6552144021318"></a>bool IsSingleLooping();</p>
95</td>
96<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p555220403134"><a name="p555220403134"></a><a name="p555220403134"></a>Checks whether loop playback is enabled.</p>
97</td>
98</tr>
99<tr id="row24941622111618"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1555214041314"><a name="p1555214041314"></a><a name="p1555214041314"></a>Player</p>
100</td>
101<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1655294011317"><a name="p1655294011317"></a><a name="p1655294011317"></a>int32_t GetCurrentTime(int64_t &amp;time) const;</p>
102</td>
103<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p255234031315"><a name="p255234031315"></a><a name="p255234031315"></a>Obtains the current playback duration, accurate to millisecond.</p>
104</td>
105</tr>
106<tr id="row655224015139"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p165520406137"><a name="p165520406137"></a><a name="p165520406137"></a>Player</p>
107</td>
108<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p7552164071320"><a name="p7552164071320"></a><a name="p7552164071320"></a>int32_t GetDuration(int64_t &amp;duration) const;</p>
109</td>
110<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p17552640141312"><a name="p17552640141312"></a><a name="p17552640141312"></a>Obtains the total duration of media files, in milliseconds.</p>
111</td>
112</tr>
113<tr id="row11552194019131"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p955214013132"><a name="p955214013132"></a><a name="p955214013132"></a>Player</p>
114</td>
115<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p655234018131"><a name="p655234018131"></a><a name="p655234018131"></a>int32_t GetVideoWidth(int32_t &amp;videoWidth);</p>
116</td>
117<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p12552174081314"><a name="p12552174081314"></a><a name="p12552174081314"></a>Obtains the width of the video.</p>
118</td>
119</tr>
120<tr id="row8552164013134"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p125525404136"><a name="p125525404136"></a><a name="p125525404136"></a>Player</p>
121</td>
122<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p13552114011316"><a name="p13552114011316"></a><a name="p13552114011316"></a>int32_t GetVideoHeight(int32_t &amp;videoHeight);</p>
123</td>
124<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p14552134011138"><a name="p14552134011138"></a><a name="p14552134011138"></a>Obtains the height of the video.</p>
125</td>
126</tr>
127<tr id="row6552340181312"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1155244017138"><a name="p1155244017138"></a><a name="p1155244017138"></a>Player</p>
128</td>
129<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1955374031313"><a name="p1955374031313"></a><a name="p1955374031313"></a>int32_t Reset();</p>
130</td>
131<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p1553124061317"><a name="p1553124061317"></a><a name="p1553124061317"></a>Restores the player to the initial state.</p>
132</td>
133</tr>
134<tr id="row6553134021311"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1655314021316"><a name="p1655314021316"></a><a name="p1655314021316"></a>Player</p>
135</td>
136<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p13553194018132"><a name="p13553194018132"></a><a name="p13553194018132"></a>int32_t Release();</p>
137</td>
138<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p455354018139"><a name="p455354018139"></a><a name="p455354018139"></a>Releases player resources.</p>
139</td>
140</tr>
141<tr id="row25531940151318"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p95531440191318"><a name="p95531440191318"></a><a name="p95531440191318"></a>Player</p>
142</td>
143<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1955317400131"><a name="p1955317400131"></a><a name="p1955317400131"></a>void SetPlayerCallback(const std::shared_ptr&lt;PlayerCallback&gt; &amp;cb);</p>
144</td>
145<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p135530402139"><a name="p135530402139"></a><a name="p135530402139"></a>Sets a player callback.</p>
146</td>
147</tr>
148<tr id="row26841936205916"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p155531940171317"><a name="p155531940171317"></a><a name="p155531940171317"></a>Source</p>
149</td>
150<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1955314012137"><a name="p1955314012137"></a><a name="p1955314012137"></a>Source(const std::string&amp; uri);</p>
151</td>
152<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p755314031315"><a name="p755314031315"></a><a name="p755314031315"></a>A constructor used to create a <strong id="b898542419341"><a name="b898542419341"></a><a name="b898542419341"></a>Source</strong> instance based on a specified URI.</p>
153</td>
154</tr>
155<tr id="row16713165319598"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p195531740141316"><a name="p195531740141316"></a><a name="p195531740141316"></a>Source</p>
156</td>
157<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p655310403132"><a name="p655310403132"></a><a name="p655310403132"></a>Source(const std::shared_ptr&lt;StreamSource&gt; &amp;stream, const Format &amp;formats);</p>
158</td>
159<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p05536401138"><a name="p05536401138"></a><a name="p05536401138"></a>A constructor used to create a <strong id="b39632476347"><a name="b39632476347"></a><a name="b39632476347"></a>Source</strong> instance based on the stream source and format information.</p>
160</td>
161</tr>
162<tr id="row39004563590"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p15531340191312"><a name="p15531340191312"></a><a name="p15531340191312"></a>Source</p>
163</td>
164<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p13553174091318"><a name="p13553174091318"></a><a name="p13553174091318"></a>SourceType GetSourceType() const;</p>
165</td>
166<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p1455354016136"><a name="p1455354016136"></a><a name="p1455354016136"></a>Obtains the source type.</p>
167</td>
168</tr>
169<tr id="row15429101008"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1655434018139"><a name="p1655434018139"></a><a name="p1655434018139"></a>Source</p>
170</td>
171<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p7554154013137"><a name="p7554154013137"></a><a name="p7554154013137"></a>const std::string &amp;GetSourceUri() const;</p>
172</td>
173<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p1855414071310"><a name="p1855414071310"></a><a name="p1855414071310"></a>Obtains the media source URI.</p>
174</td>
175</tr>
176<tr id="row17477411011"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p105540409134"><a name="p105540409134"></a><a name="p105540409134"></a>Source</p>
177</td>
178<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1355434014138"><a name="p1355434014138"></a><a name="p1355434014138"></a>const std::shared_ptr&lt;StreamSource&gt; &amp;GetSourceStream() const;</p>
179</td>
180<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p455415408132"><a name="p455415408132"></a><a name="p455415408132"></a>Obtains information about the media source stream.</p>
181</td>
182</tr>
183<tr id="row19135971706"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p257064871110"><a name="p257064871110"></a><a name="p257064871110"></a>Source</p>
184</td>
185<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p151191016151214"><a name="p151191016151214"></a><a name="p151191016151214"></a>const Format &amp;GetSourceStreamFormat() const;</p>
186</td>
187<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p14257126131210"><a name="p14257126131210"></a><a name="p14257126131210"></a>Obtains the media source stream format.</p>
188</td>
189</tr>
190<tr id="row1543179104"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p255412409135"><a name="p255412409135"></a><a name="p255412409135"></a>Format</p>
191</td>
192<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p655454001314"><a name="p655454001314"></a><a name="p655454001314"></a>bool PutIntValue(const std::string &amp;key, int32_t value);</p>
193</td>
194<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p205661711619"><a name="p205661711619"></a><a name="p205661711619"></a>Sets metadata of the integer type.</p>
195</td>
196</tr>
197<tr id="row695314111204"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p655454019138"><a name="p655454019138"></a><a name="p655454019138"></a>Format</p>
198</td>
199<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1554840111319"><a name="p1554840111319"></a><a name="p1554840111319"></a>bool PutLongValue(const std::string &amp;key, int64_t value);</p>
200</td>
201<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p230317337163"><a name="p230317337163"></a><a name="p230317337163"></a>Sets metadata of the long integer type.</p>
202</td>
203</tr>
204<tr id="row3518133213019"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1855434031312"><a name="p1855434031312"></a><a name="p1855434031312"></a>Format</p>
205</td>
206<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p1555484014139"><a name="p1555484014139"></a><a name="p1555484014139"></a>bool PutFloatValue(const std::string &amp;key, float value);</p>
207</td>
208<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p12391147111614"><a name="p12391147111614"></a><a name="p12391147111614"></a>Sets metadata of the single-precision floating-point type.</p>
209</td>
210</tr>
211<tr id="row176434351308"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p655534031317"><a name="p655534031317"></a><a name="p655534031317"></a>Format</p>
212</td>
213<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p5555640111320"><a name="p5555640111320"></a><a name="p5555640111320"></a>bool PutDoubleValue(const std::string &amp;key, double value);</p>
214</td>
215<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p185881525191711"><a name="p185881525191711"></a><a name="p185881525191711"></a>Sets metadata of the double-precision floating-point type.</p>
216</td>
217</tr>
218<tr id="row9476163810013"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p3555154017133"><a name="p3555154017133"></a><a name="p3555154017133"></a>Format</p>
219</td>
220<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p3555124015133"><a name="p3555124015133"></a><a name="p3555124015133"></a>bool PutStringValue(const std::string &amp;key, const std::string &amp;value);</p>
221</td>
222<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p16021743131719"><a name="p16021743131719"></a><a name="p16021743131719"></a>Sets metadata of the string type.</p>
223</td>
224</tr>
225<tr id="row879515406015"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p15551540181313"><a name="p15551540181313"></a><a name="p15551540181313"></a>Format</p>
226</td>
227<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p19555164041313"><a name="p19555164041313"></a><a name="p19555164041313"></a>bool GetIntValue(const std::string &amp;key, int32_t &amp;value) const;</p>
228</td>
229<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p435725714171"><a name="p435725714171"></a><a name="p435725714171"></a>Obtains the metadata value of the integer type.</p>
230</td>
231</tr>
232<tr id="row462919431104"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1655544021318"><a name="p1655544021318"></a><a name="p1655544021318"></a>Format</p>
233</td>
234<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p0555194031314"><a name="p0555194031314"></a><a name="p0555194031314"></a>bool GetLongValue(const std::string &amp;key, int64_t &amp;value) const;</p>
235</td>
236<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p7330132141811"><a name="p7330132141811"></a><a name="p7330132141811"></a>Obtains the metadata value of the long integer type.</p>
237</td>
238</tr>
239<tr id="row1797513451904"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1655624011319"><a name="p1655624011319"></a><a name="p1655624011319"></a>Format</p>
240</td>
241<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p155567401134"><a name="p155567401134"></a><a name="p155567401134"></a>bool GetFloatValue(const std::string &amp;key, float &amp;value) const;</p>
242</td>
243<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p080203817189"><a name="p080203817189"></a><a name="p080203817189"></a>Obtains the metadata value of the single-precision floating-point type.</p>
244</td>
245</tr>
246<tr id="row012319491603"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p855694013132"><a name="p855694013132"></a><a name="p855694013132"></a>Format</p>
247</td>
248<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p10556124015132"><a name="p10556124015132"></a><a name="p10556124015132"></a>bool GetDoubleValue(const std::string &amp;key, double &amp;value) const;</p>
249</td>
250<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p116117558189"><a name="p116117558189"></a><a name="p116117558189"></a>Obtains the metadata value of the double-precision floating-point type.</p>
251</td>
252</tr>
253<tr id="row22531651901"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p1855604081314"><a name="p1855604081314"></a><a name="p1855604081314"></a>Format</p>
254</td>
255<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p9556840171310"><a name="p9556840171310"></a><a name="p9556840171310"></a>bool GetStringValue(const std::string &amp;key, std::string &amp;value) const;</p>
256</td>
257<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p6495161451914"><a name="p6495161451914"></a><a name="p6495161451914"></a>Obtains the metadata value of the string type.</p>
258</td>
259</tr>
260<tr id="row552743019"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p165563405133"><a name="p165563405133"></a><a name="p165563405133"></a>Format</p>
261</td>
262<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p4556134061315"><a name="p4556134061315"></a><a name="p4556134061315"></a>const std::map&lt;std::string, FormatData *&gt; &amp;GetFormatMap() const;</p>
263</td>
264<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p4933161261817"><a name="p4933161261817"></a><a name="p4933161261817"></a>Obtains the metadata map.</p>
265</td>
266</tr>
267<tr id="row127651251115"><td class="cellrowborder" valign="top" width="15.959999999999999%" headers="mcps1.2.4.1.1 "><p id="p16556240111315"><a name="p16556240111315"></a><a name="p16556240111315"></a>Format</p>
268</td>
269<td class="cellrowborder" valign="top" width="47.77%" headers="mcps1.2.4.1.2 "><p id="p195561240111317"><a name="p195561240111317"></a><a name="p195561240111317"></a>bool CopyFrom(const Format &amp;format);</p>
270</td>
271<td class="cellrowborder" valign="top" width="36.27%" headers="mcps1.2.4.1.3 "><p id="p185953195717"><a name="p185953195717"></a><a name="p185953195717"></a>Sets all metadata to a specified format.</p>
272</td>
273</tr>
274</tbody>
275</table>
276
277## Limitations and Constraints<a name="section1165911177314"></a>
278
279When the input source is a media stream, the playback progress cannot be controlled and the file duration cannot be obtained.
280
281## How to Develop<a name="section34171333656"></a>
282
2831.  Implement a  **PlayerCallback**  function, register the callback via  **SetPlayerCallback**  for event processing.
284
285    ```
286    class TestPlayerCallback : public PlayerCallback{
287        void OnPlaybackComplete() override
288        {
289            // Process the event that the file playback is complete.
290        }
291        void OnError(int32_t errorType, int32_t errorCode) override
292        {
293            // Process the error event.
294        }
295        void OnInfo(int type, int extra) override
296        {
297            // Process a common event.
298        }
299        void OnRewindToComplete() override
300        {
301            // Process the event that playback position is changed.
302        }
303    };
304
305    ```
306
3072.  Create a  **Player**  instance, set the playback source, and start playback.
308
309    ```
310    Player *player = new Player();
311    std::shared_ptr<PlayerCallback> callback = std::make_shared<TestPlayerCallback>();
312    player->SetPlayerCallback(callback);// Set a player callback.
313    std::string uri(filePath);// filePath is a local file path.
314    Source source(uri);// Create a Source instance and save the URI to the instance.
315    player->SetSource(source);// Set the Source instance to the player.
316    player->Prepare(); // Prepare for the playback.
317    player->SetVideoSurface(surface);// Set the playback surface.
318    player->Play(); // Start playback.
319    ```
320
3213.  Control the playback as needed.
322
323    ```
324    player->SetVolume(lvolume, rvolume);// Set volume for left and right channels.
325    player->EnableSingleLooping(true);// Enable loop playback.
326    player->Pause(); // Pause playback.
327    player->Play(); // Resume playing.
328    ```
329
3304.  Release resources after the playback is complete.
331
332    ```
333    player->Stop(); // Stop playback.
334    player->Release(); // Release resources.
335    ```
336
337
338