# Class hcap.Media

- Defined in: hcap-1.24.6.5901.js

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| hcap.Media() Interface for displaying and controlling the playback of media on the TV.

## Method Summary

## Class Detail

hcap.Media()
Interface for displaying and controlling the playback of media on the TV. This class is not to be constructed directly (by user code). hcap.Media has a change of status as follows.

See:
  hcap.Media.createMedia()

## Method Detail

- <static> {Object} hcap.Media.createMedia(param)
  Create Media object. The Media object provides the ability to play back video files and stream on a device.
  If an object is passed to the settings parameter, the function should try to initialize the internal media player with the provided settings. If successful, the function should return an instance of hcap.Media with a standardized interface for the internal media player. If the functions fails to instantiate the internal media player to a playable state for any reason (such as media not found or supported, or only one media player supported at a time), then the function should return null.
  If no object is passed to the settings parameter, then the function should return the last non-destroyed hcap.Media instance, or null if there are no active media players.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {String} param.url [Required] - media url. As of API, the following protocols should be accepted.

    url
    RTSP - (rtsp://1.2.3.4:554/video.mp4)
    HTTP - (http://lge.com/movie.mp4)
    FILE - (file:///tmp/usb/usb1/example.mp4)

    - {String} param.mimeType [Required] - video mime type. please refer to table below.

    mimeType
    'audio/x-ms-wma'
    'audio/mpeg'
    'audio/mp3'
    'video/mp4'
    'video/mpeg4'
    'video/x-m4v'
    'video/mpeg'
    'video/x-ms-wmv'
    'video/x-ms-asf'
    'video/x-msvideo'
    'video/x-flv'
    'application/x-mpegURL' (HTTP supports only)

    - {String} param.subtitleUrl [Optional] - subtitle url. As of API, the following protocols should be accepted.

    subtitleUrl
    HTTP - (http://lge.com/movie.smi)

  Since:
    1.3.1
  Returns:
    {Object} hcap.Media
  See:
    hcap.Media.play()
- destroy(param)
  Destroy the media playback. If you want to request channel change during playback then you should destroy media object. Before destorying the media, please check the current media status is the stop. If the media status is not the stop, please call hcap.Media.stop() and then call hcap.Media.destroy().

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.stop({
                           "onSuccess" : function() {
                               console.log("onSuccess");
                               media.destroy({
                                   "onSuccess" : function() {
                                       console.log("onSuccess");
                                       hcap.Media.shutDown({
                                           "onSuccess" : function() {
                                               console.log("onSuccess");
                                           },
                                           "onFailure" : function(f) {
                                               console.log("onFailure : errorMessage = " + f.errorMessage);
                                           }
                                       });
                                   },
                                   "onFailure" : function(f) {
                                       console.log("onFailure : errorMessage = " + f.errorMessage);
                                   }
                               });
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media is destroyed already, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.play()
    hcap.Media.pause()
    hcap.Media.resume()
    hcap.Media.stop()
- getAudioLanguage(param)
  Gets the list of supported audio languages and the index of list in the current media.
  Audio language list is composed of language codes and delimiter comma(',').
  Application can get/set audio language of the current media by index of the audio language list.
  If there is no audio language list of the current channel, only "xx" is returned as the audio language list.
  And "xx" could be returned as an audio language if the audio language is not mapped to an audio language code.
  The maximum number of audio language lists is supported up to 16. If the video has more than 16 languages, only 16 are displayed.

  Item | Value
  --- | ---
  audio language list | en,ko,fr,en,xx
  index | 0, 1, 2, 3, 4
  Audio Language List & Index Example

  If the application wants to set the audio language to French ('fr'), use the index '2'.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getAudioLanguage({
                           "onSuccess" : function(s) {
                               console.log("onSuccess audio language list : " + s.list + " index : " + s.index);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function (param) {
                // {String} param.list - audio language list string
                //     which is composed of language codes separated by delimiter comma(',').
                // {Number} param.index - audio language index of the current media.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.12
  See:
    hcap.Media.setAudioLanguage()
- getInformation(param)
  Gets information of media. For example, the title of the currently loaded media.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getInformation({
                           "onSuccess" : function(s) {
                               console.log("onSuccess" +
                                   "\nvideoAvailable = " + s.videoAvailable +
                                   "\ntitle = " + s.title +
                                   "\ncontentLengthInMs = " + s.contentLengthInMs);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function (param) {
                // {Boolean} param.videoAvailable - whether the video is available.
                // {String} param.title - a human readable title of the current media.
                //     If the title is undetermined, this method returns null.
                // {Number} param.contentLengthInMs - length (in milliseconds) of the media.
                //     If the length is infinite/indeterminable, then this method returns null.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
- getPlayPosition(param)
  Gets the position (in milliseconds) in the media that the player is currently at. If th length of the media is infinite/indeterminable, this function returns the number of milliseconds the player has been playing the media. The default position, before the video has been played, is 0 (unless override by the position setting).

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getPlayPosition({
                           "onSuccess" : function(s) {
                               console.log("onSuccess position : " + s.positionInMs);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function (param) {
                // {Number} param.positionInMs - number of milliseconds the player is into the media
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.setPlayPosition()
- getPlaySpeed(param)
  [RTSP Only] Gets the speed (rate) of the current media. The speed (rate) at which the media is currently playing. If the media has not yet started playing or is stopped, this method returns 0.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getPlaySpeed({
                           "onSuccess" : function(s) {
                               console.log("onSuccess speed : " + s.speed);
                               switch(s.speed) {
                                 case 0 :
                                    console.log("Playback has stopped");
                                    break;
                                 case 1 :
                                    console.log("Media is playing");
                                    break;
                                 case 0.5 :
                                    console.log("Media is playing at half speed");
                                    break;
                                 case 2 :
                                    console.log("Media is fast-forwarding at 2x");
                                    break;
                                 case -2 :
                                    console.log("Media is rewinding at 2x");
                                    break;
                               }
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function (param) {
                // {Number} param.speed - rate at which the media runs currently.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.setPlaySpeed()
- getState(param)
  Gets player status. Status can be 'play', 'pause' or 'stop'.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getState({
                           "onSuccess" : function(s) {
                               console.log("onSuccess state : " + s.state);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function (param) {
                // {String} param.state - a human readable status of the current media.
                //     It can be 'play', 'pause' or 'stop'.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
- getSubtitle(param)
  Gets the subtitle type and track number and ISO639-1 launguage code if available.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getSubtitle({
                           "onSuccess" : function(s) {
                               console.log("onSuccess : subtitle type = " + s.type + "index = " + s.index + "language = " + s.list);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // {Number} param.type - Current played subtitle type.
                // {Number} param.index - Current played subtitle track number, On the case of external subtitle, don't care this value.
                // {String} param.list - Language code of 'xx' if no available.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.22.0
  See:
    hcap.Media.setSubtitle()
    hcap.Media.SubtitleType.NONE
    hcap.Media.SubtitleType.INTERNAL_SUBTITLE
    hcap.Media.SubtitleType.EXTERNAL_SUBTITLE
    hcap.Media.SubtitleType.CLOSED_CAPTION
- getSubtitleOn(param)
  Gets the subtitle status of the current media.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.getSubtitleOn({
                           "onSuccess" : function(s) {
                               console.log("onSuccess : subtitleOn = " + s.subtitleOn);
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // {Boolean} param.subtitleOn - true if the media subtitle is on. false if it is off.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.7
  See:
    hcap.Media.setSubtitleOn()
- pause(param)
  Pause the media playback.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "repeatCount" : 2,
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.pause({
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media is paused already, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.play()
    hcap.Media.resume()
    hcap.Media.stop()
    hcap.Media.destroy()
- play(param)
  Starts playing a media file or stream. If the media file starts to play, then 'play_start' event will be invoked.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "repeatCount" : 2,
                   "onSuccess" : function() {
                       console.log("onSuccess");
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Number} param.repeatCount [Optional] - repeat count. Default setting value is 1. If you want to play a media stream in infinite loop, set 0.
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media is played already, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1, 1.8 repeatCount
  See:
    hcap.Media.stop()
    hcap.Media.pause()
    hcap.Media.resume()
    hcap.Media.destroy()
    media_event_received
- resume(param)
  Resume the media playback.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "repeatCount" : 2,
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.pause({
                           "onSuccess" : function() {
                               console.log("onSuccess");
                               media.resume({
                                   "onSuccess" : function() {
                                       console.log("onSuccess");
                                   },
                                   "onFailure" : function(f) {
                                       console.log("onFailure : errorMessage = " + f.errorMessage);
                                   }
                               });
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media is resumed already, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.play()
    hcap.Media.stop()
    hcap.Media.pause()
    hcap.Media.destroy()
- setAudioLanguage(param)
  Sets the audio language of the current media.

  Item | Value
  --- | ---
  audio language list | en,ko,fr,en,xx
  index | 0, 1, 2, 3, 4
  Audio Language List & Index Example

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.setAudioLanguage({
                           "index" : 1,
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Number} param.index [Required] - audio language index to be set. Index starts with 0.
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // No Parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.
      Setting to the same audio language index as before will invoke this callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.12
  See:
    hcap.Media.getAudioLanguage()
- setPlayPosition(param)
  Sets the position of the player at which to continue playing the media at. The 'seek_done' event will notify the result of this call. If you want to use this method continuously, you should check to receive the "seek_done" event before the next invocation.

      var media = null;
      document.addEventListener(
           "media_event_received",
           function (param) {
               // {String} param.eventType - changed event type
               console.log("event type = " + param.eventType);
               if (param.eventType === 'seek_done') {
                   console.log("success about media.setPlayPosition ");
               } else if (param.eventType === 'play_start') {
                   media.setPlayPosition({
                      "positionInMs" : 1000,
                      "onSuccess" : function() {
                          console.log("onSuccess");
                       },
                       "onFailure" : function(f) {
                          console.log("onFailure : errorMessage = " + f.errorMessage);
                       }
                   });
               }
           }, false
      );

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Number} param.positionInMs [Required] - number of milliseconds from the start of the media the player should play from
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.getPlayPosition()
    hcap.Media.play()
- setPlaySpeed(param)
  [RTSP Only] Sets the speed (rate) of the current media. If the media has not been started yet, calling this function (with any rate other then 0) will start the media at the specified rate. When the current media passed through http protocol, this API supports only fast forward. In mms and rtsp streaming, the speed parameter is transparently transmitted to the server without any conversion. Therefore, developers are responsible for matching the speed parameter between the application and the server.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.setPlaySpeed({
                           "speed" : 2,
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Number} param.speed [Required] - rate at which the media should run
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.getPlaySpeed()
- setSubtitle(param)
  Sets the subtitle type and track number

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.setSubtitle({
                           "type" :  hcap.Media.SubtitleType.INTERNAL_SUBTITLE,
                           "index" : 0,
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Number} param.type [Required] - Support 3 type of subtitle following as none, internal subtitle, external subtitle, closed caption.
    - {Number} param.index [Required] - Subtitle index to be set. Index starts with 0. onthe case of external subtitle, don't care this value.
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.22.0
  See:
    hcap.Media.getSubtitle()
    hcap.Media.SubtitleType.NONE
    hcap.Media.SubtitleType.INTERNAL_SUBTITLE
    hcap.Media.SubtitleType.EXTERNAL_SUBTITLE
    hcap.Media.SubtitleType.CLOSED_CAPTION
- setSubtitleOn(param)
  Sets the subtitle of the current media on or off. If the subtitle url is not ready, there is no effect on screen. It will work after setting subtitle url using createMedia or setSubtitleUrl.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.setSubtitleOn({
                           "subtitleOn" : true,
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Boolean} param.subtitleOn [Required] - true if the media subtitle is on. false if it is off.
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.7
  See:
    hcap.Media.getSubtitleOn()
- setSubtitleUrl(param)
  Sets the subtitle url of the current media. It will replace the subtitle url which is registered by createMedia().

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.setSubtitleUrl({
                           "subtitleUrl" : "http://lge.com/subtitle.srt",
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {String} param.subtitleUrl [Required] - subtitle url.
    - {Function} param.onSuccess [Optional] - success callback function.

            param.onSuccess = function() {
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.7
  See:
    hcap.Media.setSubtitleOn()
- <static> hcap.Media.shutDown(param)
  Shuts down media channel. You should call hcap.Media.shutDown() after invoking hcap.Media.destroy() if there is no more need to use media player. After this method is invoked, TV input will be changed to last configuration without any notification.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.stop({
                           "onSuccess" : function() {
                               console.log("onSuccess");
                               media.destroy({
                                   "onSuccess" : function() {
                                       console.log("onSuccess");
                                       hcap.Media.shutDown({
                                           "onSuccess" : function() {
                                               console.log("onSuccess");
                                           },
                                           "onFailure" : function(f) {
                                               console.log("onFailure : errorMessage = " + f.errorMessage);
                                           }
                                       });
                                   },
                                   "onFailure" : function(f) {
                                       console.log("onFailure : errorMessage = " + f.errorMessage);
                                   }
                               });
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media channel shuts down, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.8
  See:
    hcap.Media.startUp()
- <static> hcap.Media.startUp(param)
  Starts up media channel which is one of input source on TV. So you should call this method before making hcap.Media object. And you should call hcap.Media.shutDown() after invoking hcap.Media.destroy() for finalizing media channel.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media channel starts up, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.8
  See:
    hcap.Media.shutDown()
- stop(param)
  Stops the media playback.

      hcap.Media.startUp({
           "onSuccess" : function() {
               console.log("onSuccess");
               var media = hcap.Media.createMedia({
                   "url" : "http://media_server_url/media_file.avi",
                   "mimeType" : "video/mp4",
                   "subtitleUrl" : "http://media_server_url/media_file.smi"
               });
               media.play({
                   "onSuccess" : function() {
                       console.log("onSuccess");
                       media.stop({
                           "onSuccess" : function() {
                               console.log("onSuccess");
                           },
                           "onFailure" : function(f) {
                               console.log("onFailure : errorMessage = " + f.errorMessage);
                           }
                       });
                   },
                   "onFailure" : function(f) {
                       console.log("onFailure : errorMessage = " + f.errorMessage);
                   }
               });
           },
           "onFailure" : function(f) {
               console.log("onFailure : errorMessage = " + f.errorMessage);
           }
      });

  Parameters:
  {Object} param
    - {Function} param.onSuccess [Optional] - success callback function.
      If a media is stopped already, this callback function will be invoked.

            param.onSuccess = function() {
                // No parameter.
            }

    - {Function} param.onFailure [Optional] - failure callback function.

            param.onFailure = function (param) {
                // {String} param.errorMessage - in case of failure, this message provides the details.
            }

  Since:
    1.3.1
  See:
    hcap.Media.play()
    hcap.Media.pause()
    hcap.Media.resume()
    hcap.Media.destroy()