Skip to content

Commit a314b7b

Browse files
committed
git add players.h and players.c
1 parent 2a768bd commit a314b7b

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

players.c

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include "players.h"
2+
3+
ListNode *Players=NULL;
4+
char *Player=NULL;
5+
pid_t PlayerPid=0;
6+
7+
void ParsePlayer(const char *Config)
8+
{
9+
char *ContentType=NULL;
10+
const char *ptr;
11+
12+
ptr=GetToken(Config,"\\S",&ContentType,GETTOKEN_QUOTES);
13+
if (! Players) Players=ListCreate();
14+
SetVar(Players,ContentType,ptr);
15+
16+
DestroyString(ContentType);
17+
}
18+
19+
20+
21+
char *SelectPlayer(const char *ContentType)
22+
{
23+
ListNode *Curr;
24+
25+
Curr=ListGetNext(Players);
26+
while (Curr)
27+
{
28+
if (fnmatch(Curr->Tag, ContentType, 0)==0)
29+
{
30+
printf("PLAYER: [%s] %s\n",ContentType,Curr->Item);
31+
Player=CopyStr(Player, (char *) Curr->Item);
32+
return((char *) Curr->Item);
33+
}
34+
Curr=ListGetNext(Curr);
35+
}
36+
37+
return(NULL);
38+
}
39+
40+
void SetPlayer(const char *Config)
41+
{
42+
if (strcmp(Config, "auto")==0) Flags |= FLAG_PLAYER_AUTO;
43+
else Player=CopyStr(Player, Config);
44+
}
45+
46+
47+
void LaunchPlayer()
48+
{
49+
char *Tempstr=NULL;
50+
51+
if (PlayerPid > 0) return;
52+
if (! StrValid(Player)) return;
53+
54+
Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
55+
PlayerPid=Spawn(Tempstr,"");
56+
57+
DestroyString(Tempstr);
58+
}
59+
60+

players.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef MOVGRAB_PLAYERS_H
2+
#define MOVGRAB_PLAYERS_H
3+
4+
#include "common.h"
5+
6+
extern int DisplayTitleWidth;
7+
8+
void ParsePlayer(const char *Config);
9+
char *SelectPlayer(const char *ContentType);
10+
void SetPlayer(const char *Config);
11+
void LaunchPlayer();
12+
13+
#endif

0 commit comments

Comments
 (0)