<li><a href="#scan">Scanning for All Available Radio Frequencies</a></li>
<li><a href="#tune">Tuning the Radio and Beginning Listening</a></li>
<li><a href="#seek">Seeking for a Nearby Channel</a></li>
- </ul>
+ </ul>
<p class="toc-title">Related Info</p>
<ul class="toc">
<li><a href="../../../../org.tizen.guides/html/native/multimedia/radio_n.htm">Radio Guide</a></li>
<div id="container"><div id="contents"><div class="content">
<h1>Radio: Accessing the Radio</h1>
-
+
<p>This tutorial demonstrates how you can access and tune a radio.</p>
<h2>Warm-up</h2>
<p>Implement the callback function:</p>
<pre class="prettyprint">
-static void
+static void
on_radio_interrupted(radio_interrupted_code_e code, void* userdata)
{
// Search the radio handle from userdata
mRadioInfo* mRadio = (mRadioInfo *)userdata;
-
+
switch (code)
{
case RADIO_INTERRUPTED_COMPLETED:
// The application, which was the source of conflict, is closed now
// Restart the radio playback here
break;
-
+
default:
// Your radio listening is interrupted
// Release the application resources or save the current state here
<li>
<p>Implement the callback function:</p>
-<pre class="prettyprint">void
+<pre class="prettyprint">void
on_scan_finished(void* userdata)
{
// Frequency scanning is done. Tune into one of the scanned frequencies
- // and start listening
+ // and start listening
}
</pre>
<p>The callback function returns the available frequencies:</p>
<pre class="prettyprint">
-void
+void
on_scan_updated(int frequency, void* userdata)
{
mRadioInfo* mRadio = (mRadioInfo *)userdata;
<p>Start scanning</p>
<pre class="prettyprint">radio_scan_start(mRadio.radio, on_scan_updated, &mRadio);</pre>
-<p>The scanning time depends on your environment (the strength of the radio signal). Cancel the current scan using the <span style="font-family: Courier New,Courier,monospace">radio_scan_stop()</span> function.</p></li></ol>
+<p>The scanning time depends on your environment (the strength of the radio signal). Cancel the current scan using the <span style="font-family: Courier New,Courier,monospace">radio_scan_stop()</span> function.</p></li>
+<li>
+<p>Restriction</p>
+<p>You must not call radio api (ex. <span style="font-family: Courier New,Courier,monospace">radio_set_frequency, radio_start ...</span>) in callback function. </p></li>
+</ol>
<h2 id="tune" name="tune">Tuning the Radio and Beginning Listening</h2>
if (ret != RADIO_ERROR_NONE)
{
return false;
-}
+}
</pre>
</li>
<li>
if (ret != RADIO_ERROR_NONE)
{
return false;
-}
+}
</pre>
<p>To seek down, use the <span style="font-family: Courier New,Courier,monospace">radio_seek_up()</span> function in a similar fashion.</p>
{
mRadioInfo *mRadio = (mRadioInfo *)userdata;
int new_frequency = 0;
-
+
// The seek is done. The radio is tuned into the newly found frequency
// The application sets the new frequency and updates the user interface
- radio_get_frequency(mRadio->radio, &new_frequency);
+ radio_get_frequency(mRadio->radio, &new_frequency);
}
</pre>
</li></ol>