From 6caa5382325913ba2a8d64e397934d72fbcfe318 Mon Sep 17 00:00:00 2001 From: coderhyme Date: Wed, 27 Sep 2017 08:29:59 +0900 Subject: [PATCH] [Multimedia] Add guide for the Radio PS2: Reviewed Change-Id: Ibe09d370cd0a18b0c3e8eeeaff3e5d4df68092ef Signed-off-by: coderhyme --- org.tizen.guides/html/dotnet/media/radio.htm | 194 +++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 org.tizen.guides/html/dotnet/media/radio.htm diff --git a/org.tizen.guides/html/dotnet/media/radio.htm b/org.tizen.guides/html/dotnet/media/radio.htm new file mode 100644 index 0000000..cc4488b --- /dev/null +++ b/org.tizen.guides/html/dotnet/media/radio.htm @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + Radio + + + + + +
+ +
+

Dependencies

+
    +
  • Tizen 4.0 and Higher
  • +
+

Content

+ +

Related Info

+ +
+
+ +
+ +

Radio

+ +

You can control the radio hardware in a device to provide radio playback in your application.

+ +

The main features of the Tizen.Multimedia.Radio class include:

+ + + +

You can only have one radio instance active at a time. Radio playback can be interrupted by another radio application.

+ +

Prerequisites

+ +

To enable your application to use the radio functionality:

+
    +
  1. To use the methods and properties of the Tizen.Multimedia.Radio class, include the Tizen.Multimedia namespace in your application: +
    +using Tizen.Multimedia;
    +
    +
  2. +
  3. Create an instance of the Tizen.Multimedia.Radio class: +
    +Radio radio = new Radio();
    +
    +
  4. +
  5. To receive notifications when radio playback is interrupted, register an event handler for the Interrupted event of the Tizen.Multimedia.Radio class. Radio playback is interrupted, for example, when the radio application moves to the background. +
    +radio.Interrupted += OnRadioInterrupted;
    +
    +void OnRadioInterrupted(object sender, RadioInterruptedEventArgs args)
    +{
    +    switch (args.Reason)
    +    {
    +        case RadioInterruptedReason.ResourceConflict:
    +            /// Application that was the source of the conflict is now closed
    +            /// Restart the radio playback here
    +            break;
    +        default:
    +            /// Radio listening is interrupted
    +            /// Release the application resources or save the current state here
    +            break;
    +    }
    +}
    +
    +
  6. +
+ +

Scanning for Radio Frequencies

+ +

To scan for all available radio frequencies:

+ +
    +
  1. Register and define event handlers for the events of the Tizen.Multimedia.Radio class: +
      +
    • To receive a notification each time the scan finds a new frequency, register an event handler for the ScanUpdated event. The event provides the kHz value of the found frequency. +
      +radio.ScanCompleted += OnScanCompleted;
      +
      +void OnScanUpdated(object sender, ScanUpdatedEventArgs args)
      +{
      +    /// Store the radio channels in the array
      +    /// Frequency values represent the kHz of the channel
      +    Tizen.Log.Info("Radio", $"Frequency: {args.Frequency}");
      +}
      +
      + +
      + Note + Do not use radio operations (such as changing the Frequency property value or calling the Start() method) in the scan updated event handler. +
      +
    • +
    • To receive a notification when the scan is complete, register an event handler for the ScanCompleted event: +
      +radio.ScanCompleted += OnScanCompleted;
      +
      +void OnScanCompleted(object sender, EventArgs args)
      +{
      +    /// Frequency scanning is completed
      +    /// Tune in to one of the scanned frequencies and start listening
      +}
      +
      +
    • +
    +
  2. +
  3. Start scanning using the StartScan() method of the Tizen.Multimedia.Radio class: +
    +radio.StartScan();
    +
    +

    The scanning time depends on the environment (the strength of the radio signal).

    +

    To cancel the scan before it completes, use the StopScan() method.

    +
  4. +
+ +

Tuning the Radio

+ +

To select and start playing a frequency:

+ +
    +
  1. Set the frequency you want to play using the Frequency property of the Tizen.Multimedia.Radio class: +
    +radio.Frequency = newFrequncey;
    +
    +
  2. +
  3. Start playing the frequency using the Start() method of the Tizen.Multimedia.Radio class: +
    +radio.Start();
    +
    +

    If the radio emits no sound, check the signal strength with the SignalStrength property of the Tizen.Multimedia.Radio class. The property returns the current signal strength as a dBuV value.

    +
  4. +
+ +

Searching for an Adjacent Channel

+ +

To search for and tune in to an adjacent channel, use the SeekUpAsync() and SeekDownAsync() methods of the Tizen.Multimedia.Radio class. This is similar to the scanning operation, but only the nearest active frequency is searched for. Once the maximum frequency is reached in either direction, the search ends, and the radio is set to that frequency.

+

For example, to seek down, use the SeekDownAsync() method:

+
+var newFrequncey = await radio.SeekDownAsync();
+
+/// Search is complete, and the radio is tuned in to the new frequency
+/// Application sets the new frequency and updates the user interface
+
+ + + +
+ +Go to top + + + + + + -- 2.7.4