예제 #1
0
파일: fa_backend.c 프로젝트: Hr-/showtime
static int
file_open_file(prop_t *page, const char *url, struct fa_stat *fs)
{
  char redir[URL_MAX];
  char errbuf[200];
  int c;
  prop_t *meta;

  meta = prop_create_root("metadata");

  c = fa_probe(meta, url, redir, sizeof(redir), errbuf, sizeof(errbuf), fs, 1);

  switch(c) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    prop_destroy(meta);
    return file_open_dir(page, redir);

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      prop_destroy(meta);
      return 0;
    }

    playqueue_play(url, meta, 0);
    return playqueue_open(page);

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    prop_destroy(meta);
    return backend_open_video(page, url);

  case CONTENT_IMAGE:
    return file_open_image(page, meta);

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    return 0;

  default:
    prop_destroy(meta);
    return nav_open_error(page, errbuf);
  }
}
예제 #2
0
static void
file_open_file(prop_t *page, const char *url, fa_stat_t *fs)
{
  char errbuf[200];
  metadata_t *md;

  void *db = metadb_get();
  md = metadb_metadata_get(db, url, fs->fs_mtime);
  metadb_close(db);

  if(md == NULL)
    md = fa_probe_metadata(url, errbuf, sizeof(errbuf), NULL);

  if(md == NULL) {
    nav_open_errorf(page, _("Unable to open file: %s"), errbuf);
    return;
  }

  if(md->md_redirect != NULL)
    url = md->md_redirect;

  prop_t *meta = prop_create_root("metadata");

  metadata_to_proptree(md, meta, 0);

  switch(md->md_contenttype) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    file_open_browse(page, url, fs->fs_mtime);
    break;

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      break;
    }
    playqueue_play(url, meta, 0);
    playqueue_open(page);
    meta = NULL;
    break;

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    backend_open_video(page, url, 0);
    break;

  case CONTENT_IMAGE:
    file_open_image(page, meta);
    meta = NULL;
    break;

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    break;

  default:
    nav_open_errorf(page, _("Can't handle content type %d"),
		    md->md_contenttype);
    break;
  }
  prop_destroy(meta);
  metadata_destroy(md);
}