home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
Trakt.tv LiveTV scrobble Development help request.
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Alberto83" data-source="post: 1223312" data-attributes="member: 128278"><p>These are the changes to the SlimTVHandler.cs</p><p>[code=csharp] </p><p>/*snip*/</p><p>private struct TVSlotContext</p><p> {</p><p> public bool IsPiP;</p><p> public bool CardChanging;</p><p> public string AccessorPath;</p><p> public IChannel Channel;</p><p> //one timer for each slot.</p><p> //@ASK!!! What about doing this server side? one timeline for each stream? Would definitely solve placeshifting issues.</p><p> public Timer nextProgramWatcher;</p><p> }</p><p>/*SNIP*/</p><p>private bool AddOrUpdateTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel)</p><p> {</p><p> //Do this ASAP so the timer is as close as possible to the real program time change.</p><p> System.DateTime currentTime = System.DateTime.Now;</p><p> //Need to check if a timer is already set before dispose it</p><p> if (_slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher!=null)</p><p> _slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher.Dispose();</p><p> if (timeshiftMediaItem.TimeshiftContexes.LastOrDefault() != null) </p><p> {</p><p> //this is not the first context, so so get the one before and set its duration.</p><p> timeshiftMediaItem.TimeshiftContexes.Last().TimeshiftDuration = currentTime.Subtract(timeshiftMediaItem.TimeshiftContexes.Last().TuneInTime);</p><p> }</p><p> TimeshiftContext tsContext;</p><p> if (CurrentProgram== null) // there's no program information, just go as normal, and don't set a timer to update.</p><p> {</p><p> tsContext = new TimeshiftContext</p><p> {</p><p> Channel = channel,</p><p> TuneInTime = currentTime,</p><p> };</p><p> }</p><p> else //populate tscontext with program info and set the timer</p><p> {</p><p> tsContext = new TimeshiftContext</p><p> {</p><p> Channel = channel,</p><p> TuneInTime = currentTime,</p><p> Program = CurrentProgram</p><p> };</p><p> //Add a timer to trigger an update when next program begins.</p><p> //Start a new timer to call GetNewProgram when the program is due, plus 15 seconds.</p><p> _slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher = new Timer(GetNewProgram, timeshiftMediaItem,</p><p> (tsContext.Program.EndTime - currentTime + System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)), Timeout.InfiniteTimeSpan);</p><p> }</p><p> timeshiftMediaItem.TimeshiftContexes.Add(tsContext);</p><p> timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel;</p><p> return true;</p><p> }</p><p> private void GetNewProgram(object o)</p><p> {</p><p> //This will only get called when the current channel does not change. </p><p> System.DateTime currentTime = (System.DateTime.Now - System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)); //remember the NEXT_PROGRAM_WATCHER_DELAY</p><p> LiveTvMediaItem mi = (LiveTvMediaItem)o;</p><p> //Set offset for the last tscontext</p><p> mi.TimeshiftContexes.LastOrDefault().TimeshiftDuration = (currentTime - mi.TimeshiftContexes.LastOrDefault().TuneInTime);</p><p> //Create the new TSContext</p><p> //first check if the program is null</p><p> if (CurrentProgram == null) //since this function should only triggers when the program change in the current stream, we probably already have epg set, but nobody knows. Bad EPG data?</p><p> {</p><p> TimeshiftContext tsContext = new TimeshiftContext</p><p> {</p><p> Channel = (IChannel)mi.AdditionalProperties[LiveTvMediaItem.CHANNEL],</p><p> TuneInTime = currentTime,</p><p> };</p><p> }</p><p> else</p><p> {</p><p> TimeshiftContext tsContext = new TimeshiftContext</p><p> {</p><p> Channel = (IChannel)mi.AdditionalProperties[LiveTvMediaItem.CHANNEL],</p><p> TuneInTime = currentTime,</p><p> Program = CurrentProgram //@NOTE!!!! ok, what if the user changes channel just "a line before??"</p><p> };</p><p> //Add the new program to contexes</p><p> mi.TimeshiftContexes.Add(tsContext);</p><p> //This is safe</p><p> mi.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = CurrentProgram;</p><p> mi.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = (NextProgram != null) ? NextProgram : null;</p><p> //update timer to the next program change.</p><p> _slotContexes[(int)mi.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher.Change(</p><p> (tsContext.Program.EndTime - currentTime + System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)), Timeout.InfiniteTimeSpan);</p><p> }</p><p> }</p><p>/*snip*/</p><p>[/code]</p><p></p><p>I could optimize the code by calling again AddOrUpdateTimeshiftContext in the callback function but i wanted to keep it separate for easier debugging (not a pro coder, you can tell from my comments to always know what and why i did something. Need more practice, sorry ) my own code.</p><p>With this changes i could get a timeline with just a few milliseconds delay from the real epg data.</p></blockquote><p></p>
[QUOTE="Alberto83, post: 1223312, member: 128278"] These are the changes to the SlimTVHandler.cs [code=csharp] /*snip*/ private struct TVSlotContext { public bool IsPiP; public bool CardChanging; public string AccessorPath; public IChannel Channel; //one timer for each slot. //@ASK!!! What about doing this server side? one timeline for each stream? Would definitely solve placeshifting issues. public Timer nextProgramWatcher; } /*SNIP*/ private bool AddOrUpdateTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel) { //Do this ASAP so the timer is as close as possible to the real program time change. System.DateTime currentTime = System.DateTime.Now; //Need to check if a timer is already set before dispose it if (_slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher!=null) _slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher.Dispose(); if (timeshiftMediaItem.TimeshiftContexes.LastOrDefault() != null) { //this is not the first context, so so get the one before and set its duration. timeshiftMediaItem.TimeshiftContexes.Last().TimeshiftDuration = currentTime.Subtract(timeshiftMediaItem.TimeshiftContexes.Last().TuneInTime); } TimeshiftContext tsContext; if (CurrentProgram== null) // there's no program information, just go as normal, and don't set a timer to update. { tsContext = new TimeshiftContext { Channel = channel, TuneInTime = currentTime, }; } else //populate tscontext with program info and set the timer { tsContext = new TimeshiftContext { Channel = channel, TuneInTime = currentTime, Program = CurrentProgram }; //Add a timer to trigger an update when next program begins. //Start a new timer to call GetNewProgram when the program is due, plus 15 seconds. _slotContexes[(int)timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher = new Timer(GetNewProgram, timeshiftMediaItem, (tsContext.Program.EndTime - currentTime + System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)), Timeout.InfiniteTimeSpan); } timeshiftMediaItem.TimeshiftContexes.Add(tsContext); timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel; return true; } private void GetNewProgram(object o) { //This will only get called when the current channel does not change. System.DateTime currentTime = (System.DateTime.Now - System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)); //remember the NEXT_PROGRAM_WATCHER_DELAY LiveTvMediaItem mi = (LiveTvMediaItem)o; //Set offset for the last tscontext mi.TimeshiftContexes.LastOrDefault().TimeshiftDuration = (currentTime - mi.TimeshiftContexes.LastOrDefault().TuneInTime); //Create the new TSContext //first check if the program is null if (CurrentProgram == null) //since this function should only triggers when the program change in the current stream, we probably already have epg set, but nobody knows. Bad EPG data? { TimeshiftContext tsContext = new TimeshiftContext { Channel = (IChannel)mi.AdditionalProperties[LiveTvMediaItem.CHANNEL], TuneInTime = currentTime, }; } else { TimeshiftContext tsContext = new TimeshiftContext { Channel = (IChannel)mi.AdditionalProperties[LiveTvMediaItem.CHANNEL], TuneInTime = currentTime, Program = CurrentProgram //@NOTE!!!! ok, what if the user changes channel just "a line before??" }; //Add the new program to contexes mi.TimeshiftContexes.Add(tsContext); //This is safe mi.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = CurrentProgram; mi.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = (NextProgram != null) ? NextProgram : null; //update timer to the next program change. _slotContexes[(int)mi.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]].nextProgramWatcher.Change( (tsContext.Program.EndTime - currentTime + System.TimeSpan.FromSeconds(NEXT_PROGRAM_WATCHER_DELAY)), Timeout.InfiniteTimeSpan); } } /*snip*/ [/code] I could optimize the code by calling again AddOrUpdateTimeshiftContext in the callback function but i wanted to keep it separate for easier debugging (not a pro coder, you can tell from my comments to always know what and why i did something. Need more practice, sorry ) my own code. With this changes i could get a timeline with just a few milliseconds delay from the real epg data. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Trakt.tv LiveTV scrobble Development help request.
Contact us
RSS
Top
Bottom