Jump to content

C# playback reporting Help


Vicpa

Recommended Posts

Vicpa

Hi,

My client uses the old version of the Api client. The playback reporting methods Start, Progress and Stop, are the area I could use some help

Start method: fails looking for another property what else do I need to add ?

The methods I am using are below:

     /// <summary>
     /// Reports playback start
     /// </summary>
     /// <param name="info">The information.</param>
     /// <param name="isOffline">if set to <c>true</c> [is offline].</param>
     /// <param name="apiClient">The current apiClient. It can be null if offline</param>
     /// <returns>Task.</returns>
     public async Task ReportPlaybackStart(PlaybackStartInfo info, bool isOffline, IApiClient apiClient)
     {
         if (!isOffline)
         {
             await apiClient.ReportPlaybackStartAsync(info).ConfigureAwait(false);
         }
     }

     /// <summary>
     /// Reports playback progress
     /// </summary>
     /// <param name="info">The information.</param>
     /// <param name="streamInfo">The stream information.</param>
     /// <param name="isOffline">if set to <c>true</c> [is offline].</param>
     /// <param name="apiClient">The current apiClient. It can be null if offline</param>
     /// <returns>Task.</returns>
     public async Task ReportPlaybackProgress(PlaybackProgressInfo info, StreamInfo streamInfo, bool isOffline, IApiClient apiClient)
     {
         if (!isOffline)
         {
             if (streamInfo != null)
             {
                 info.PlaySessionId = streamInfo.PlaySessionId;

                 if (streamInfo.MediaSource != null)
                 {
                     info.LiveStreamId = streamInfo.MediaSource.LiveStreamId;
                 }
             }

             await apiClient.ReportPlaybackProgressAsync(info).ConfigureAwait(false);
         }
     }

     /// <summary>
     /// Reports playback progress
     /// </summary>
     /// <param name="info">The information.</param>
     /// <param name="streamInfo">The stream information.</param>
     /// <param name="serverId">The server identifier.</param>
     /// <param name="userId">The user identifier.</param>
     /// <param name="isOffline">if set to <c>true</c> [is offline].</param>
     /// <param name="apiClient">The current apiClient. It can be null if offline</param>
     /// <returns>Task.</returns>
     public async Task ReportPlaybackStopped(PlaybackStopInfo info, StreamInfo streamInfo, string serverId, string userId, bool isOffline, IApiClient apiClient)
     {
         if (isOffline)
         {
             var action = new UserAction
             {
                 Date = DateTime.UtcNow,
                 ItemId = info.ItemId,
                 PositionTicks = info.PositionTicks,
                 ServerId = serverId,
                 Type = UserActionType.PlayedItem,
                 UserId = userId
             };

             await _localAssetManager.RecordUserAction(action).ConfigureAwait(false);
             return;
         }

         if (streamInfo != null)
         {
             info.PlaySessionId = streamInfo.PlaySessionId;

             if (streamInfo.MediaSource != null)
             {
                 info.LiveStreamId = streamInfo.MediaSource.LiveStreamId;
             }
         }

         // Put a try/catch here because we need to stop transcoding regardless
         try
         {
             await apiClient.ReportPlaybackStoppedAsync(info).ConfigureAwait(false);
         }
         catch (Exception ex)
         {
             _logger.ErrorException("Error in ReportPlaybackStoppedAsync", ex);
         }
     }

Thanks any help would be appreciated.

-vicpa

 

Link to comment
Share on other sites

Those calls should all include the PlaySessionId value that you got from the /PlaybackInfo call prior to playback.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...