Skip to content

Commit

Permalink
videoplayer: Improve how we display errors if unable to play the vide…
Browse files Browse the repository at this point in the history
…o sources

Fixes #2624
  • Loading branch information
andoma committed May 18, 2015
1 parent b7be5b0 commit 7f5742b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
3 changes: 2 additions & 1 deletion glwskins/default/pages/openerror.view
Expand Up @@ -17,7 +17,8 @@ widget(container_y, {

widget(label, {
align: center;
caption: _("Unable to open resource");
caption: fmt(_("Unable to open %s"),
$self.model.metadata.title ?? _("resource"));
TextStyleItem();
sizeScale: 1.5;
});
Expand Down
79 changes: 49 additions & 30 deletions src/video/video_playback.c
Expand Up @@ -193,19 +193,37 @@ play_video(const char *url, struct media_pipe *mp,
snprintf(errbuf, errlen, "No backend for URL");
return NULL;
}

rstr_t *r = prop_get_string(p, "source", NULL);
prop_destroy(p);
if(r != NULL) {
TRACE(TRACE_DEBUG, "vp", "Page %s redirects to video source %s\n",
url, rstr_get(r));
event_t *e = play_video(rstr_get(r), mp, flags, priority,
errbuf, errlen, vq, parent_title, parent_url,
origin, resume_mode);
prop_destroy(p);
rstr_release(r);
return e;
}
snprintf(errbuf, errlen,
"Page model for '%s' does not provide a video source", url);

rstr_t *type = prop_get_string(p, "model", "type", NULL);
rstr_t *err = prop_get_string(p, "model", "error", NULL);
rstr_t *title = prop_get_string(p, "model", "metadata", "title", NULL);

if(type != NULL && !strcmp(rstr_get(type), "openerror")) {

prop_set(mp->mp_prop_metadata, "title", PROP_SET_RSTRING, title);
snprintf(errbuf, errlen, "%s",
err ? rstr_get(err) : "Unable to open URL");

} else {
snprintf(errbuf, errlen,
"Page model for '%s' does not provide sufficient data", url);
}
rstr_release(type);
rstr_release(err);
rstr_release(title);
prop_destroy(p);
return NULL;

}
Expand All @@ -230,6 +248,34 @@ play_video(const char *url, struct media_pipe *mp,

canonical_url = htsmsg_get_str(m, "canonicalUrl");

// Metadata

if((str = htsmsg_get_str(m, "title")) != NULL) {
prop_set(mp->mp_prop_metadata, "title", PROP_SET_STRING, str);
va.title = str;
} else {
flags |= BACKEND_VIDEO_SET_TITLE;
}

uint32_t u32;
if(!htsmsg_get_u32(m, "year", &u32)) {
prop_set(mp->mp_prop_metadata, "year", PROP_SET_INT, u32);
va.year = u32;
}
if(!htsmsg_get_u32(m, "season", &u32)) {
prop_set(mp->mp_prop_metadata, "season", PROP_SET_INT, u32);
va.season = u32;
}
if(!htsmsg_get_u32(m, "episode", &u32)) {
prop_set(mp->mp_prop_metadata, "episode", PROP_SET_INT, u32);
va.episode = u32;
}


if((str = htsmsg_get_str(m, "imdbid")) != NULL)
va.imdb = str;


// Sources

if((sources = htsmsg_get_list(m, "sources")) == NULL) {
Expand Down Expand Up @@ -257,33 +303,6 @@ play_video(const char *url, struct media_pipe *mp,
return NULL;
}

// Other metadata

if((str = htsmsg_get_str(m, "title")) != NULL) {
prop_set(mp->mp_prop_metadata, "title", PROP_SET_STRING, str);
va.title = str;
} else {
flags |= BACKEND_VIDEO_SET_TITLE;
}

uint32_t u32;
if(!htsmsg_get_u32(m, "year", &u32)) {
prop_set(mp->mp_prop_metadata, "year", PROP_SET_INT, u32);
va.year = u32;
}
if(!htsmsg_get_u32(m, "season", &u32)) {
prop_set(mp->mp_prop_metadata, "season", PROP_SET_INT, u32);
va.season = u32;
}
if(!htsmsg_get_u32(m, "episode", &u32)) {
prop_set(mp->mp_prop_metadata, "episode", PROP_SET_INT, u32);
va.episode = u32;
}


if((str = htsmsg_get_str(m, "imdbid")) != NULL)
va.imdb = str;


// Subtitles

Expand Down

0 comments on commit 7f5742b

Please sign in to comment.