diff --git a/MediaBrowser.Api/HttpHandlers/PlaybackCheckInHandler.cs b/MediaBrowser.Api/HttpHandlers/PlaybackCheckInHandler.cs
deleted file mode 100644
index 9de3e2791..000000000
--- a/MediaBrowser.Api/HttpHandlers/PlaybackCheckInHandler.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using MediaBrowser.Common.Net.Handlers;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Model.Connectivity;
-using MediaBrowser.Model.Dto;
-using System;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- ///
- /// Provides a handler to set played status for an item
- ///
- public class PlaybackCheckInHandler : BaseSerializationHandler
- {
- ///
- /// Gets the object to serialize.
- ///
- /// Task{DtoUserItemData}.
- protected override async Task GetObjectToSerialize()
- {
- // Get the user
- var user = await this.GetCurrentUser().ConfigureAwait(false);
-
- var clientType = ClientType.Other;
-
- if (!string.IsNullOrEmpty(QueryString["client"]))
- {
- ClientType type;
-
- if (Enum.TryParse(QueryString["client"], true, out type))
- {
- clientType = type;
- }
- }
-
- var device = QueryString["device"];
-
- // Get the item
- var item = DtoBuilder.GetItemByClientId(QueryString["id"], user.Id);
-
- // Playback start check-in
- if (QueryString["type"].Equals("start", StringComparison.OrdinalIgnoreCase))
- {
- Kernel.UserDataManager.OnPlaybackStart(user, item, clientType, device);
- }
- else
- {
- long? positionTicks = null;
-
- if (!string.IsNullOrEmpty(QueryString["positionTicks"]))
- {
- positionTicks = long.Parse(QueryString["positionTicks"]);
- }
-
- // Progress check-ins require position ticks
- if (QueryString["type"].Equals("progress", StringComparison.OrdinalIgnoreCase))
- {
- await Kernel.UserDataManager.OnPlaybackProgress(user, item, positionTicks, clientType, device).ConfigureAwait(false);
- }
- else if (QueryString["type"].Equals("stopped", StringComparison.OrdinalIgnoreCase))
- {
- await Kernel.UserDataManager.OnPlaybackStopped(user, item, positionTicks, clientType, device).ConfigureAwait(false);
- }
- }
-
- var data = item.GetUserData(user, true);
-
- return new DtoBuilder(null).GetDtoUserItemData(data);
- }
-
- ///
- /// Gets the current user.
- ///
- /// User.
- ///
- public async Task GetCurrentUser()
- {
- var handler = this;
- var id = handler.QueryString["userid"];
-
- var user = ApiService.GetUserById(id);
-
- if (user == null)
- {
- throw new UnauthorizedAccessException(string.Format("User with Id {0} does not exist", id));
- }
-
- var clientType = ClientType.Other;
-
- if (!string.IsNullOrEmpty(handler.QueryString["client"]))
- {
- ClientType type;
-
- if (Enum.TryParse(handler.QueryString["client"], true, out type))
- {
- clientType = type;
- }
- }
-
- var device = handler.QueryString["device"];
-
- await Controller.Kernel.Instance.UserManager.LogUserActivity(user, clientType, device).ConfigureAwait(false);
-
- return user;
- }
-
- }
-}
\ No newline at end of file
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index c6c822624..fb7fe0b29 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -75,7 +75,6 @@
-
diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
index 4267947ad..4ec2aca49 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Model.Connectivity;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
@@ -215,6 +216,66 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; }
}
+ [Route("/Users/{UserId}/PlayingItems/{Id}", "POST")]
+ public class OnPlaybackStart : IReturnVoid
+ {
+ ///
+ /// Gets or sets the user id.
+ ///
+ /// The user id.
+ public Guid UserId { get; set; }
+
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ public string Id { get; set; }
+ }
+
+ [Route("/Users/{UserId}/PlayingItems/{Id}/Progress", "POST")]
+ public class OnPlaybackProgress : IReturnVoid
+ {
+ ///
+ /// Gets or sets the user id.
+ ///
+ /// The user id.
+ public Guid UserId { get; set; }
+
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ public string Id { get; set; }
+
+ ///
+ /// Gets or sets the position ticks.
+ ///
+ /// The position ticks.
+ public long? PositionTicks { get; set; }
+ }
+
+ [Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")]
+ public class OnPlaybackStopped : IReturnVoid
+ {
+ ///
+ /// Gets or sets the user id.
+ ///
+ /// The user id.
+ public Guid UserId { get; set; }
+
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ public string Id { get; set; }
+
+ ///
+ /// Gets or sets the position ticks.
+ ///
+ /// The position ticks.
+ public long? PositionTicks { get; set; }
+ }
+
///
/// Class GetLocalTrailers
///
@@ -515,6 +576,55 @@ namespace MediaBrowser.Api.UserLibrary
Task.WaitAll(task);
}
+ ///
+ /// Posts the specified request.
+ ///
+ /// The request.
+ public void Post(OnPlaybackStart request)
+ {
+ var kernel = (Kernel)Kernel;
+
+ var user = kernel.GetUserById(request.UserId);
+
+ var item = DtoBuilder.GetItemByClientId(request.Id, user.Id);
+
+ kernel.UserDataManager.OnPlaybackStart(user, item, ClientType.Other, string.Empty);
+ }
+
+ ///
+ /// Posts the specified request.
+ ///
+ /// The request.
+ public void Post(OnPlaybackProgress request)
+ {
+ var kernel = (Kernel)Kernel;
+
+ var user = kernel.GetUserById(request.UserId);
+
+ var item = DtoBuilder.GetItemByClientId(request.Id, user.Id);
+
+ var task = kernel.UserDataManager.OnPlaybackProgress(user, item, request.PositionTicks, ClientType.Other, string.Empty);
+
+ Task.WaitAll(task);
+ }
+
+ ///
+ /// Posts the specified request.
+ ///
+ /// The request.
+ public void Post(OnPlaybackStopped request)
+ {
+ var kernel = (Kernel)Kernel;
+
+ var user = kernel.GetUserById(request.UserId);
+
+ var item = DtoBuilder.GetItemByClientId(request.Id, user.Id);
+
+ var task = kernel.UserDataManager.OnPlaybackStopped(user, item, request.PositionTicks, ClientType.Other, string.Empty);
+
+ Task.WaitAll(task);
+ }
+
///
/// Deletes the specified request.
///
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs
index 5342cff4b..de9690140 100644
--- a/MediaBrowser.Common/Extensions/BaseExtensions.cs
+++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs
@@ -61,7 +61,7 @@ namespace MediaBrowser.Common.Extensions
/// Guid.
public static Guid GetMD5(this string str)
{
- using (var provider = new MD5CryptoServiceProvider())
+ using (var provider = MD5.Create())
{
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
}
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
index 50dca1e4c..7a1492359 100644
--- a/MediaBrowser.Common/Kernel/BaseKernel.cs
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
-using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
diff --git a/MediaBrowser.Common/Kernel/TcpManager.cs b/MediaBrowser.Common/Kernel/TcpManager.cs
index 6ea390904..1c76b42f9 100644
--- a/MediaBrowser.Common/Kernel/TcpManager.cs
+++ b/MediaBrowser.Common/Kernel/TcpManager.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -12,7 +13,6 @@ using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Common.Kernel
{