当前位置: 首页 > news >正文

美食杰网站的建设目的建设工程律师

美食杰网站的建设目的,建设工程律师,网站备案许可证,最吃香的男生十大手艺用android或是QT来开发视频播放程序相对来说比较简单#xff0c;如果是在linux用纯C语言来进行开发#xff0c;就显得比较麻烦#xff0c;好在现在有很多开源项目能够帮助我们做什么事情#xff0c;mplayer就是音视频播放开源项目中典型的例子。 首先需要去mplayer官方网站… 用android或是QT来开发视频播放程序相对来说比较简单如果是在linux用纯C语言来进行开发就显得比较麻烦好在现在有很多开源项目能够帮助我们做什么事情mplayer就是音视频播放开源项目中典型的例子。 首先需要去mplayer官方网站mplayer下载地址下载源代码然后使用你的交叉编译工具进行编译编译完成后会生成一个mplayer执行程序在命令行执行mplayer就可以进行播放了。 但是用c语言编程来实现mplayer的播放功能怎么实现呢本文就来讲讲一个简单的mplayer播放器的实现。 一 、 创建一个管道进行进程间通信 int fd_fifo; int g_sock_pair[2]; //全双工管道标识符 int sock_stop_mplay[2]; char video_list[VIDEO_MAX_NUM][30]; void mplayer_init(void) { int sockID; sockIDsocketpair(AF_UNIX, SOCK_STREAM, 0, g_sock_pair);//建立全双工管道 if(sockID) { printf(the pipe is not contructed ); exit(0); } else { IfPlay FALSE;//设置标识符初始状态 IfStop TRUE; IfPause FALSE; IfQuit TRUE; video_over FALSE; } if(pipe(sock_stop_mplay)0) { printf(stop mplay pipe create error ); return ; } } 二 、 获得视频播放目录的文件个数 int mplayer_get_video_name(void) { int i; int num; int total_num; struct dirent **namelist; char *filepath usr/video/; memset(video_list,0,sizeof(video_list)); num scandir(filepath,namelist,0,alphasort); printf(the video num is: %d ,num); if(num 0)return -1; if(num VIDEO_MAX_NUM) { num VIDEO_MAX_NUM; } for(i0;id_name); } total_num num-2; return total_num; printf(video name:%s ,video_list[0]); } 三 、 mplayer播放器的实现 void video_play(void) { pid_t pid; pid_t pid1; FILE * fp; char buf[1024]; int mark 0; //播放标志 printf(the pid is %d ,getpid()); mplayer_init(); unlink(/usr/my_fifo); //如果管道存在则先删除 mkfifo(/usr/my_fifo,O_CREAT|0666); perror(mkfifo); fd_fifoopen(/usr/my_fifo,O_RDWR); int pipe_fd[2]; //用于进程ID通信 int r_num; char pipe_buf[100]; memset(pipe_buf,0,100); if(pipe(pipe_fd)0) { printf(pipe create error ); return ; } pid fork(); if(pid 0) { char temp[100]; memset(temp,0,sizeof(temp)); printf(pid xxx %d ,getpid()); sprintf(temp,%d,getpid()); close(pipe_fd[0]); if(write(pipe_fd[1],temp,strlen(temp))!-1) printf(child write success! ); if((pid1fork())0) { //close(g_sock_pair[0]); //dup2(g_sock_pair[1],1); //将子进程的标准输出重定向到管道的写端 int video_num 0; char *videoname; int total_num; char stop_cmd[20]; total_num mplayer_get_video_name(); while(1) { if(mark) { video_num; printf(video_num %d ,video_num); if(video_num total_num) { video_num 0; printf(video_num more than total_num ); } } videoname video_list[video_num]; char videopath[50] /storage/unit_app/video/; char sPlay[100]mplayer -ao alsa -vo fbdev -vc on28190 -fs -slave -quiet -input file/storage/my_fifo ; strcat(videopath,videoname); strcat(sPlay,videopath); mplayer_background_pic(); memset(stop_cmd,0,20); printf(begin play the video! ); fp popen(sPlay, r); if(fp NULL) { perror(popen); exit(-1); } else { while(fgets(buf, sizeof(buf), fp)) { printf(%s, buf); } printf(one video end play ); pclose(fp); mark 1; } usleep(30000); fcntl(sock_stop_mplay[0], F_SETFL, O_NONBLOCK); read(sock_stop_mplay[0],stop_cmd,20); if(strcmp(stop_cmd,stop)0) { mark 0; printf(rev the stop cmd ); break; } printf(end the play pthread ); } exit(0); } if (waitpid(pid1, NULL, 0) ! pid1) { fprintf(stderr,Waitpid error! ); exit(-1); } exit(0); } else if(pid 0) { close(pipe_fd[1]); usleep(30000); if((r_numread(pipe_fd[0],pipe_buf,100))0) { printf(%d numbers read from be pipe is %s ,r_num,pipe_buf); childs_pid atoi(pipe_buf); } } } 四、 mplayer的结束程序 void video_stop(void) { pid_t pid; char cmd[100]; memset(cmd,0,100); sprintf(cmd,kill -9 %d,childs_pid); char stop_cmd[20]; memset(stop_cmd,0,20); sprintf(stop_cmd,stop); mplayer_send_cmd(quit ); if(write(sock_stop_mplay[1],stop_cmd,strlen(stop_cmd))!-1) printf(write stop cmd success! ); //clear_fb(); printf(kill childs_pid %d ,childs_pid); system(cmd); mplayer_del(); } void mplayer_send_cmd(char *cmd) { write(fd_fifo,cmd,strlen(cmd)); } void mplayer_del(void) { close(g_sock_pair[0]);//关闭管道 close(g_sock_pair[1]); close(sock_stop_mplay[0]); close(sock_stop_mplay[2]); wait(NULL);//收集子进程信息 } OK只要实现上述代码基本的mplayer播放器就可以实现了。
http://www.w-s-a.com/news/114049/

相关文章:

  • 网站后台策划书破解版手游app平台
  • 宿迁网站建设介绍公司wordpress 文章 分类 页面
  • 建设通同类网站网站设计公司种类
  • 台州专业做网站网站可以个人做吗
  • 个人logo在线生成免费乐陵德州seo公司
  • 网站回答问题app怎么做专业定制网红柴火灶
  • 网站做的最好的公司行业网址大全
  • 内网怎么做网站服务器seo统计
  • 丽水市企业网站建设 微信营销 影视拍摄计算机专业吃香吗
  • 龙岗做网站公司哪家好找到做网站的公司
  • 网站图片alt属性wordpress 自定义栏目 调用
  • 怎样建网站最快广州网站建设工程
  • iis7 网站404错误信息12306网站很难做吗
  • 网站建设600元包公司设计图片大全
  • 网站建设费用怎么做分录做校园网站代码
  • 网站改版做重定向福州网站建设思企
  • 网站建设全流程企业形象网站开发业务范畴
  • wordpress无法查看站点西安优秀高端网站建设服务商
  • 固始网站制作熟悉免费的网络营销方式
  • 做网站到a5卖站赚钱搜索引擎优化代理
  • 沈阳网站建设包括win10优化
  • 做百度手机网站点击软网站seo优化徐州百度网络
  • 徐州专业网站制作标志设计作业
  • 自己可以做网站空间吗海天建设集团有限公司网站
  • 教学督导网站建设报告aspcms网站图片不显示
  • 网站开发公司成本是什么门户网站宣传方案
  • 上海 企业网站建设网站怎么开通微信支付
  • 饮料网站建设wordpress主题猫
  • 网站建设需要编码不有没有专门的网站做品牌授权的
  • 做爰在线网站免费空间列表