FIX: enum QuviInfo values
[libquvi.git] / src / api / doxy / query_formats.dp
blob69bfb9feb7bcf749afa731e39ba8a123694fd415
1 /** @page query_formats Querying available media formats
3 @section default Default behaviour
5 By default, the library will return a @ref ms_url to the "default"
6 media format -- whatever the media script determines it to be.
8 @section multi Multiple formats
10 Some of the websites provide >1 formats for the media. The number,
11 and the quality of these media formats may vary greatly, depending on
12 the website. Therefore, the application should first query the available
13 formats to a @ref m_url , and then have either the user of the application
14 or the application itself to choose which one to access.
16 The example below shows how to query the formats. For added readability,
17 it uses the GLib string utility functions (the 'g_str' prefix).
19 @code
20 quvi_query_formats_t qqf = quvi_query_formats_new(q, URL);
21 abort_if_error();
23   gchar *fmts;
24   gchar **r;
25   gint i;
27   fmts = quvi_query_formats_get(qqf);
28   r = g_strsplit(fmts, ",", 0);
30   for (i=0; r[i] != NULL; ++i)
31     {
32       quvi_media_t m;
33       gchar *url;
35       /* Set the format string the application should access. */
36       quvi_set(q, QUVI_OPTION_REQUEST_FORMAT, r[i]);
38       /* Return the media properties for the media URL. */
39       m = quvi_media_new(q, URL);
40       abort_if_error();
42       /* Access the media stream URL for this format. */
43       quvi_media_get(m, QUVI_MEDIA_PROPERTY_STREAM_URL, &url);
44       stream_from(url);
46       quvi_media_free(m);
47       m = NULL;
48     }
50   g_strfreev(r);
51   r = NULL;
53 quvi_query_formats_free(qqf); /* Release when done using it. */
54 qqf = NULL;
55 @endcode
57 @note @ref quvi_query_formats_get returns always at least "default"
59 @sa @ref m_format
61 The available @ref m_script collection determines which
62 websites are supported by the library.