Skip to content

Commit

Permalink
Add new timeline states to try and bring in line with new API
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehamel committed Apr 17, 2019
1 parent 60b75e1 commit 2ef3cc6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
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

1 comment on commit 2ef3cc6

@bobone666
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This to get working with pi3?
Does work through berry boot with 1.8
Had probs with rasplex straight off sd without berry boot(yellow lightning) when ather os work fine with exactly same setup

Please sign in to comment.