Development


This chapter explains how to develop a DAB/DMB application using the LG DMB SDK with source code.

Overview

In applications, the APIs provided by LG DMB SDK are used to control the device and DAB/DMB framework. The application control DAB/DMB service channel searching, as well as the broadcast watching and listening functions. The application shall be developed under the condition that selecting channels and watching and listening to broadcasts will be available when launching the DAB/DMB service.

Preparation

You can implement DAB/DMB services in your application using the APIs provided with the LG DMB SDK.

Creating an Android Project

You should create a new module to develop a DAB/DMB application in Android Studio.

 

1. Start Android Studio, and select File > New Project to create new project.

 

2. Fill in the “Configure your new project” form as follows, and click the Next button.

  • Application name: Enter the appropriate name for your application
  • Company domain: Enter the appropriate value for your application

creating 1.png

 

3. Under "Select the form factors your app will run on," check the box for Phone and Tablet. For Minimum SDK, select API 23: Android 6.0. Then, click the Next button.

creating 2.png

 

4. Under "Add an activity to Mobile," select Blank Activity and click the Next button.

 

5. Under "Customize the Activity," leave fields as default and click the Finish button. Now your Android project is created.

Importing a Library

Once you have created an Android Project, you should import the LG DMB library.

 

1. Copy the library file from the libs folder of the SDK root path to the libs folder under app in your project

e.g.) workspace/MyFMRadioApp/app/libs
 

2. From the File menu, select New module.
 

3. Under “Create New Module”, choose ‘Phone and Tablet Application’ and ‘Import JAR or .AAR package’, then click the Next button.

creating 3.png

 

4. For the File name field, browse the project folder and find the LG DMB library, then click the Finish button.

creating 4.png

 

5. You will now see that the LG DMB module is added to the project.

 

6. Select Synchronize from the File menu. The LG DMB library is configured and ready to use.

 

Key Implementation

This section describes how to develop an application using LG DMB SDK. Please refer to the API Reference in the SDK package for detail information about each APIs. The detailed information on the sample code using each API is describes in Sample Tutorials.

 

1. First, import library package in MainActivity.

import com.lge.broadcast.tdmb.Dmb;

 

2. Connect to DAB/DMB service by calling Dmb.open() in onCreate() method. You should call Dmb.release() when you close DAB/DMB service.

protected void onCreate(Bundle savedInstanceState){ 
      super.onCreate(savedInstanceState); 
      ... 
      Dmb.open(); 
}

 

 

3. Select op_mode by calling Dmb.init(), and register the EventCallback function to receive event from DAB/DMB service. You should call Dmb.exit() when you end DAB/DMB service.

 

4. Search channels by calling Dmb.find(), and set a certain channel of DAB/DMB service by calling Dmb.select().

 

5. Register the DataCallback function by calling Dmb.data(), and send data such as FIC and SLS/DLS to the application. For TV broadcast, size, position, and rotation of the video displayed on the device can be set using Dmb.setVideoDimension(). If you use Dmb.setVideoDimension() to display video on the device, SurfaceView should be used. SurfaceView uses SurfaceHolder to control the virtual canvas, or surface, unlike in the general Android View. In other words, SurfaceHolder class directly access to surface to process a display.

 

6. Select Make Module ‘app’ of Build menu in Android Studio, and Run > Run ‘app’.

Navigation