[Mplayerplug-in-devel] small patch
Brought to you by:
kdekorte
From: Cian C. <cia...@gm...> - 2005-10-19 12:45:46
|
Hi Kevin, I've created a small patch that allows a user to turn on/off the various loading messages that mplayerplug-in shows while loading a movie with the "loading-messages" option in their mplayerplug-in.conf file. While these messages are useful normally, I would like to have them turned off for some embedded applications. To get a completely blank screen while loading one also needs to use logo=3Dfalse in the embed tag. Anyway, I've tested the patch myself and it works for me, and I've tried to keep it as neat as possible, but almost certainly you'll want to modify it if you decide to include it in your code. I hope you do :) I'm going to paste it inline in case the mailing list software strips attachments. Cian diff -Naurb mplayerplug-in/Source/plugin.cpp mplayerplug-in-cians/Source/plugin.cpp --- mplayerplug-in/Source/plugin.cpp=092005-10-18 01:25:37.000000000 +0100 +++ mplayerplug-in-cians/Source/plugin.cpp=092005-10-19 13:30:00.000000000 = +0100 @@ -218,6 +218,7 @@ starttime =3D 0; nopauseonhide =3D 0; targetplayer =3D 0; + loading_messages =3D 0; #ifdef GTK_ENABLED image =3D NULL; @@ -859,6 +860,7 @@ =09status =3D GTK_LABEL(gtk_label_new(_("Initializing"))); =09progress_bar =3D GTK_PROGRESS_BAR(gtk_progress_bar_new()); +=09if(loading_messages){ =09if (window_height > 125) { #ifdef GTK2_ENABLED @@ -926,6 +928,7 @@ =09=09=09=09 aWindow->height - 25); #endif =09} +=09} =09gtk_misc_set_alignment(GTK_MISC(status), 0, 0); =09gtk_label_set_line_wrap(status, TRUE); @@ -1249,6 +1252,7 @@ =09=09=09 n->fname); =09=09buildPlaylist(this, n->fname, n); =09=09if (mode =3D=3D NP_FULL || noembed =3D=3D 1) { +=09=09 if(loading_messages){ #ifdef X_ENABLED =09=09 DrawUI(widget, this, "Download Complete", 0, 99); #endif @@ -1267,6 +1271,7 @@ =09=09 } #endif =09=09} +=09=09} =09=09if (DEBUG > 1) =09=09 printf("buildPlaylist is complete\n"); =09=09if (strncasecmp(mimetype, "application/sdp", 15) =3D=3D 0) { @@ -1707,6 +1712,7 @@ =09=09} =09=09if (mode =3D=3D NP_EMBED && noembed =3D=3D 0 && fullscreen =3D=3D 0= ) { =09=09 if (state < STATE_PLAYING) { +=09=09 if(loading_messages){ #ifdef X_ENABLED =09=09=09DrawUI(widget, this, message, =09=09=09 0, @@ -1734,8 +1740,10 @@ =09=09=09} #endif =09=09 } +=09=09 } =09=09} else { =09=09 if (fullscreen =3D=3D 0) { +=09=09 if(loading_messages){ #ifdef X_ENABLED =09=09=09DrawUI(widget, this, message, =09=09=09 0, @@ -1767,6 +1775,7 @@ =09=09 } =09=09} =09 } +=09 } =09 if (n->status !=3D STATE_DOWNLOADED_ENOUGH) { =09=09burl =3D getURLBase(n->url); diff -Naurb mplayerplug-in/Source/plugin.h mplayerplug-in-cians/Source/plug= in.h --- mplayerplug-in/Source/plugin.h=092005-10-17 22:38:53.000000000 +0100 +++ mplayerplug-in-cians/Source/plugin.h=092005-10-19 12:00:20.000000000 +0= 100 @@ -197,6 +197,7 @@ long int starttime; int nopauseonhide; int targetplayer;=09=09// if we have this create a new window and play= there + int loading_messages; #ifdef GTK_ENABLED GtkWidget *gtkwidget; diff -Naurb mplayerplug-in/Source/plugin-setup.cpp mplayerplug-in-cians/Source/plugin-setup.cpp --- mplayerplug-in/Source/plugin-setup.cpp=092005-10-18 01:25:37.000000000 = +0100 +++ mplayerplug-in-cians/Source/plugin-setup.cpp=092005-10-19 11:57:26.000000000 +0100 @@ -1347,7 +1347,14 @@ =09=09 continue; =09=09} - +=09=09if (strncasecmp(buffer, "loading-messages", 16) =3D=3D 0) { +=09=09 snprintf(parse, 1000, "%s", strtok(buffer, "=3D")); +=09=09 snprintf(parse, 1000, "%s", strtok(NULL, "=3D")); +=09=09 sscanf(parse, "%i", &instance->loading_messages); +=09=09 if (instance->loading_messages !=3D 0) +=09=09=09instance->loading_messages =3D 1; +=09=09 continue; +=09=09} =09 } =09 fclose(config); diff -Naurb mplayerplug-in/Source/plugin-threads.cpp mplayerplug-in-cians/Source/plugin-threads.cpp --- mplayerplug-in/Source/plugin-threads.cpp=092005-10-17 22:38:53.00000000= 0 +0100 +++ mplayerplug-in-cians/Source/plugin-threads.cpp=092005-10-19 13:12:14.000000000 +0100 @@ -243,7 +243,7 @@ if (DEBUG > 1) =09printf("Entering SetupPlayer\n"); - + if (instance->loading_messages){ #ifdef X_ENABLED DrawUI(instance->widget, instance, "Loading Media...", 0, -1); #endif @@ -251,7 +251,7 @@ if (instance->status !=3D NULL) =09gtk_label_set_text(instance->status, "Loading Media..."); #endif - + } if (instance->td->list =3D=3D NULL) { =09instance->td->list =3D instance->list; } @@ -578,6 +578,7 @@ if (DEBUG) =09printf("creating thread - NP_EMBED\n"); + if (instance->loading_messages){ #ifdef X_ENABLED DrawUI(instance->widget, instance, "Getting playlist...", 0, -1); #endif @@ -585,6 +586,7 @@ if (instance->status !=3D NULL) =09gtk_label_set_text(instance->status, "Getting playlist..."); #endif + } if (instance->state < STATE_GETTING_PLAYLIST) =09instance->state =3D STATE_GETTING_PLAYLIST; @@ -833,7 +835,7 @@ =09=09strlcpy(message, "Buffering ", 1024); =09=09strlcat(message, local_url, 1000); - +=09=09if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09=09DrawUI(local_td->instance->widget, =09=09 local_td->instance, eos, -1, (int) cfpercent); @@ -847,11 +849,13 @@ #endif =09 } =09} +=09} =09pthread_testcancel(); =09if (strstr(buffer, "Starting") !=3D NULL) { =09 strlcpy(message, "Playing ", 1024); =09 strlcat(message, local_url, 1000); +=09 if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09 DrawUI(local_td->instance->widget, =09=09 local_td->instance, message, 0, -1); @@ -861,6 +865,7 @@ =09 g_idle_add(gtkgui_message, local_td->instance); #endif =09} +=09} =09pthread_testcancel(); =09if (strstr(buffer, "VO:") !=3D NULL) { @@ -1018,6 +1023,7 @@ =09pthread_testcancel(); =09if (strstr(buffer, "Connect") !=3D NULL) { =09 snprintf(message, 1024, "%s", buffer); +=09 if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09 DrawUI(local_td->instance->widget, =09=09 local_td->instance, message, 0, -1); @@ -1027,10 +1033,13 @@ =09 g_idle_add(gtkgui_message, local_td->instance); #endif =09} +=09} +=09 =09pthread_testcancel(); =09if (strstr(buffer, "Initiated") !=3D NULL) { =09 snprintf(message, 1024, "%s", buffer); +=09 if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09 DrawUI(local_td->instance->widget, =09=09 local_td->instance, message, 0, -1); @@ -1040,10 +1049,12 @@ =09 g_idle_add(gtkgui_message, local_td->instance); #endif =09} +=09} =09pthread_testcancel(); =09if (strstr(buffer, "No stream found") !=3D NULL) { =09 snprintf(message, 1024, "%s", buffer); +=09 if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09 DrawUI(local_td->instance->widget, =09=09 local_td->instance, message, 0, -1); @@ -1053,8 +1064,7 @@ =09 g_idle_add(gtkgui_message, local_td->instance); #endif =09} - - +=09} =09pthread_testcancel(); =09if (strstr(buffer, "Example: mplayer -playlist ") !=3D NULL) { =09 if (*maybeplaylist =3D=3D 0) { @@ -1358,6 +1368,7 @@ =09printf("----player thread: playPlayList - waiting complete\n"); pthread_testcancel(); + if (local_td->instance->loading_messages){ #ifdef X_ENABLED DrawUI(local_td->w, local_td->instance, "Loading Media...", 0, -1); #endif @@ -1365,7 +1376,7 @@ snprintf(local_td->instance->lastmessage, 1024, "Loading Media..."); g_idle_add(gtkgui_message, local_td->instance); #endif - + } memset(cmd, '\0', 1); i =3D 0; if (DEBUG) @@ -1533,6 +1544,7 @@ =09=09printf("----player thread: playing url: %s\n", local_url); =09 strlcpy(message, "Playing ", 1024); =09 strlcat(message, local_list->url, 1000); +=09 if (local_td->instance->loading_messages){ #ifdef X_ENABLED =09 DrawUI(local_td->w, local_td->instance, message, 0, -1); #endif @@ -1540,6 +1552,7 @@ =09 snprintf(local_td->instance->lastmessage, 1024, "%s", message); =09 g_idle_add(gtkgui_message, local_td->instance); #endif +=09 } =09 pthread_cleanup_push((void (*)(void *)) =09=09=09=09 pthread_mutex_unlock, =09=09=09=09 (void *) &(local_td->instance-> @@ -1564,8 +1577,8 @@ =09 if (nomouseinput) { =09=09local_td->argv[argc++] =3D strdup("-nomouseinput"); -// } else { -// nomouseinput =3D 0; +=09 // } else { +=09 // nomouseinput =3D 0; =09 } =09 if (local_td->instance->starttime > 0) { |