---
plan: "MyTV Continue Broadcasting Dialog"
description: "Implement a continue broadcasting dialog at the end of the MyTV playlist to allow users to select the next series to watch."
status: "completed"
priority: "high"
complexity: "moderate"
created: "2026-04-12"
updated: "2026-04-13"
completed: "2026-04-13"
depends_on:
  - null
related_features:
  - "docs/features/plugin-video-milionar/004-mytv.md"
related_research:
  - null
estimated_files: 4
---

# MyTV Continue Broadcasting Dialog

## Motivation
Currently, when a user watches a MyTV channel via the "Živé vysílání" (broadcast) button, the playback stops when the fixed playlist (e.g., 12 episodes) concludes. To provide a truly continuous "Live TV" experience, the user should be prompted at the end of the broadcast with an interactive, beautifully designed dialog allowing them to select which series should follow, effortlessly extending the broadcast.

## Goal
Show a large "Pokračovat v živém vysílání" (Continue Broadcasting) dialog when the last episode of the broadcast playlist is reaching its end (similar to the autoplay countdown). The dialog will display a selection of series available on the channel. By default, the next logical series in the round-robin sequence is pre-selected. If the user makes a selection, a new program is assembled and playback continues seamlessly. Without a choice, the dialog remains on screen indefinitely until the user interacts or dismisses it. 

## Current state
`PlaylistCountdownMonitor` monitors the Kodi playlist. When it detects there are no further items (`!self._has_next_in_playlist()`), it currently treats playback as ending soon (single episode mode) without any proactive prompt for extending a channel broadcast. 

## Proposed solution

### Overview
1.  Create a visually rich `DialogMyTVContinue.xml` adhering to MyTV's aesthetic rules (rounded corners, specific color overlays, gradient fades).
2.  Implement `ContinueBroadcastDialog` Python class to drive the UI, populating it with series from the current channel context.
3.  Modify `PlaylistCountdownMonitor` to trigger this dialog on the last playlist item.
4.  If a series is selected, clear the program cache, generate a new queue starting from the selected series, and start playing the new playlist.

### Architecture
- **XML Dialog**: Uses absolute positioning, no flexbox, AARRGGBB colors, manual navigation (onup/ondown). Uses `focusedlayout` to present a horizontal carousel or grid of series posters/fanart.
- **Python Dialog Logic**: Receives the `channel_id`, looks up `MediaChannelManager` to get `series_list`, orders them according to what should logically play next based on current progress/cache, and waits for user selection via `doModal()`.
- **Integration**: `PlaylistCountdownMonitor` needs the `channel_id` (so we need to restore `self._channel_id` passing via `set_channel_context()` that was just reverted, but this time only for identifying the channel, NOT for auto-extending).

### Affected files

| File | Action | Change description |
|------|--------|-------------------|
| `resources/skins/Default/1080i/ai/DialogMyTVContinue.xml` | NEW | New XML layout matching MyTV style (gradients, rounded cards). |
| `wcs/playback/dialogs/continue_broadcast.py` | NEW | Dialog class `ContinueBroadcastDialog`. Returns selected `series_tmdb_id` or `None`. |
| `wcs/playback/PlaylistCountdownMonitor.py` | MODIFY | Restore `self._channel_id` property. When monitoring an episode and `!self._has_next_in_playlist()`, pause or just show the new dialog at countdown time. Handle the response. |
| `wcs/ai/DialogMyTV.py` | MODIFY | Restore `monitor.set_channel_context(channel_id)`. Expose a method to handle playlist continuation (e.g., generating new entries starting from `series_tmdb_id` and passing them to Kodi player). |

### Implementation steps

1.  **[x] Modify `PlaylistCountdownMonitor.py` and `DialogMyTV.py` context**
    *   Revert the removal of `set_channel_context(self, channel_id, addon_id)` in `PlaylistCountdownMonitor`.
    *   In `DialogMyTV._play_broadcast()`, call `monitor.set_channel_context(channel_id, addon_id)`.

2.  **[x] Create `wcs/playback/dialogs/continue_broadcast.py`**
    *   Define `ContinueBroadcastDialog(xbmcgui.WindowXMLDialog)`.
    *   Accept `channel_id` and list of ordered series.
    *   Property `WCS.Continue.SeriesCount` and list control population with series names, posters, and next episodes (using `ProgressManager` and `TMDbClient`).
    *   Return `ACTION_SELECT` and the chosen `series_tmdb_id`, or `ACTION_DISMISS`.

3.  **[x] Create `DialogMyTVContinue.xml`**
    *   Design: Fullscreen dark overlay (`gradient_cinematic_bottom.png`).
    *   Label "Pokračovat v živém vysílání".
    *   Horizontal list (id=50) for series selection. `itemlayout` and `focusedlayout` with `card_mask_large.png` or `still_mask_rounded.png`, using MyTV standard aesthetic variables.
    *   Buttons to confirm or cancel.

4.  **[x] Integrate dialog into `PlaylistCountdownMonitor._monitor_episode()`**
    *   Condition: `not self._has_next_in_playlist() and self._channel_id`.
    *   When countdown triggers, pause video, show `ContinueBroadcastDialog`.
    *   If user selects a series: Provide a mechanism to generate NEW playlist starting from `series_tmdb_id`, play it, and close dialog. Since `PlaylistCountdownMonitor` cannot easily call `DialogMyTV` methods as it's closed, `PlaylistCountdownMonitor` must build the playlist via `PlaylistBuilder` itself (similar to the previous `_extend_playlist_if_needed`, but starting explicitly from the selected series, and replacing the current playback).

### Settings changes
No new settings changes. Will respect the existing `mytv_upcoming_count` when generating the new playlist block.

### API / Interface changes
None inside public API. Only internal playback handling updates.

### Dependencies
No new dependencies. Requires `plugin-video-milionar` resources.

## Risks and limitations
- Playback transition: Generating the next 12 episodes from TMDB on the fly might take ~1-2 seconds. Should show a loading indication after selection if possible.
- The dialog will cover the end of the video. It must act similarly to the standard countdown dialog.

## Testing
1. Launch MyTV, select channel.
2. Press "Živé vysílání". Limit `mytv_upcoming_count` to 3 for faster testing.
3. Skip towards the end of the 3rd episode.
4. Verify the "Pokračovat v živém vysílání" dialog appears.
5. Select a different series.
6. Verify a new playlist loads and plays immediately starting with the selected series episode.

## Notes
- To avoid code duplication, ensure the logic to build a playlist of `mytv_upcoming_count` episodes starting from a specific series is separated into a shared helper class (e.g. `PlaylistBuilder.generate_channel_playlist()`) rather than locked inside `DialogMyTV`.
