Skip to content

Commit

Permalink
git add players.h and players.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumPaget committed Jun 15, 2017
1 parent 2a768bd commit a314b7b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
60 changes: 60 additions & 0 deletions players.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "players.h"

ListNode *Players=NULL;
char *Player=NULL;
pid_t PlayerPid=0;

void ParsePlayer(const char *Config)
{
char *ContentType=NULL;
const char *ptr;

ptr=GetToken(Config,"\\S",&ContentType,GETTOKEN_QUOTES);
if (! Players) Players=ListCreate();
SetVar(Players,ContentType,ptr);

DestroyString(ContentType);
}



char *SelectPlayer(const char *ContentType)
{
ListNode *Curr;

Curr=ListGetNext(Players);
while (Curr)
{
if (fnmatch(Curr->Tag, ContentType, 0)==0)
{
printf("PLAYER: [%s] %s\n",ContentType,Curr->Item);
Player=CopyStr(Player, (char *) Curr->Item);
return((char *) Curr->Item);
}
Curr=ListGetNext(Curr);
}

return(NULL);
}

void SetPlayer(const char *Config)
{
if (strcmp(Config, "auto")==0) Flags |= FLAG_PLAYER_AUTO;
else Player=CopyStr(Player, Config);
}


void LaunchPlayer()
{
char *Tempstr=NULL;

if (PlayerPid > 0) return;
if (! StrValid(Player)) return;

Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
PlayerPid=Spawn(Tempstr,"");

DestroyString(Tempstr);
}


13 changes: 13 additions & 0 deletions players.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef MOVGRAB_PLAYERS_H
#define MOVGRAB_PLAYERS_H

#include "common.h"

extern int DisplayTitleWidth;

void ParsePlayer(const char *Config);
char *SelectPlayer(const char *ContentType);
void SetPlayer(const char *Config);
void LaunchPlayer();

#endif

0 comments on commit a314b7b

Please sign in to comment.