百度智能云

All Product Document

          Multimedia Cloud Processing

          Android-Player-SDK-Developer Guide

          Before development, make sure the following prerequisites are ready:

          • Download the latest player Android SDK.
          • Prepare the Android operation environment: Systems of Android 2.2 and above.
          • Adaptive to CPU instruction set: ARM v7, ARM 64 and Intel X86.
          • Apply for an account and enable the privileges: You need to log in Baidu AI Cloud, get Access Key (AK) in Safety Certificate Page. The AK parameter must be passed in during SDK authentication.
          • Integrate and add player SDK to App project:

            (1)Create Android project.

            (2)Add the Jar package in the SDK to the libs directory of the App project, and set to depend on this Jar package in the project property.

            (3)The so dynamic library compression package matched to CPU type is selected, and decompressed to directory libs of project directory.

            (4)(Optional) Integrate the res folder into the res directory under the project directory

            When BMediaController is used, execute the merge operation. 
          • Privilege statement

            Please claim the following privileges in the AndroidManifest.xml of Android App: 
            
                <uses-permission android:name="android.permission.INTERNET" /> 
                <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
                <uses-permission android:name="android.permission.WRITE_SETTINGS" /> 
                <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 

          Video Play Developer Guide

          As the core character of Android player SDK, the video play function currently has introduced the BVideoView type interface source code providing support for the media play display and will introduce the BMediaController type interface source code providing support for media play control; currently, you can use both BVideoView and BMediaController for rapid development and customize development based on BVideoView. Meanwhile, we are trying to open up more source codes for you to deeply customize.

          API introduction

          • setOnNetworkSpeedListener: Register the bandwidth achieved when the monitoring function can get the playing online videos, which is more accurate than the network speed achieved by system function.
          • setFirstBufferingTime: Control the maximum buffer duration of the first frame data in the player. The time indicates the end of buffering and does not mean that you can see the first frame data within this time point.
          • setCacheBufferSize: When playing the online videos, the size of the network buffering zone is customized, and it is not recommended to set if there is no specific need.
          • setCacheTime: Custom the maximum buffer waiting time when playing the network video (unit: Second), in the absence of setup, it defaults to 1 second, with the minimum value of 0.5 second and the maximum value of 4 seconds.
          • setUserAgent: When playing the online videos, the user agent sent to the server is customized.
          • setCustomHttpHeader: When playing the online videos, http get requests sent to the server are customized, such as refer and Trailer, separated by \r\n. E.g.: “referrer:.baidu.com\r\nRetry-After:120\r\nPragma:no-cache\r\n”.

          Use BVideoView and BMediaController for quick playback

          Player SDK supports “Play\Pause” key and other two customized keys, which can realize the features similar to “last part” and “next part”, and you can also realize the controls by yourself. If two corresponding listeners are registered, the custom key is displayed in the controller, otherwise it is not displayed. The controller also displays the current play time and total video duration, and there is seekbar, you can execute seek operation for the current play.

          1.Create BVideoView and BMediaController.

          Create BVideoView and BMediaController in two ways, with the example code shown as follows:

                     #Mode 1: Directly create in the deployment file 
                     <RelativeLayout 
                        android:id="@+id/videoview_holder" 
                        android:layout_width="wrap_content" 
                        android:layout_height="wrap_content" 
                        android:layout_centerInParent="true" > 
                        <com.baidu.cyberplayer.core.BVideoView 
                           Android:id=”@id/videoview” 
                           Android:layout_width=”fill_parent” 
                           Android:layout_height=”fill_parent”/> 
                      </RelativeLayout> 
                      ... ...
                      <RelativeLayout 
                        android:id="@+id/controller_holder" 
                        android:layout_width="wrap_content" 
                        android:layout_height="wrap_content" 
                        android:layout_centerInParent="true" 
                        <com.baidu.cyberplayer.core.BMediaController 
                          Android:id=”@id/controllerbar” 
                          Android:layout_width=”fill_parent” 
                          Android:layout_height=”fill_parent” /> 
                      </RelativeLayout> 
          
                      #Method 2: Dynamically create it in the source code, and add it to the page. 
                      BVideoView mVV; 
                      BMediaController mVVCtl; 
                      ...
                      mViewHolder = (RelativeLayout) findViewById(R.id.videoview_holder); 
                      mControllerHolder = (LinearLayout) findViewById(R.id.controller_holder); 
          
                      mVV = new BVideoView(MediaControllerPlayingActivity.this); 
                      mVVCtl = new BMediaController(MediaControllerPlayingActivity.this); 
                      LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( 
                        LinearLayout.LayoutParams.FILL_PARENT, 
                        LinearLayout.LayoutParams.FILL_PARENT); 
                      mViewHolder.addView(mVV, param); 
                      mControllerHolder.addView(mVVCtl, param); 

          2.Correlate BVideoView and BMediaController to realize play.

          (1)(Optional)Call BVideoView.setNativeLisbDirectory() before playing to assign the loading position of the bottom library.

          Don’t need to call every time before play, only when the loading position of the underlying library needs to be assigned.

          (2)(Optional)Register the listener to monitor the playback process, so that the application can deal with it according to the monitoring result.

          Function declaration Description
          void setOnSeekCompleteListener(OnSeekCompleteListener listener) The callback function called after finishing seek registration
          void setOnPreparedListener(OnPreparedListener linstener) Register the callback function called when the media file is loading or to be load
          void setOnCompletionListener(OnCompletionListener linstener) Register the callback function that is called after the media files are played
          void setOnCompletionWithParamListener(OnCompletionWithParamListener listener) Register a completed callback function with parameters
          void setOnErrorListener(OnErrorListener linstener) Register the callback function called when an error occurs during the play
          void setOnPlayingBufferCacheListener(OnInfoListener linstener) Register the callback function of the cache zone filling degree percentage when playing
          void setOnNetworkSpeedListener(OnNetworkSpeedListener listener) Register and report the callback function of the network speed when playing
          void setOnPositionUpdateListener(OnPositionUpdateListener linstener) Register and report the current play progress (unit: ms) callback function, and callback interval is 200 ms
          void setOnTotalCacheUpdateListener(OnTotalCacheUpdateListener listener) Register and report the current buffering duration (unit: Second) callback function, with the callback interval of 500 milliseconds

          (3)(Optional)Correlate BVideoView and BMediaController to start play.

          Sample Code:

                      mVV.setMediaController(mVVCtl); 
                      mVV.setDecodeMode(BVideoView.DECODE_SW); //Select soft solution mode or hard solution mode 
                      mVV.setVideoPath(path); 
                      mVV.showCacheInfo(true); 
                      mVV.start(); 

          Whereas, showCacheInfo() is used to set whether to display the buffer status and buffer percentage on videoview during the buffering, which defaults to display. setDecodeMode() is used for setting software and hardware decoding modes. It is software decoding by default. You can decide it according to the format supported by the Android system by default. If the default supported formats are MP4, 3GP, etc., recommend enabling the hardware decoding to save power consumption and improve playback performance.

          3.Use BVideoView and BMediaController to realize multi-rate selection play.

          (1)Access optional code rate and resolution array.

          Use getMediaInfo and getSupportedResolution (or getSupportedBitrateKb) of BVideoView static interface to access the resolution (or code rate) array supported by current video address.

          Sample code:

                      new Thread(new Runnable() { 
                          @Override 
                          public void run() { 
                              Looper.prepare(); 
                              BVideoView.getMediaInfo(VideoViewPlayingActivity.this, mVideoSource); 
                              mAvailableResolution = BVideoView.getSupportedResolution(); 
                              mAvailableBitrateKb = BVideoView.getSupportedBitrateKb(); 
                          } 
                      }).start(); 

          Note Since getMediaInfo is time-consuming, please call in the sub thread.

          (2)Register event detectaphone in BMediaController.

          Initialize the response resolution ratio to select button and click the event OnClickListener, call setResolutionListener interface of BMediaController to set the listener to the instance.

          Sample code:

                      private View.OnClickListener mSelectResolutionListener = new View.OnClickListener() { 
                          @Override 
                          public void onClick(View v) { 
                              if (mResolutionSelector != null && mAvailableResolution != null) { 
                                  mResolutionSelector.setAdapter( 
                                              new ArrayAdapter<String>(VideoViewPlayingActivity.this, R.layout.resolution_item, mAvailableResolution)); 
                                  mResolutionSelector.setVisibility(View.VISIBLE); 
                              } 
                          } 
                      }; 
                      mVVCtl.setResolutionListener(mSelectResolutionListener); 

          (3)Select the resolution ratio to play.

          Call selectResolutionType of BVideoView, and pass in the subscripts of the resolution (or code rate) array that the video supports to play the video at that resolution (and code rate).

          Sample code:

                      mResolutionSelector.setOnItemClickListener(new OnItemClickListener() { 
                          @Override 
                          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { 
                              if (mVV != null) { 
                                  mVV.selectResolutionType(arg2); 
                              } 
                              mResolutionSelector.setVisibility(View.GONE); 
                          } 
                      }); 

          Custom playback control interface based on BVideoView

          The method of using BVideoView to customize is basically the same as [Use BVideoView and BMediaController for Rapid Play](#Use BVideoView and BMediaController for Rapid Play); when implementing, please pay attention:

          • After calling BVideoView.start(), wait for OnPreparedListener.onPrepared() to show that the video is ready to play, you are suggested to add waiting information or notifications in the interface during this process.
          • After calling OnPreparedListener.onPrepared(), you can get the current play time and total video duration to display the play process through BVideoView.getCurrentPosition() and BVideoView.getDuration(). You can seek the video through BVideoView.seekTo() while dragging the progress bar.
          • Execute BVideoView.stopPlayback() to stop the video, which is an asynchronous operation and needs to wait for OnCompletionListener.onCOmpletion(), and it indicates a true end of playback; at this point, the next playback can be started.

          M3U8 video download

          The player supports download and management for M3U8 videos.

          Class file

          Class file Description Key information
          VideoDownloadManager class Information related to download management startOrResumeDownloaderpauseDownloaderdeleteDownloaderstopAllgetDownloadableVideoItemByUrlgetAllDownloadableVideoItemsMethod
          DownloadObserver class Information related to download tasks
          AbstractDownloadableVideoItem class Information related to task status and local storage of videos getProgressgetLocalAbsolutePath

          Download management method

          Method Description Description
          startOrResumeDownloader Create/resume download tasks Assign the URL and title of the target video, create/resume task and add in the download task pipeline; whether to execute the task is determined by the task number being executed in the current Pipeline, and 5 tasks are supported to be downloaded simultaneously by default. Use cooperatively with pauseDownloaderwhen used to restore the task
          pauseDownloader Pause the download task Use cooperatively with startOrResumeDownloader. After pausing the task, the downloaded videos are still locally stored and the tasks are removed from the download pipeline
          deleteDownloader Delete the download tasks Comparing with pauseDownloader, the cancelled tasks are removed from the task pipeline, and the corresponding videos are also deleted from local as well.
          stopAll Stop the download tasks in batch The processing for local video is similar to pauseDownloader, meaning to still locally store the downloaded videos. pauseDownloader aims at single task and stopAll is batch operation
          getDownloadableVideoItemByUrl Access the download unit Download unit, which is the resource collection of the download tasks, includes URL, local storage path, filename, download progress and download status of the target video
          getAllDownloadableVideoItems Access all download unit getAllDownloadableVideoItemByUrl()aims at single task and getAllDownloadableVideoItems is batch operation

          Download and play

          1.Call VideoDownloadManager.getInstance(context, userName) to finish initialization to get the download management single instance.

          2.Call startOrResumeDownloader(url, observer) to create the download task.

          Function prototype: 
          
              public void startOrResumeDownloader(String url, DownloadObserver observer) 
          
          At this time, you can also call pause ( `pauseDownloader `), resume ( `startOrResumeDownloader `), delete ( `deleteDownloader `), stop all ( `stopAll `) and other interfaces to manage download tasks. 
          
          Please inherit the `DownloadObserver` class and realize `update` method to conveniently get real-time status changing notifications when downloading the task. 
          
              public void update(AbstractDownloadableVideoItem downloader) 

          3.During the process of task downloading, call back update(AbstractDownloadableVideoItem downloader) to get real-time download status.

              Downloader object can get the following methods: 
          
          |Method                   |Description                        |
          | -------------------- | ------------------------- |
          | getUrl               |Get single download url                |
          | getLocalAbsolutePath |Get the local absolute path of the downloaded file             |
          | getProgress          |Get download status.                    |
          | getStatus            |Get download status(Enumeration type DownloadStatus) |
          | getErrorCode         |When the download status is Error, get the error code through the interface  |
          | getFailReason        |Get the simple description of download failure or discontinuity            |
          
          >Note: Error code such as AbstractDownloadableVideoItem. ERROR_CODE_INVALID_URL 
          
           Whereas, the error code when an error occurs is shown in the table below: 
          
          |Error code                               |Description                  |
          | --------------------------------- | ------------------- |
          | ERROR_CODE_NO_ERROR               |Error free                 |
          | ERROR_CODE_INVALID_URL            |Address invalid                |
          | ERROR_CODE_NETWORK_FAILED         |Network problems                |
          | ERROR_CODE_SDCARD_UNMOUNTED       |Local storage problem              |
          | ERROR_CODE_M3U8\_\\INVALID_FORMAT |m3u8 format problem            |
          | ERROR_CODE_M3U8_SAVE_FAILED       |m3u8 storage problem            |
          | ERROR_CODE_M3U8_DRM_INVALID       |Invalid key or token related to drm protection |
          | ERROR_CODE_TS_SAVE_FAILED         |Fail to save ts files            |

          4.After downloading successfully, AbstractDownloadableVideoItem is called back to getLocalAbsolutePath, and transfer folderPath + "/" + fileName to the player for local play.

          Subtitle Play Development Guide

          As a new highlight of Android player SDK, the add-on subtitle feature supports the import of add-on subtitle during the video playing, including downloading subtitle, loading local subtitle, adjusting subtitle display, etc. At present, only srt subtitle format is supported. We are trying to support more subtitle format. Please stay tuned.

          API introduction

          The subtitle module in the play core is managed through SubtitleManager; when using the subtitle, call getSubtitlePlayManager() in BVideoView to get SubtitleManager instance.

          Subtitle display settings are managed through SubtitleSettings; when changing subtitle settings, adjust by getSubtitleSettings of SubtitleManager to get SubtitleSettings.

          All methods provided are not thread-safety, and Android application needs to ensure to call these methods in one same thread.

          SubtitleErrorCallback

          SubtitleErrorCallback interface defines the callback method when an error occurs during the play, introduce the callback after getting SubtitleManager.

              public interface SubtitleErrorCallback { 
                /**
                 *@Description:Call when downloading and playing the subtitle 
                 *The error of @param error errorCode is defined in subtitleError */ 
                 void onSubtitleError(SubtitleError error); 
              } 

          SubtitleError

          SubtitleError packs error code and error message; there are two public variables: errorCode and errorMsg. Record the error code and error message through two variables, and the specific error code is also defined in this class.

          public class SubtitleError { 
              /**Error message code */ 
              public int errorCode; 
              /**Error message desc */ 
              public String errorMsg; 
          
              public SubtitleError(int errorcode, String errormsg){ 
                  this.errorCode = errorcode; 
                  this.errorMsg = errormsg; 
              } 
          
              /**Default error*/ 
              public static final int ERR_SUBTITLE_UNKNOWN = 1001; 
              /**Invalid parameter*/ 
              public static final int ERR_ARGUMENT_ILLEGAL = 1002; 
              /**Unsupported subtitle type*/ 
              public static final int ERR_UNSUPPORT_TYPE = 2001; 
              /**Error in updating video location information*/ 
              public static final int ERR_CANNOT_UPDATE_POSITION = 3001; 
              /**Alignment method is not supported*/ 
              public static final int ERR_ALIGN_UNSUPPORT = 4002; 
              /**Network connection is not available*/ 
              public static final int ERR_NETWORK_NOT_CONNECTED = 5000; 
              /**File cannot be created*/ 
              public static final int ERR_FAIL_CREATE_FILE = 5001; 
              /**Rename failure*/ 
              public static final int ERR_FAIL_RENAME_FILE = 5002; 
              /**MalformedURL*/ 
              public static final int ERR_MALFORMED_URL = 5003; 
              /**IOException*/ 
              public static final int ERR_IO_EXCEPTION = 5004; 
              /**File not found*/ 
              public static final int ERR_FILE_NOT_FOUND = 5005; 
              /**Coding does not support*/ 
              public static final int ERR_FILE_NOT_FOUND = 5006; 
              /**The directory is not writable*/ 
              public static final int ERR_FILE_NOT_FOUND = 5007; 
              /**serverReturn error*/ 
              public static final int ERR_SERVER_ERRORNO = 5008; 
          } 

          SubtitleManager Get

          Create BvideoView instance in the Activity, and create by calling the getSubtitlePlayManager() method in the instance.

          Sample Code:

              BVideoView mVV = new BVideoView(this); 
              SubtitleManager manager = mVV.getSubtitlePlayManager( 
                      new SubtitleErrorCallback() { 
                            public void onSubtitleFailed (SubtitleError error) (); 
                      } 
                  ); 

          Play subtitle

          • Download and play the subtitle

                /**
                 *@Description:Download and start the subtitle 
                 *@param downUrlDownload url 
                 *@param dirDownload directory 
                 *@param fileNameFile name 
                 *@param baseAdjustAutomatic synchronization adjustment value, ms; 
                 *@param downCallbackCallback after finishing download 
                 */
                public void startSubtitle( 
                    final String downUrl, 
                    final String dir, 
                    final String fileName, 
                    final int baseAdjust, 
                    final DownFinishCallback downCallback) {}; 
              
                /**
                 *@Description: 
                 *@param downUrlDownload and start the subtitle 
                 *@param fullPathNeed to save the full path of the subtitle 
                 *@param baseAdjustAutomatic synchronization adjustment value, ms; 
                 *@param downCallbackCallback after finishing download 
                 */
                public void startSubtitle( 
                    final String downUrl, 
                    final String fullPath, 
                    final int baseAdjust, 
                    final DownFinishCallback downCallback) {}; 
            
            DownFinishCallback is the callback that the download finishes, which is defined as follows: 
            
                public interface DownFinishCallback { 
                    /**
                     *@Description:Callback method after finishing download 
                     *@param isSuccessAfter downloading successfully, true is returned and the subtitle play is automatically activated. Return false if it fails. 
                     *@param msgIf it is true, return the downloaded fullPath; if it is false, return an error message. 
                     */
                     void onDownFinished(boolean isSuccess, String msg); 
                } 
          • Play the local subtitle

                /**
                 *@Description:Enable subtitles 
                 *@param subtitlePathLocal absolute path of subtitles. It shall end with a subtitle type and is used to judge the type. 
                 */
                public void startSubtitle(String subtitlePath){}; 
          • ON/OFF subtitle display

                /**
                 *@Description:Set whether to display subtitle *@param isShowIf it shows true 
                 */
                public void setIsShowSubtitle(boolean isShow){}; 
          • Adjust the subtitles manually

                /**
                 *@Description:Adjust the subtitles manually 
                 *@param msecAdjust the number of milliseconds: positive integer for faster, negative integer for slower 
                 */
                public void manualSyncSubtitle(int msec) {}; 

          Set up subtitles

          Subtitle settings can be managed through SubtitleSettings. First get SubtitleSettings instance through getSubtitleSettings() of SubtitleManager, and then call SubtitleSettings function to adjust the subtitle to play.

          SubtitleSettingsProvide subtitle adjustment interface:

          • Set the subtitle color

                /**
                 *@Description:Set color display 
                 *@param mDisplayColorColor displayed 
                 *Note that this int value is a value including transparency. Please use Color.parseColor or Color.argb to convert it. 
                 */
                public void setDisplayColor(int displayColor) {}; 
          • Set the subtitle character size

                /**
                 *@Description:Set the subtitle character size 
                 *@param mDisplayFontSizeSubtitle size, with the unit of px 
                 */
                public void setDisplayFontSize(float displayFontSize); 
          • Set subtitle position

                /**
                 *@Description:Set the subtitle alignment and padding 
                 *@param alignAlignment mode, ALIGN_BOTTOM or ALIGN_TOP 
                 *@param padding and the bottom padding, with the unit of px 
                 */
                public void setDisplayLocation(int align, int padding); 

          Multi-screen Interaction Development Guide

          Player SDK releases DLNA (Digital Living Network Alliance) controller feature to realize multi-screen interaction. Android cellphones activate the DLNA service as the DMS (Digital Media Server) or DMC (Digital Media Controller); the DLNA device (normally TV or sound) in the same LAN can connect Android cellphones. These devices, as DMP (Digital Media Player) or DMR (Digital Media Render), can play audio and video on the phone.

          API introduction

          Use DLNA feature, and API calls are divided into the following steps:

          • Pass in AK for initialization and privilege authentication.
          • Enable DLNA service.
          • Get Render (the display devices such as TV) list.
          • Specify a Render to associate with it.
          • Specify the URL of the resource to be played.
          • The play control phase; start, pause, drag and adjust the sound volume.
          • Stop DLNA service

          Other optional operations:

          • Get the play capacity, the supported formats and protocols of the Render before playing.
          • Automatically get the Render status information during the play.
          • Subscribe Render status to avoid proactive polling.
          • Monitoring error.

          Note:

          • IDLNAServiceProvider is the only interface for external services.
          • API calling is divided into synchronous calling and asynchronous calling according to whether the operation is time-consuming:

            • Synchronously call the immediately returned result.
            • Return asynchronous call immediately, and get the execution result through the registered corresponding callback. As callback is not executed in UI thread, please do not perform UI-related operations in the callback; if the operation fails, you can also check the error code and error message details through the corresponding callback.
          • API document indicates whether the specific API is synchronous or asynchronous operation.

          Start and stop DLNA service

          • Initialize and start DLNA service

            The startup process includes: Get the IDLNAServiceProvider instance, use AK for initialization, and enable the DLNA service. 
            
            Sample code: 
            
                // Android context instance about application environment 
                Context context = ...; 
                // User's Access Key 
                String AK = ...; 
                // Callback handle for DLNA statup 
                IEnableDLNACallBack enableDLNACallback = ...; 
              
                \x{fffc}IDLNAServiceProvider serviceProvider = DLNAProviderFactory.getProviderInstance(context); 
                serviceProvider.initialize(AK, “”); 
                serviceProvider.enableDLNA(enableDLNACallback); 
          • Disable DLNA service

            Sample code: 
            
                // Callback handle for DLNA shutdown 
                IDisableDLNACallBack  disableDLNACallback = ...; 
              
                serviceProvider.disableDLNA(disableDLNACallback); 

          IDLNAServiceProviderRelated functions are described as follows:

          Operation Interface Description
          Initialization void initialize(String AK, String SK); -
          Enable DLNA service void enableDLNA(IEnableDLNACallBack callback); Activate the underlying DLNA service, and send the result to the onEnableDLNA() of callback.
          Stop DLNA service void disableDLNA(IDisableDLNACallBack callback); The results is transmitted to onDisableDLNA() of callback

          Select the device and playback resource

          After activating DLNA service, get the current active device list, remind and select the device to correlate, and set the play source URL.

          Sample code:

          Map<String, String> renderMap = serviceProvider.getDeviceMap(DLNADeviceType.MEDIA_RENDERER); 
          ...
          // Device selected by the user 
          String selectedDevice = ...; 
          // selectRenderDeviceCallback interface 
          ISelectRendererDeviceCallBack selectRendererDeviceCallback = ...; 
          
          serviceProvider.selectRenderDevice(selectedDevice, selectRendererDeviceCallback); 
          
          //Video resource URL 
          String mediaUrl = ...; 
          // setMediaURICallback interface 
          ISetMediaURICallBack setMediaUriCallback = ...; 
          serviceProvider.setMediaURI(mediaUrl, setMediaUriCallback); 

          IDLNAServiceProviderRelated functions are described as follows:

          Operation Interface Description
          Get Render Map<String, String> getDeviceMap(DLNADeviceType devType); Selectable value of DLNADeviceType: MEDIA_SERVER, MEDIA_RENDERER
          Correlate Render void selectRenderDevice(String devId, ISelectRendererDeviceCallBack callback); Send the result to the callback onSelectRenderDevice()
          Set resource URL void setMediaURI(String mediaURI, ISetMediaURICallBack callback); Send the result to the callback onSetMediaURI()

          Play control

          Call the API of IDLNAServiceProvider to realize play control. Since the interaction objects are other terminal devices in the network, there are network delays and device response delays during the control and interaction process, that is, after the API calls return, the controlled device may delay in responding for a period of time.

          The state of the controlled terminal can affect the success of API call, for example, Seek operation is allowed only in the playback state. All control operation results are returned through the corresponding callback function registered.

          IDLNAServiceProviderThe playback control function is described as follows:

          Operation Interface Description
          play void play(IPlayCallBack callback); Request the device to start playing, and callback onPlay() after the result is got.
          PAUSING void pause(IPauseCallBack callback); Request the device to pause play, call the callback onPause() after getting the result
          Stop void stop(IStopCallBack callback); Request the device to stop play, call the callback onStop() after getting the result
          Drag void seek(String position, ISeekCallBack callback); Request the device to stop play, call the callback onSeek() after getting the result; the format of
          position is hh:mm:ss
          Set volume void setVolume(int vol, ISetVolumeCallBack callback); Request the device to change sound volume, call the callback onSetVolume() after getting the result
          Set mute void setMuteStat(boolean isMute, ISetMuteCallBack callback); Request the device to set mute, call the callback onSetMute() after getting the result

          Get device status

          Call the API of IDLNAServiceProvider to get the relevant status of the controlled device.

          IDLNAServiceProviderThe device status function is described as follows:

          Operation Interface Description
          Get volume void getVolume(IGetVolumeCallBack callback); Query the device sound volume, call the callback onGetVolume() after getting the result
          Get Mute status void getMuteStat(IGetMuteCallBack callback); Query whether the device is in a mute state, and call onGetMute() of callback after getting the result.
          Get the media file play duration String getMediaDuration(); May return 00:00:00, ignore and try to get again;
          DeviceEventListener is recommended to register, when duration changes, the bottom level is responsible for noticing the latest duration value to the upper levels
          Get the current play progress String getMediaPosition(); May return 00:00:00, ignore and try to get again;
          DeviceEventListener is recommended to register, when duration changes, the bottom level is responsible for noticing the latest duration value to the upper levels
          Access the current status of Render String getRenderState(); The possible status is: Playing/Stopped/Transitioning/No Media/Paused
          Previous
          Quick Query of Interface
          Next
          Android-Player-SDK-Introduction