資源簡介
實現了播放列表的mp3播放器,基于gtk實現,代碼300行左右,核心代碼幾十行,對初學gtk的同學十分有益。linux開發資料少,望大家積極下載,謝謝。

代碼片段和文件信息
#include?“core.h“
#include?“list.h“
#include?
static?PLAYSET?*dumb;
static?gboolean?cb_play_bus(GstBus?*bus?GstMessage?*msg?gpointer?data)
{
PLAYSET?*player=?(PLAYSET*)data;
GError?*err;
gchar?*debug;
/*
GstTagList?*tags;
gchar?*title;
gchar?*artist;
gchar?*album;
*/
switch(GST_MESSAGE_TYPE(msg)?)
{
case?GST_MESSAGE_ERROR:
gst_message_parse_error(msg?&err?&debug);
g_print(“Error:?%s\n“?err->message);
g_error_free(err);
g_free(debug);
gst_element_set_state(player->play2?GST_STATE_NULL);
break;
case?GST_MESSAGE_EOS:
coreNext(player);
break;
case?GST_MESSAGE_TAG:
/* gst_message_parse_tag(msg?&tags);
if(gst_tag_list_get_string(tags?GST_TAG_title?&title)&&?
???gst_tag_list_get_string(tags?GST_TAG_ARTIST?&artist)&&?
???gst_tag_list_get_string(tags?GST_TAG_ALBUM?&album)?)
{
}
gst_tag_list_free(tags);
*/
break;
default:
break;
}
return?TRUE;
}
static?gboolean?cb_dumb_bus(GstBus?*bus?GstMessage?*msg?gpointer?data)
{
PLAYSET?*player=?(PLAYSET*)data;
GError?*err;
gchar?*debug;
GstTagList?*tags;
gchar?*title;
gchar?*artist;
gchar?*album;
GstFormat?format=?GST_FORMAT_TIME;
gint64?val=?-1;
GList?*p=?NULL;
switch(GST_MESSAGE_TYPE(msg)?)
{
case?GST_MESSAGE_ERROR:
gst_message_parse_error(msg?&err?&debug);
g_print(“Error:?%s\n“?err->message);
g_error_free(err);
g_free(debug);
gst_element_set_state(player->play2?GST_STATE_NULL);
break;
case?GST_MESSAGE_EOS:
gst_element_set_state(player->play2?GST_STATE_NULL);
break;
case?GST_MESSAGE_TAG:
gst_message_parse_tag(msg?&tags);
if(gst_tag_list_get_string(tags?GST_TAG_title?&title)&&?
???gst_tag_list_get_string(tags?GST_TAG_ARTIST?&artist)&&?
???gst_tag_list_get_string(tags?GST_TAG_ALBUM?&album)?)
{
p=?g_list_nth(player->playlist?player->num);
g_stpcpy(((PlayList*)p->data)->title?title);
g_stpcpy(((PlayList*)p->data)->artist?artist);
g_stpcpy(((PlayList*)p->data)->album?album);
}
gst_tag_list_free(tags);
if(gst_element_query_duration(player->play2?&format?&val)?)
{
p=?g_list_nth(player->playlist?player->num);
/*((PlayList*)p->data)->duration=?val/1000000000;*/
val=?val/1000000000;
g_sprintf(((PlayList*)p->data)->duration?“%02d:%02ds“?(gint)val/60?(gint)val%60);
gst_element_set_state(player->play2?GST_STATE_NULL);
if(!(2==player->mode||0==player->mode&&(g_list_length(player->playlist)-1==player->num)?)?)
{
coreNext(player);
}
else
{
gst_element_set_state(player->play2?GST_STATE_NULL);
list_print(player->playlist);
return?FALSE;
}
}
break;
default:
break;
}
return?TRUE;
}
PLAYSET?*coreCreate()
{
PLAYSET?*player=?NULL;
GstElement?*play1;
GstElement?*play2;
GstBus?*bus;
player=?(PLAYSET*)malloc(sizeof(PLAYSET)?);
dumb=?(PLAYSET*)malloc(sizeof(PLAYSET)?);
if(NULL!=?player&
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9184??2011-06-30?20:29??PLAY\core.c
?????文件???????1013??2011-06-29?15:21??PLAY\core.h
?????文件???????1146??2011-06-29?16:04??PLAY\list.c
?????文件????????328??2011-07-22?19:44??PLAY\list.h
?????文件????????419??2011-06-30?09:26??PLAY\main.c
?????文件????????451??2011-06-28?16:06??PLAY\makefile
?????目錄??????????0??2011-07-25?17:49??PLAY\mp3
?????目錄??????????0??2011-07-22?19:43??PLAY
-----------?---------??----------?-----??----
????????????????12541????????????????????8
- 上一篇:知名的斯坦福兔子的三維點云數據,pcd格式
- 下一篇:樹莓派3B原理圖
評論
共有 條評論