资源简介
一个基于gtk实现的mp3播放器,十分小巧,代码简单,仅200行,供学习gtk的初级同学使用
代码片段和文件信息
/* file: gplayer.c
*/
#include “gplayer.h“
#include
static gboolean gplayer_init(GPlayer *player);
/*
*/
static gboolean cb_bus(GstBus *bus GstMessage *msg gpointer data)
{
GPlayer *player= (GPlayer*)data;
GError *err;
gchar *debug;
GstTagList *tags;
gchar *title;
gchar *artist;
gchar *album;
gint time;
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);
;
break;
case GST_MESSAGE_EOS:
;
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) )
{
g_print(“title: %s\nArtist: %s\nAlbum: %s\n“
title artist album);
}
gst_tag_list_free(tags);
if(-1!=gplayer_get_duration(player) )
{
time= gplayer_get_duration(player);
g_print(“Time: %d:%ds\n“ time/60 time%60 );
}
break;
default:
break;
}
return TRUE;
}
static gboolean cb_timeout(gpointer data)
{
GPlayer *player= (GPlayer*)data;
gint gone= gplayer_get_pos(player);
gdouble progress= gplayer_get_progress(player);
gdouble volume= 1.0;
gboolean mute= FALSE;
g_print(“Progress: %d:%ds\t%lf\n“ gone/60 gone%60 progress );
if(progress>0.25&& progress<0.35)
gplayer_set_progress(player 0.75);
gplayer_set_volume(player volume+10*progress );
volume= gplayer_get_volume(player);
gplayer_set_mute(player mute+( (progress>0.5)?1:0 ) );
mute= gplayer_get_mute(player);
g_print(“Volume: %lf\nMute: %d\n“ volume mute);
return TRUE;
}
/*
*/
GPlayer *gplayer_create()
{
GPlayer *player= NULL;
GstElement *play2;
GstBus *bus;
player= (GPlayer*)malloc(sizeof(GPlayer) );
if(NULL!= player)
{
play2= gst_element_factory_make(“playbin2“ “play2“);
bus= gst_pipeline_get_bus(GST_PIPELINE(play2) );
gst_bus_add_watch(bus cb_bus player);
gst_object_unref(GST_object(bus) );
gst_element_set_state(play2 GST_STATE_NULL);
player->play2= play2;
}
else
{
}
gplayer_init(player);
return player;
}
static gboolean gplayer_init(GPlayer *player)
{
/*g_object_set(G_object(player->play2) “volume“ player->volume NULL);
g_object_set(G_object(player->play2) “mute“ player->mute NULL);*/
g_timeout_add(1000 cb_timeout player);
g_object_set(G_object(player->play2) “uri“ “file:///mnt/hgfs/share/gplayer/mp3/1.mp3“ NULL);
gst_element_set_state(player->play2 GST_STATE_PLAYING);
return TRUE;
}
gboolean gplayer_play(GPlayer *player)
{
return TRUE;
}
gboolean gplayer_pause(GPlayer *player)
{
gboolean res= TRUE;
if(GST_STATE_CHANGE_FAILURE== gst_element_set_state(player->play2 GST_STATE_PAUSED) )
res= FALSE;
return res;
}
gboolean gplayer_next(GPlayer
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5522 2011-07-22 14:17 gpla
文件 5516 2011-06-30 20:30 gpla
文件 1223 2011-06-27 15:42 gpla
文件 359 2011-06-27 10:03 gpla
文件 4127762 2011-03-17 22:49 gpla
文件 3658440 2010-11-19 20:09 gpla
文件 2338434 2011-04-12 22:17 gpla
文件 241 2011-06-27 09:39 gpla
目录 0 2011-07-17 16:24 gpla
目录 0 2011-07-22 14:17 gpla
----------- --------- ---------- ----- ----
10137497 10
相关资源
- ffmpeg(amr转换mp3).exe.zip
- 网页音乐播放器答辩PPT
- win32迷你音乐播放器
- 51单片机音乐播放器的设计,在LCD12
- 弹幕播放器Demo.zip
- 国外开源Wince全能播放器TCPMP源码
- csf播放器这个终于可以用了
- GTK帮助文档
-
gtkmpla
yer - vc设计简单多媒体播放器
- 官方WRF播放器[atrecply.msi].zip
- MP3音乐txt文件转16进制代码工具
- 狐狸少爷汉化软件安装时的背景音乐
-
网页视频播放器ckpla
yer 及iis安装配 - 快闪PPT附背景音乐tiger rhythm.mp3
- ios本地音乐播放器
- CPU54条的音乐播放器应用
- 一些音乐播放器图标按钮的素材,总
- MMTools控件的demo,包含从TMemoryStream内
- 虚拟现实文件福音 BSContactVRML播放器
- mp3编解码源代码很好的算法源码很全
- ActiveX RTSP实时流媒体播放器 支持录像
-
flash+xm
l播放器实现连续播放 - rtmp流网页播放器
- RGB裸数据播放软件
-
SimplePla
yer(DShow).zip - GTK+3.0需要的dll全在里面啦Windows运行
- 基于mini2440的mp3播放器的设计
- 安卓音乐播放器APP57863
- Philips飞利浦MP3Spark2固件工具Firmware(
评论
共有 条评论