Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Add new timeline states to try and bring in line with new API #315

Draft
wants to merge 1 commit into
base: openpht-1.9
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plex/Client/PlexTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ CUrlOptions CPlexTimeline::getTimeline(bool forServer)
controllable.push_back("skipNext");
}

if (controllable.size() > 0 && m_state != PLEX_MEDIA_STATE_STOPPED)
if (controllable.size() > 0 && m_state != PLEX_MEDIA_STATE_FINISHED)
options.AddOption("controllable", StringUtils::Join(controllable, ","));

if (g_application.m_pPlayer->IsPlaying() && m_state != PLEX_MEDIA_STATE_STOPPED)
if (g_application.m_pPlayer->IsPlaying() && m_state != PLEX_MEDIA_STATE_FINISHED)
{
options.AddOption("volume", g_application.GetVolume());

Expand Down Expand Up @@ -174,7 +174,7 @@ CUrlOptions CPlexTimeline::getTimeline(bool forServer)
}
}

if (m_state != PLEX_MEDIA_STATE_STOPPED)
if (m_state != PLEX_MEDIA_STATE_FINISHED)
{
std::string location = "navigation";

Expand Down
2 changes: 1 addition & 1 deletion plex/Client/PlexTimeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CPlexTimeline
{
public:
CPlexTimeline(ePlexMediaType type = PLEX_MEDIA_TYPE_UNKNOWN) : m_state(PLEX_MEDIA_STATE_STOPPED), m_continuing(false), m_type(type) {}
CPlexTimeline(ePlexMediaType type = PLEX_MEDIA_TYPE_UNKNOWN) : m_state(PLEX_MEDIA_STATE_FINISHED), m_continuing(false), m_type(type) {}

CPlexTimeline(const CPlexTimeline& other)
{
Expand Down
4 changes: 2 additions & 2 deletions plex/Client/PlexTimelineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void CPlexTimelineManager::ReportProgress(const CFileItemPtr &newItem, ePlexMedi

if ((oldTimeline && !oldTimeline->getItem()) || timeline->getItem()->GetPath() != oldTimeline->getItem()->GetPath())
{
if (oldTimeline->getState() != PLEX_MEDIA_STATE_STOPPED && oldTimeline)
if (oldTimeline->getState() != PLEX_MEDIA_STATE_CANCELLED && oldTimeline)
{
CFileItemPtr oldItem = oldTimeline->getItem();
if (oldItem->HasProperty("playQueueID") && newItem->HasProperty("playQueueID") && oldItem->GetProperty("playQueueID").asString() == newItem->GetProperty("playQueueID").asString())
Expand Down Expand Up @@ -190,7 +190,7 @@ void CPlexTimelineManager::ReportProgress(const CFileItemPtr &newItem, ePlexMedi

ReportProgress(timeline, reallyForce);

if (timeline->getState() == PLEX_MEDIA_STATE_STOPPED)
if (timeline->getState() == PLEX_MEDIA_STATE_FINISHED) // || Should this OR with cancelled?
{
/* Now we need to make sure that if this item is cached it's removed */
if (timeline->getItem())
Expand Down
4 changes: 3 additions & 1 deletion plex/PlexTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ enum ePlexMediaType {
};

enum ePlexMediaState {
PLEX_MEDIA_STATE_STOPPED,
PLEX_MEDIA_STATE_FINISHED,
PLEX_MEDIA_STATE_CANCELLED,
PLEX_MEDIA_STATE_ERROR,
PLEX_MEDIA_STATE_PLAYING,
PLEX_MEDIA_STATE_BUFFERING,
PLEX_MEDIA_STATE_PAUSED
Expand Down
20 changes: 15 additions & 5 deletions plex/PlexUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,14 @@ std::string PlexUtils::GetMediaStateString(ePlexMediaState state)
{
CStdString strstate;
switch (state) {
case PLEX_MEDIA_STATE_STOPPED:
strstate = "stopped";
case PLEX_MEDIA_STATE_FINISHED:
strstate = "finished";
break;
case PLEX_MEDIA_STATE_CANCELLED:
strstate = "cancelled";
break;
case PLEX_MEDIA_STATE_ERROR:
strstate = "error";
break;
case PLEX_MEDIA_STATE_BUFFERING:
strstate = "buffering";
Expand All @@ -802,16 +808,20 @@ std::string PlexUtils::GetMediaStateString(ePlexMediaState state)

///////////////////////////////////////////////////////////////////////////////////////////////////
ePlexMediaState PlexUtils::GetMediaStateFromString(const std::string& statestr)
{ if (statestr == "stopped")
return PLEX_MEDIA_STATE_STOPPED;
{ if (statestr == "finished")
return PLEX_MEDIA_STATE_FINISHED;
else if (statestr == "cancelled")
return PLEX_MEDIA_STATE_CANCELLED;
else if (statestr == "error")
return PLEX_MEDIA_STATE_ERROR;
else if (statestr == "buffering")
return PLEX_MEDIA_STATE_BUFFERING;
else if (statestr == "playing")
return PLEX_MEDIA_STATE_PLAYING;
else if (statestr == "paused")
return PLEX_MEDIA_STATE_PAUSED;

return PLEX_MEDIA_STATE_STOPPED;
return PLEX_MEDIA_STATE_FINISHED;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down