Web lists-archives.org

[MPlayer-dev-eng] Patch for a pause property




I'm working on a stateless frontend for mplayer. And to give a good feel for the app(a play/pause button that shows play or pause, not both, and not two buttons), I wanted to know if mplayer was paused or not since it could be controlled outside of my infrastructure. Setting if it's paused or not doesn't work, it just pauses it. It only patches command.c and not slave.txt. I've never dealt with mplayer's internals so this was mainly just to get what I needed than anything else. Hopefully someone knows how to clean it up and get it working right.

--- command.c.orig	2007-10-07 14:49:33.000000000 -0500
+++ command.c	2008-06-09 02:16:05.000000000 -0500
@@ -398,6 +398,45 @@
     return M_PROPERTY_NOT_IMPLEMENTED;
 }
 
+/// Pause (RW)
+static int mp_property_pause(m_option_t * prop, int action, void *arg,
+			    MPContext * mpctx)
+{
+    switch (action) {
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+	mpctx->was_paused = !mpctx->was_paused;
+	return M_PROPERTY_OK;
+    case M_PROPERTY_PRINT:
+	if (!arg)
+	    return M_PROPERTY_ERROR;
+	if (mpctx->was_paused) {
+	    *(char **) arg = strdup(MSGTR_Enabled);
+	    return M_PROPERTY_OK;
+	}
+	else {
+	    *(char **) arg = strdup(MSGTR_Disabled);
+	    return M_PROPERTY_OK;
+	}
+    case M_PROPERTY_SET:
+	if (!arg)
+	    return M_PROPERTY_ERROR;
+	else {
+		if (mpctx->was_paused) {
+			mpctx->was_paused = 0;
+		}
+		else {
+			pause_loop();
+			mpctx->was_paused = 1;
+		}
+		return M_PROPERTY_OK;
+	}
+    default:
+	return m_property_flag(prop, action, arg, &mpctx->was_paused);
+
+    }
+}
+
 
 ///@}
 
@@ -1630,6 +1669,8 @@
      M_OPT_MIN, 0, 0, NULL },
     { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
      0, 0, 0, NULL },
+    { "pause", mp_property_pause, CONF_TYPE_FLAG,
+     M_OPT_RANGE, 0, 1, NULL },
 
     // Audio
     { "volume", mp_property_volume, CONF_TYPE_FLOAT,
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng