/** * mex_media_controls_get_enqueued: * @controls: The MexMediaControls widget * @current_content: MexContent that the player is currently playing * * If the media controls has been given a queue model then return the next * MexContent in the queue model. * * Return value: The next content in the queue or NULL */ MexContent * mex_media_controls_get_enqueued (MexMediaControls *controls, MexContent *current_content) { MexMediaControlsPrivate *priv; MexModel *queue; MexContent *content = NULL; if (!MEX_IS_MEDIA_CONTROLS (controls) || !MEX_IS_CONTENT (current_content)) return NULL; priv = controls->priv; if (priv->is_queue_model == FALSE) return NULL; queue = mex_proxy_get_model (priv->proxy); if (queue) { gint idx, length; idx = mex_model_index (queue, current_content); length = mex_model_get_length (queue); if (idx++ > length) return NULL; content = mex_model_get_content (queue, idx); } return content; }
/** * mex_proxy_start_at: * @proxy: Proxy to add content to * @start_at_content: First content item in the model to add to * the proxy * @loop: Whether to loop back to the beginning of the * associated #MexModel's content items once the last item is reached; * if %TRUE, content items before the @start_at_content will be * added once the last of the model's content items is reached; * if %FALSE, only content items from @start_at_content to the last of * the model's content items are added * * Add content from a model to a proxy. */ void mex_proxy_start_at (MexProxy *proxy, MexContent *start_at_content, gboolean loop) { gint i; MexContent *content; MexProxyPrivate *priv; GController *controller; g_return_if_fail (MEX_IS_PROXY (proxy)); priv = proxy->priv; if (priv->started) { g_warning (G_STRLOC ": Trying to start an already started proxy"); return; } mex_proxy_clear (proxy); priv->started = TRUE; if (!priv->model) return; if (!G_TYPE_IS_OBJECT (priv->object_type)) { g_warning (G_STRLOC ": Proxy type is not an object type"); return; } /* Iterate over existing objects */ if (!start_at_content) { i = 0; while ((content = mex_model_get_content (priv->model, i++))) mex_proxy_add_content (proxy, content); } else { gint start_at; gboolean looped = FALSE; start_at = mex_model_index (priv->model, start_at_content); if (start_at == -1) { g_critical (G_STRLOC ": Content %p not found in %p model", start_at_content, priv->model); return; } for (i = start_at; TRUE; i++) { /* break out if looped and back around to start_at */ if (loop && looped && i == start_at) break; if ((content = mex_model_get_content (priv->model, i))) { mex_proxy_add_content (proxy, content); } else { if (loop) { looped = TRUE; i = -1; } else break; } } } controller = mex_model_get_controller (priv->model); g_signal_connect_after (controller, "changed", G_CALLBACK (mex_proxy_controller_changed_cb), proxy); }