cinera_player_pre.js: Reenable YT interaction

Essentially, the previous change prevented the marker progress code from
firing if the user only interacts with the YouTube player directly.

cinera.c: Try to curl the quotes in, rather than straight up deleting
them, if(ShouldFetchQuotes)
This commit is contained in:
Matt Mascarenhas 2018-02-28 20:18:11 +00:00
parent 2053be1969
commit ab598e37e6
2 changed files with 10 additions and 19 deletions

View File

@ -14,7 +14,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 5,
.Patch = 36
.Patch = 37
};
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
@ -1741,13 +1741,13 @@ CurlQuotes(buffer *QuoteStaging, char *QuotesURL)
fprintf(stderr, "\e[0;35mFetching\e[0m quotes: %s\n", QuotesURL);
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
CURLcode CurlReturnCode;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &QuoteStaging->Ptr);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlIntoBuffer);
curl_easy_setopt(curl, CURLOPT_URL, QuotesURL);
if((res = curl_easy_perform(curl)))
if((CurlReturnCode = curl_easy_perform(curl)))
{
fprintf(stderr, "%s", curl_easy_strerror(res));
fprintf(stderr, "%s\n", curl_easy_strerror(CurlReturnCode));
}
curl_easy_cleanup(curl);
}
@ -1811,14 +1811,9 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, bool ShouldFetchQuotes)
char QuoteCachePath[256];
CopyString(QuoteCachePath, "%s/%s", QuoteCacheDir, Speaker);
if(ShouldFetchQuotes)
{
remove(QuoteCachePath);
}
FILE *QuoteCache;
char QuotesURL[256];
// TODO(matt): Make the URL configurable
// TODO(matt): Make the URL configurable and also handle the case in which the .raw isn't available
CopyString(QuotesURL, "https://dev.abaines.me.uk/quotes/%s.raw", Speaker);
bool CacheAvailable = FALSE;
@ -1869,7 +1864,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, bool ShouldFetchQuotes)
fread(QuoteStaging.Location, FileSize, 1, QuoteCache);
fclose(QuoteCache);
if(SearchQuotes(&QuoteStaging, FileSize, Info, ID) == RC_UNFOUND)
if(ShouldFetchQuotes || SearchQuotes(&QuoteStaging, FileSize, Info, ID) == RC_UNFOUND)
{
CurlQuotes(&QuoteStaging, QuotesURL);

View File

@ -42,7 +42,7 @@ function Player(htmlContainer, refsCallback) {
this.buffering = false;
this.pauseAfterBuffer = false;
this.speed = 1;
this.currentTime = 0;
this.currentTime = -1;
this.lastFrameTime = 0;
this.scrollTo = -1;
this.scrollPosition = 0;
@ -56,6 +56,7 @@ function Player(htmlContainer, refsCallback) {
Player.initializeYoutube(this.onYoutubeReady.bind(this));
this.updateSize();
this.resume();
}
// Start playing the video from the current position.
@ -66,7 +67,6 @@ Player.prototype.play = function() {
this.youtubePlayer.playVideo();
}
this.pauseAfterBuffer = false;
this.resume();
} else {
this.shouldPlay = true;
}
@ -118,10 +118,6 @@ Player.prototype.updateSize = function() {
this.markersContainer.style.height = height;
if (this.youtubePlayerReady) {
this.youtubePlayer.setSize(Math.floor(width), Math.floor(height));
if(this.playing)
{
this.resume();
}
}
}
@ -238,7 +234,7 @@ Player.prototype.updateProgress = function() {
}
if (this.currentMarker) {
this.refsCallback(this.currentMarker.ref, this.currentMarker.el);
this.refsCallback(this.currentMarker.ref, this.currentMarker.el, this);
} else if (prevMarker && prevMarker.ref) {
this.refsCallback(null);
}
@ -1179,7 +1175,7 @@ function resetFade() {
}
}
function onRefChanged(ref, element) {
function onRefChanged(ref, element, player) {
if(element.classList.contains("skip"))
{
var filterState;