[MPlayer-dev-eng] [PATCH] selecting tv channel by name (tv://)

Ivan Szanto szivan at duticai.TWI.TUDelft.NL
Fri Apr 11 22:45:00 CEST 2003


Hi,


it's nice to see that tv:// is such a hot topic today ;-)

I like tv:// URL, cause I have a line similar to the
following in my ~/.mplayer/config

tv:channels=e9-1:NL1,e11-2:NL2,28-3:RTL4,63-4:RTL5,47-5:Net5+17,31-6

only with more channels ;-)

By using the channel number on the command line I can switch
to the channel I want to watch right away, e.g. tv://4
The only hassle is that I have to remember the numbers.
In order to overcome that, I made this small patch.
Now it's enough to remember the names of the channels (easier for me).
Even a substring is enough...

Enough said already. Have a nice week end!

Ivan
-------------- next part --------------
--- main/libmpdemux/tv.c	Wed Apr  9 16:07:45 2003
+++ main-smb-channels/libmpdemux/tv.c	Thu Apr 10 21:26:39 2003
@@ -335,9 +335,26 @@
 		channel = 1;
 
 	tv_channel_current = tv_channel_list;
+	if (isdigit(*tv_param_channel)) {
+
+	/* if tv_param_channel begins with a digit interpret it as a number */
+
 	for (i = 1; i < channel; i++)
 		if (tv_channel_current->next)
 			tv_channel_current = tv_channel_current->next;
+	} else {
+
+	/* if tv_param_channel does not begin with a digit 
+	   set the first channel that contains tv_param_channel in its name */
+
+	while ( tv_channel_current ) {
+		if ( strstr(tv_channel_current->name, tv_param_channel) )
+		  break;
+		tv_channel_current = tv_channel_current->next;
+		}
+	if ( !tv_channel_current ) tv_channel_current = tv_channel_list;
+	}
+
 	mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
 			tv_channel_current->name, (float)tv_channel_current->freq/1000);
 	tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));


More information about the MPlayer-dev-eng mailing list