Handling Configuration and Errors

This topic covers how to change the Tizen WASM Player configuration at runtime, and how to handle errors during playback.

Changing Runtime Configuration

Some aspects of a playing stream can be reconfigured during runtime. Changes to following parameters are supported:

Track type Parameter
Video Resolution
Video Frame rate

To change specific runtime configurations, send a keyframe packet that has the new configuration value set:

  • To change the stream resolution:

    ElementaryMediaPacket packet;
    // ...
    packet.width = /* New width */;
    packet.height = /* New height */;
    // ...
    
  • To change the stream framerate:

    ElementaryMediaPacket packet;
    // ...
    packet.framerate_num = /* New framerate_num */;
    packet.framerate_den = /* New framerate_den */;
    // ...
    

Handling Async Append Errors

If AppendPacketAsync(), AppendEncryptedPacketAsync(), or AppendEndOfTrackAsync() are used, the app must detect async append errors using ElementaryMediaTrackListener. The OnAppendError() event should be handled in a custom implementation of ElementaryMediaTrackListener:

class MyMediaElementListener : public samsung::wasm::ElementaryMediaTrackListener {
  using OperationResult = samsung::wasm::OperationResult;
  // ...
  // Override virtual OnAppendError method
  void OnAppendError(OperationResult result) override {
    // Handle append error
  }
  // ...
};

Handling Pipeline Errors

The platform multimedia pipeline runs asynchronously. Elementary media packets are moved through the pipeline and processed after the AppendPacket() operation is finished. The WASM Player verifies as much data as feasible when its API is called, however some errors can still happen asynchronously (such as decoding errors).

The app needs to detect asynchronous errors using HTMLMediaElementListener. The OnError() event must be handled in a custom implementation of HTMLMediaElementListener:

class MyMediaElementListener : public samsung::html::HTMLMediaElementListener {
  using MediaError = samsung::html::MediaError;
  // ...
  // Override virtual OnError method
  void OnError(MediaError error_code, const char* error_msg) override {
    // Handle media error
  }
  // ...
};