pünktchen 1251 Posted April 14, 2020 Share Posted April 14, 2020 As the topic says, how do i set an item as "played" in a C# plugin? I've tried this so far: public class MyService { private IUserDataManager _userDataManager; private readonly ILibraryManager _libraryManager; private readonly IUserManager _userManager; public MyService(IUserDataManager userDataManager, ILibraryManager libraryManager, IUserManager userManager) { _libraryManager = libraryManager; _userDataManager = userDataManager; _userManager = userManager; } public void SetPlayed() { var userName = "MyUserName"; var user = _userManager.GetUserByName(userName.AsSpan()); var baseItem = _libraryManager.GetItemList(new InternalItemsQuery(user) { ItemIds = new[] { 179 }, Limit = 1 }).First(); var userData = _userDataManager.GetUserData(user, baseItem); var played = _userDataManager.UpdatePlayState(baseItem, userData, baseItem.RunTimeTicks); Plugin.InfoLogger("Item: {0} is played completely: {1}", baseItem.InternalId, played); } } The resulting log line says the item is watched completely, but the item does not get marked played. What i'm doing wrong? Link to comment Share on other sites More sharing options...
chef 3745 Posted April 14, 2020 Share Posted April 14, 2020 What happens if you run a refresh after setting the runtime ticks to the end? Link to comment Share on other sites More sharing options...
pünktchen 1251 Posted April 14, 2020 Author Share Posted April 14, 2020 I've refreshed the item and the library in the webif, but nothing happens. Link to comment Share on other sites More sharing options...
Solution rechigo 293 Posted April 14, 2020 Solution Share Posted April 14, 2020 BaseItem has a MarkPlayed method item.MarkPlayed(User user, DateTimeOffset datePlayed, bool resetPosition) Is this what you are looking for? 1 Link to comment Share on other sites More sharing options...
pünktchen 1251 Posted April 14, 2020 Author Share Posted April 14, 2020 That's exactly what i need. So much easier than my approach. Thank you so much @@rechigo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now