Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: track_info.c
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- track_info.c (revision 35ca936eb33e206ff2b083a5fc7a4f32e682b82d)
- +++ track_info.c (revision )
- @@ -54,6 +54,92 @@
- ti->comments = NULL;
- ti->codec = NULL;
- ti->codec_profile = NULL;
- +
- + // TODO: There must be a better way to locate the SRT
- + char filename_str[strlen(filename)];
- + memcpy(filename_str, filename, sizeof(char) * strlen(filename));
- +
- + filename_str[strlen(filename) - 3] = 's';
- + filename_str[strlen(filename) - 2] = 'r';
- + filename_str[strlen(filename) - 1] = 't';
- +
- + if (access(filename_str, F_OK) != -1) {
- + ti->have_lyrics = 1;
- + ti->showTextLyric = 0;
- + ti->lastLyric = 0;
- +
- + FILE *fp;
- + fp = fopen(filename_str, "r");
- +
- + enum {lCounter, lTime, lText, lBlank} currentTypeLine = lCounter;
- +
- + int countLyrics = 0;
- + char buffer[256];
- + int bufferCount = 0;
- + while ((buffer[bufferCount] = getc(fp)) != EOF) {
- + if (buffer[bufferCount] == '\n') {
- + buffer[bufferCount - 1] = '\0';
- + if (currentTypeLine == lTime) {
- + int temp1;
- + char start_hours[2];
- + start_hours[0] = buffer[0];
- + start_hours[1] = buffer[1];
- + sscanf(start_hours, "%d", &temp1);
- +
- + int temp2;
- + char start_minutes[2];
- + start_minutes[0] = buffer[3];
- + start_minutes[1] = buffer[4];
- + sscanf(start_minutes, "%d", &temp2);
- +
- + int temp3;
- + char start_seconds[2];
- + start_seconds[0] = buffer[6];
- + start_seconds[1] = buffer[7];
- + sscanf(start_seconds, "%d", &temp3);
- +
- + ti->lyric[countLyrics].timeStart = (temp1 * 3600) + (temp2 * 60) + (temp3);
- +
- + int temp4;
- + char end_hours[2];
- + end_hours[0] = buffer[17];
- + end_hours[1] = buffer[18];
- + sscanf(end_hours, "%d", &temp4);
- +
- + int temp5;
- + char end_minutes[2];
- + end_minutes[0] = buffer[20];
- + end_minutes[1] = buffer[21];
- + sscanf(end_minutes, "%d", &temp5);
- +
- + int temp6;
- + char end_seconds[2];
- + end_seconds[0] = buffer[23];
- + end_seconds[1] = buffer[24];
- + sscanf(end_seconds, "%d", &temp6);
- +
- + ti->lyric[countLyrics].timeEnd = (temp4 * 3600) + (temp5 * 60) + (temp6);
- + } else if (currentTypeLine == lText) {
- + strcpy(ti->lyric[countLyrics].messageText, buffer);
- + countLyrics++;
- + }
- +
- + if (currentTypeLine == lBlank) {
- + currentTypeLine = lCounter;
- + } else {
- + currentTypeLine++;
- + }
- +
- + bufferCount = 0;
- + buffer[bufferCount] = '\0';
- + } else {
- + bufferCount++;
- + }
- + }
- + } else {
- + ti->have_lyrics = 0;
- + }
- +
- return ti;
- }
- Index: options.c
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- options.c (revision 35ca936eb33e206ff2b083a5fc7a4f32e682b82d)
- +++ options.c (revision )
- @@ -225,6 +225,7 @@
- " %{status} %{?show_playback_position?%{position} %{?duration?/ %{duration} }?%{?duration?%{duration} }}"
- "- %{total} "
- "%{?volume>=0?vol: %{?lvolume!=rvolume?%{lvolume},%{rvolume} ?%{volume} }}"
- + " | %{lyrics} | "
- "%{?stream?buf: %{buffer} }"
- "%{?show_current_bitrate & bitrate>=0? %{bitrate} kbps }"
- "%="
- Index: track_info.h
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- track_info.h (revision 35ca936eb33e206ff2b083a5fc7a4f32e682b82d)
- +++ track_info.h (revision )
- @@ -22,6 +22,12 @@
- #include <time.h>
- #include <stddef.h>
- +struct sLyric {
- + int timeStart;
- + int timeEnd;
- + char messageText[256];
- +};
- +
- struct track_info {
- struct keyval *comments;
- @@ -64,6 +70,12 @@
- unsigned int play_count;
- int is_va_compilation : 1;
- +
- + int have_lyrics;
- + struct sLyric lyric[256];
- + int lastLyric;
- + int showTextLyric;
- + char *currentTextLyric;
- };
- typedef size_t sort_key_t;
- Index: ui_curses.c
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- ui_curses.c (revision 35ca936eb33e206ff2b083a5fc7a4f32e682b82d)
- +++ ui_curses.c (revision )
- @@ -289,6 +289,7 @@
- TF_VOLUME,
- TF_LVOLUME,
- TF_RVOLUME,
- + TF_LYRICS,
- TF_BUFFER,
- TF_REPEAT,
- TF_CONTINUE,
- @@ -345,6 +346,7 @@
- DEF_FO_INT('\0', "volume", 1),
- DEF_FO_INT('\0', "lvolume", 1),
- DEF_FO_INT('\0', "rvolume", 1),
- + DEF_FO_STR('\0', "lyrics", 0),
- DEF_FO_INT('\0', "buffer", 1),
- DEF_FO_STR('\0', "repeat", 0),
- DEF_FO_STR('\0', "continue", 0),
- @@ -653,8 +655,15 @@
- fopt_set_str(&track_fopts[TF_SHUFFLE], shuffle_strs[shuffle]);
- fopt_set_str(&track_fopts[TF_PLAYLISTMODE], aaa_mode_names[aaa_mode]);
- - if (player_info.ti)
- + if (player_info.ti) {
- duration = player_info.ti->duration;
- +
- + if (player_info.ti->have_lyrics && player_info.ti->showTextLyric) {
- + fopt_set_str(&track_fopts[TF_LYRICS], player_info.ti->currentTextLyric);
- + } else {
- + fopt_set_str(&track_fopts[TF_LYRICS], "");
- + }
- + }
- vol_left = vol_right = vol = -1;
- if (soft_vol) {
- Index: player.c
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- player.c (revision 35ca936eb33e206ff2b083a5fc7a4f32e682b82d)
- +++ player.c (revision )
- @@ -533,6 +533,17 @@
- player_info_lock();
- player_info.pos = pos;
- + if (player_info.ti->have_lyrics) {
- + if (player_info.ti->lastLyric > 0 && player_info.ti->lyric[player_info.ti->lastLyric - 1].timeEnd <= pos)
- + player_info.ti->showTextLyric = 0;
- +
- + if (player_info.ti->lyric[player_info.ti->lastLyric].timeStart <= pos) {
- + player_info.ti->currentTextLyric = player_info.ti->lyric[player_info.ti->lastLyric].messageText;
- + player_info.ti->lastLyric++;
- + player_info.ti->showTextLyric = 1;
- + }
- + }
- +
- if (show_current_bitrate) {
- bitrate = ip_current_bitrate(ip);
- if (bitrate != -1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement