“1.1 sMonitor ubuntu开发平台”的版本间的差异

来自小蚁工场,专注嵌入式、物联网与人工智能技术。
跳转至: 导航搜索
常用shell命令
动手实践
 
(未显示同一用户的47个中间版本)
第7行: 第7行:
 
-------
 
-------
  
===vmware虚拟机软件安装===
+
===vmware软件安装===
  
 
  软 件 包:VMware-workstation-full-12.0.0.zip
 
  软 件 包:VMware-workstation-full-12.0.0.zip
第66行: 第66行:
  
 
<br>
 
<br>
===ubuntu16快速安装===
+
 
 +
【VirtualBox加载Ubuntu||VirtualBox加载Ubuntu】
 +
 
 +
===ubuntu安装配置===
 
<pre>
 
<pre>
软 件 包:64bitPlatform_1604_v5.0.zip
+
软 件 包:64bitPlatform_1604_v5.0.zip(也可能是其他版本)
 
操作系统:windows-7/8/10
 
操作系统:windows-7/8/10
 
安装过程: 如下所示
 
安装过程: 如下所示
第74行: 第77行:
  
 
====安装ubuntu系统====
 
====安装ubuntu系统====
*在d盘创建一个my virMachine目录
+
*在d盘创建一个myMachine目录
*将64bitPlatform_1604_v5.0.zip拷贝到my virMachine目录
+
*将64bitPlatform_1604_v5.0.zip拷贝到myMachine目录
  
 
*解压64bitPlatform_1604_v5.0.zip到当前目录下
 
*解压64bitPlatform_1604_v5.0.zip到当前目录下
第134行: 第137行:
 
====设置共享目录====
 
====设置共享目录====
  
*在windows桌面新建名为mklinux的目录文件,并且在里面创建hello.c
+
共享目录主要是用于实现windows与ubuntu两个系统之间的数据交互,比如windows有一个文件要给ubuntu系统用时,就可以将文件放置到共享目录下传给ubuntu。
 +
'''新的共享目录可以如下配置:'''
 +
 
 +
*在windows桌面新建名为shareWin的目录文件,并且在里面创建一个名为hello的文件
 +
 
 +
  [[File:gbaSet_01.png|600px]]
  
*回到ubuntu系统的shell操作界面
+
*回到ubuntu系统的shell操作界面,进行如下操作
  
  root@ubuntu:~# ls /mnt/hgfs  
+
  # ls /mnt/hgfs
如果出现:ls: cannot access '/mnt/hgfs': Protocol error ,说明还没有配置共享目录
+
可以看到没有名为shareWin的目录文件,接下来做如下操作:
  
*配置过程如下所示
+
[[File:gbaSet_02.png|600px]]
  
  [[File:vmware_install_21.png|600px]]
+
  [[File:gbaSet_03.png|600px]]
 +
 
 +
[[File:gbaSet_04.png|600px]]
  
 
*再次执行
 
*再次执行
  root@ubuntu:~# ls /mnt/hgfs/mklinux/
+
  # ls /mnt/hgfs
 +
# cd /mnt/hgfs/shareWin/
 +
# ls
 +
 
 +
发现在/mnt/hgfs目录下,多了一个名为shareWin的目录文件,再进到里面可能看到之前创建的hello文件。
 +
 
 +
至此,两个系统间的共享文件夹设置并启完毕,后面如果两个系统需要共享资料时,可以将其放到共享目录即可。
 +
 
 +
<br>
 +
 
 +
====网络配置连接====
 +
 
 +
*电脑windows连接上网络(可以是有线网络,也可以是无线网络,推荐无线)
 +
 
 +
*检查设置ubuntu为桥接网络连接方式
 +
 
 +
[[File:vmware_netset_01.png|600px|link= ]]
 +
 
 +
注意:必须设置为桥接方式。
 +
 
 +
 
 +
*重启ubuntu网络
 +
 
 +
[[File:vmware_netset_02.png|600px|link= ]]
 +
 
 +
*测试网络是否可联网
 +
 
 +
[[File:vmware_netset_03.png|600px|link= ]]
  
发现在/mnt/hgfs目录下,多了一个名为mklinux的目录,说明可以设置两个系统间的共享文件夹了。
+
如果可以ping通百度,则网络配置成功。
  
 
<br>
 
<br>
第179行: 第216行:
  
 
====常用shell命令====
 
====常用shell命令====
<!--
+
 
 
此处略
 
此处略
-->
 
  
 +
<!--
 
*cd(改变工作路径)
 
*cd(改变工作路径)
 
:cd xxx (xxx:是工作目录的路径)
 
:cd xxx (xxx:是工作目录的路径)
第365行: 第402行:
 
     
 
     
 
tar -zcf vmware-tools-distrib.tar.gz vmware-tools-distrib
 
tar -zcf vmware-tools-distrib.tar.gz vmware-tools-distrib
 +
-->
  
 
====实践操作====
 
====实践操作====
第370行: 第408行:
  
 
<pre>
 
<pre>
#mkdir /opt/shell_test  
+
# mkdir /opt/shell_test         //在opt目录下新建一个名为shell_test文件
#cd /opt/shell_test  
+
# ls /opt/shell_test             //查看/opt/shell_test目录
#ls /opt/shell_test  
+
# cd /opt/shell_test             //进入/opt/shell_test目录
#mkdir hello
+
# mkdir hello //新建一个名为hello目录
#ls
+
# ls                             //查看当前目录内容
#rmdir hello  
+
# rmdir hello                   //删除hello目录
#ls  
+
# ls  
#touch hello.c  
+
# touch hello.c                 //创建一个hello.c文件
#ls  
+
# ls  
#rm hello.c  
+
# rm hello.c                     //删除hello.c文件
#mkdir hello  
+
# ls
#touch hello/hello.c //新建一个文件
+
# mkdir hello  
#touch world.c  
+
# touch hello/hello.c         //在hello目录下新建一个hello.c文件
#ls  
+
# touch world.c                 //新建world.c文件
#rm -rf ./*
+
# ls  
#ls  
+
# rm -rf ./*                     //删除当前目录下所有文件
 +
# ls  
 
</pre>
 
</pre>
  
第392行: 第431行:
 
<pre>
 
<pre>
  
#cd /opt/shell_test
+
# cd /opt/shell_test                   //进入/opt/shell_test目录下
#ls
+
# touch hello.c                        //新建hello.c
#chmod 777 hello.c  
+
# ls
#ls  
+
# chmod 777 hello.c                     //修改hello.c文件为可读写
 +
# ls  
 
   
 
   
#cp hello.c hello_backup.c  -rdf
+
# cp hello.c hello_backup.c  -rdf       //将hello.c拷贝保存为一个新文件hello_backup.c
#ls
+
# ls  
 
 
#mv hello_backup.c 123.c  
 
#ls  
 
#mkdir test
 
#mv 123.c test
 
#mv test smartHome
 
  
#tar cvfj smartHome.tar.bz2 smartHome
+
# mv hello_backup.c 123.c              //将hello_backup.c改名为123.c
#ls
+
# ls                                   
#rm -rf smartHome
+
# mkdir test
#ls  
+
# mv 123.c test                        //将123.c文件移到test目录下
#tar xvfj smartHome.tar.bz2  
+
# mv test smartHome                    //将test目录改名为smartHome
#ls  
+
# ls
 +
# tar cvfj smartHome.tar.bz2 smartHome //将smartHome目录压缩为smartHome.tar.bz2文件
 +
# ls
 +
# rm -rf smartHome
 +
# ls  
 +
# tar xvfj smartHome.tar.bz2           //将smartHome.tar.bz2文件解压为smartHome目录
 +
# ls  
  
 
</pre>
 
</pre>
第419行: 第459行:
 
<pre>
 
<pre>
  
#cd /opt/shell_test
+
# cd /opt/shell_test
#rm -rf ./*
+
# rm -rf ./*
  
#touch hello.c  
+
# touch hello.c  
#vi hello.c  
+
# vi hello.c  
 
可以进入文件中,按下i,就可以编辑内容
 
可以进入文件中,按下i,就可以编辑内容
  
 
#include <stdio.h>
 
#include <stdio.h>
 +
#include <unistd.h>
 
int main()
 
int main()
 
{
 
{
         printf("hello world.\n");
+
         while(1)
 +
        {
 +
                printf("hello world.\n");
 +
                sleep(1);
 +
        }
 +
             
 
         return 0;
 
         return 0;
 
}
 
}
第436行: 第482行:
 
:wq!  (保存退出)
 
:wq!  (保存退出)
  
#gcc hello.c -o hello  
+
# gcc hello.c -o hello       // 将hello.c编译为hello
#./hello  
+
# ./hello                     // 执行可执行文件hello
 +
</pre>
 +
 
 +
<br>
 +
 
 +
 
 +
===应用开发===
 +
====测试代码开发====
 +
*工程包准备
 +
 
 +
进入ubuntu,打开终端,执行
 +
 
 +
cd  /nfs
 +
 
 +
从网页中下载demo包[[Media:playDemo.tar.bz2 |playDemo.tar.bz2[下载]]],并放置共享文件目录,返回ubuntu终端,执行:
 +
 
 +
cp /mnt/hgfs/shareWin/playDemo.tar.bz2  ./
 +
tar xvfj playDemo.tar.bz2
 +
cd  playDemo
 +
 
 +
*代码开发
 +
 
 +
打开源文件playCtl.c
 +
vi  playCtl.c
 +
 
 +
在main函数中,添加
 +
<!--
 +
<syntaxhighlight lang="ruby">
 +
char *argv[]={"maplayer","-slave","-quiet","-input","file=/opt/fifo","-playList", "MediaList",NULL};
 +
 
 +
pid = fork();
 +
if(pid < 0){ perror("fork failed\n");return -1;}
 +
else if(pid == 0){
 +
execvp("mplayer",argv);
 +
printf("exec failed\n");
 +
return -1;
 +
}else{
 +
fd = open("/opt/fifo",O_WRONLY);
 +
if(fd < 0){perror("open fifo fail\n");return -1;}
 +
sleep(1);
 +
do{
 +
choice = ui_choice();
 +
switch(choice){
 +
case 1:write(fd,"pause\n",6);break;
 +
case 2:write(fd,"seek 0 1\n",9);break;
 +
case 3:write(fd,"pt_step 1\n",10);sleep(1);break;
 +
case 6:write(fd,"quit\n",5);break;
 +
default:break;
 +
}
 +
}while(choice != 6);
 +
 
 +
system("clear");
 +
wait(NULL);
 +
}
 +
close(fd);
 +
</syntaxhighlight>
 +
-->
 +
[[File:playCtrl_001.png|800px|link= ]]
 +
 +
 
 +
注意:上面代码中
 +
“char *argv[]={"maplayer","-slave","-quiet","-input","file=/opt/fifo","-playList", "MediaList",NULL};”
 +
请将'''maplayer'''改成'''mplayer'''
 +
 
 +
在ui_choice函数中,添加:
 +
<!--
 +
<syntaxhighlight lang="ruby">
 +
 
 +
system("clear");
 +
printf("\t 1. pause player.\n");
 +
printf("\t 2. restart player.\n");
 +
printf("\t 3. next player.\n");
 +
printf("\t 6. exit player.\n");
 +
printf("\t your choice:  ");
 +
scanf("%d", &choice);
 +
 
 +
</syntaxhighlight>
 +
-->
 +
 
 +
[[File:playCtrl_002.png|800px|link= ]]
 +
 
 +
====编译执行演示====
 +
 
 +
*程序编译
 +
gcc playCtl.c -o playCtl
 +
 
 +
可以看到在当前目录下生成了一个名为playCtl的可执行文件
 +
 
 +
*程序执行
 +
mkfifo  /opt/fifo 
 +
./playCtl
 +
 
 +
可以看到开始播放视频,而在终端可以看到控制列表,输入对应的数字可以执行相应的功能
 +
 
 +
注意:上面程序执行的前提是ubuntu系统中已安装有mplayer播放器,否则会异常退出。
 +
<br>
 +
 
 +
<!--
 +
====拓展功能开发====
 +
* 添加播放上一首功能
 +
*添加音量调节功能
 +
-->
 +
<!--
 +
参考代码:
 +
 
 +
1.添加播放上一首功能
 +
*在ui_choice函数中,添加
 +
printf("\t 4. prev player.\n");
 +
 
 +
*在main函数中,添加
 +
case 4:write(fd,"pt_step -1\n",11);sleep(1);break;
 +
 
 +
2.添加音量调节功能
 +
<pre>
 +
int ui_choice(void)
 +
{
 +
        int choice;
 +
        system("clear");
 +
        printf("\t 1. pause player.\n");
 +
        printf("\t 2. restart player.\n");
 +
        printf("\t 3. next player.\n");
 +
        printf("\t 4. prev player.\n");
 +
        printf("\t 5. set volume.\n"); //新加
 +
        printf("\t 6. exit player.\n");
 +
        printf("\t your choice:  ");
 +
        scanf("%d", &choice);
 +
 
 +
        return choice;
 +
}
 +
</pre>
  
 +
*在main函数相应位置中,添加:
 +
<pre>
 +
case 4:write(fd,"pt_step -1\n",11);sleep(1);break;
 +
case 5:
 +
do{
 +
printf("enter volume value(0-100):");
 +
scanf("%d",&num);
 +
}while(num > 100 || num < 0);
 +
memset(volume,0,sizeof(volume));
 +
sprintf(volume,"volume %d 1\n",num);
 +
write(fd,volume,strlen(volume));
 +
break;
 +
case 6:write(fd,"quit\n",5);break;
 
</pre>
 
</pre>
 +
-->
  
 +
<!--
 
===动手实践===
 
===动手实践===
  
*实践1:配置网络并测试ping通百度, 并且通过网络安装QQ软件
+
*练习1:在ubuntu下面安装一种软入法(如:五笔输入法)软件并简单使用
*实践2:在ubuntu下,实现不少于两种方法安装mplayer播放器软件
+
 
<!--
+
*练习2:在ubuntu下,实现不少于两种方法安装mplayer播放器软件
 
'''方法一:利用apt-get机制安装删除mplayer播放器'''
 
'''方法一:利用apt-get机制安装删除mplayer播放器'''
 
<pre>
 
<pre>
第480行: 第670行:
 
经过一小段时间编译后,在当前目录下会发现有一个名为mpayer的可执行代码
 
经过一小段时间编译后,在当前目录下会发现有一个名为mpayer的可执行代码
 
</pre>
 
</pre>
 +
*练习3:通过配置,实现将电脑windows的D或E盘整个挂载到ubuntu的/media/hDisk目录,并且可以查看其内容。
 +
 +
*练习4:在ubuntu下通过u盘挂载实现一个短视频的播放。
 +
*练习5:配置网络并测试ping通百度, 并且通过网络安装QQ软件
 +
*练习13:在ubuntu系统上安装布署一个web服务器,并且在指定目录下编写一个简单的html文件,实现用户在浏览器中输入ip地址后可以如下打开显示一份个人简历,要求编程实现页面显示。
 +
[[File:priDemo.jpg|500px|link= ]]
 
-->
 
-->
 +
<!--
 +
<div style="font-size: 120%;">'''资源下载'''</div>
 +
{| class="wikitable" style="width: 90%;text-align: center"
 +
| style="width="30%" | '''资源编号''' ||  style=width="20%" | '''资源名称'''  ||  style=width="10%" | '''资源介绍'''  || '''下载链接'''
 +
|-
 +
|1 || align=left | [[Media:ubuntu完整安装.pdf|ubuntu完整安装]] ||  align=left | ubuntu1604完整安装过程记录  密码:leqw || [[https://pan.baidu.com/s/1qZqCRC2ahBd3oT5xJbW2bQ 下载]]
 +
|}
 +
 +
<br>
  
*实践3:在ubuntu下通过u盘挂载实现一个短视频的播放。
+
-->
*实践4:在ubuntu下面安装五笔输入法软件并简单使用
 
*实践5:在ubuntu下搭建安装一个web服务器、制作一张个人简历页面并通过浏览器访问
 
<!--
 
  
-----------
 
1.打开终端,输入$sudo su切换到root权限,如果登录时是以root登录,则无需执行此步<br>
 
2.下载Apache2,在终端内输入apt-get install apache2;<br>
 
3.下载完成后打开浏览器访问127.0.0.1,可以看到安装Apache后的默认界面,出现该页面则证明Apache安装成功。<br>
 
[[File:web-server.png|600px]]
 
4.在var\www\html文件夹下添加一张图片并将原本该文件夹下的index.html的代码修改成如下:<br>
 
<pre>
 
<style>
 
div{
 
width:1000px;
 
height: 600px;
 
background-image: url("./1.jpg") //括号中为要修改图片的路径
 
}
 
</style>
 
</head>
 
<body>
 
<div></div>
 
  
</pre>
 
5.重新打开浏览器访问127.0.0.1,发现网页图片修改成功<br>
 
[[File:web-server2.png|600px]]
 
  
<br>
+
附录:
-->
+
-----
 +
{| class="wikitable" style="width: 100%;text-align: center"
 +
| style="width="30%" | '''资源编号''' ||  style=width="20%" | '''资源名称'''  || '''下载链接'''
 +
|-
 +
|1 || MPlayer-1.3.0.tar.xz || [[Media:MPlayer-1.3.0.tar.xz|mplayer源码包下载]]
 +
|-
 +
|2 || debug.mp4 || [[Media:debug.mp4|mp4测试文件]]
 +
|-
 +
|3 || VirtualBox加载Ubuntu || <!--[[VirtualBox加载Ubuntu|【'''打开查看'''】-->【'''打开查看'''】
 +
|}
  
 +
<!--
 
===FAQ===
 
===FAQ===
  
第525行: 第717行:
 
|20||[[ubuntu_FAQ_20|其他杂七杂八问题]]|| ||
 
|20||[[ubuntu_FAQ_20|其他杂七杂八问题]]|| ||
 
|}
 
|}
 +
-->
  
 
+
<span style="border:1px solid #000; text-align:center; float:right;padding:6px;"><strong>'''返回''':</strong> [[SMonitor 开发基础|上一页]]</span>
 
 
<span style="border:1px solid #000; text-align:center; float:right;padding:6px;"><strong>返回:</strong> [[SMonitor 开发基础|上一页]]</span>
 
  
 
||
 
||
 
|}
 
|}

2024年7月30日 (二) 00:30的最新版本

正文


vmware软件安装

软 件 包:VMware-workstation-full-12.0.0.zip
操作系统:windows-7/8/10
安装过程: 如下所示

准备工作

1 d盘创建一个temp目录
2 VMware-workstation-full-12.0.0.zip拷贝到temp目录
3 解压VMware-workstation-full-12.0.0.zip

开始安装

  • 双击“VMware-workstation-full-12.0.0-2985596”,进入安装界面
Vmware install 01.png

Vmware install 02.png
  • 连续点击“下一步”
Vmware install 03.png
 
Vmware install 04.png

Vmware install 05.png 


  • 正式开始安装
Vmware install 06.png


Vmware install 07.png 


  • 软件安装过程结束
Vmware install 08.png


安装密钥

  • 打开软件包目录下“readme”,将里面的认证码拷贝出来。
  • 再点击“许可证”,并输入密钥
Vmware install 09.png
  • 点击“输入”,整个安装彻底安装完成
Vmware install 10.png
  • 此时,发现在电脑的桌面上出现了“VMware Workstation Pro”图标,可以双击打开使用
Vmware install 11.png


【VirtualBox加载Ubuntu||VirtualBox加载Ubuntu】

ubuntu安装配置

软 件 包:64bitPlatform_1604_v5.0.zip(也可能是其他版本)
操作系统:windows-7/8/10
安装过程: 如下所示

安装ubuntu系统

  • 在d盘创建一个myMachine目录
  • 将64bitPlatform_1604_v5.0.zip拷贝到myMachine目录
  • 解压64bitPlatform_1604_v5.0.zip到当前目录下

可以看到64bitPlatform_1604_v5.0目录,即为ubuntu16.04的系统镜像,可以直接使用。


运行ubuntu系统

  • 启动wmware软件
Vmware install 12.png
  • 通过vmware加载ubuntu系统
  • 点击“打开虚拟机
Vmware install 13.png
  • 选中上面解压的ubuntu16.04系统,并点击“打开”
Vmware install 14.png

可以看到一个“挂起状态”的ubuntu16.04系统。

  • 接下来,点击虚拟机绿色的“启动键”,即可以恢复进行ubuntu1604系统。
Vmware install 15.png
  • 选择“我已复制该虚拟机”
Vmware install 1611.png

正常进入“ubuntu系统主界面”。

  • 接下来,重启ubuntu系统,并使用新用户login.
Vmware install 1711.png
  • 点击“login”
Vmware install 1811.png
  • 输入用户名“root”
Vmware install 1911.png
  • 回车输入密码“123456”
Vmware install 2011.png
  • 回车,进入ubuntu系统
Vmware install 1611.png

至此,整个ubuntu1604系统安装完毕。


设置共享目录

共享目录主要是用于实现windows与ubuntu两个系统之间的数据交互,比如windows有一个文件要给ubuntu系统用时,就可以将文件放置到共享目录下传给ubuntu。 新的共享目录可以如下配置:

  • 在windows桌面新建名为shareWin的目录文件,并且在里面创建一个名为hello的文件
 GbaSet 01.png
  • 回到ubuntu系统的shell操作界面,进行如下操作
# ls /mnt/hgfs

可以看到没有名为shareWin的目录文件,接下来做如下操作:

GbaSet 02.png
GbaSet 03.png
GbaSet 04.png
  • 再次执行
# ls /mnt/hgfs
# cd /mnt/hgfs/shareWin/
# ls 

发现在/mnt/hgfs目录下,多了一个名为shareWin的目录文件,再进到里面可能看到之前创建的hello文件。

至此,两个系统间的共享文件夹设置并启完毕,后面如果两个系统需要共享资料时,可以将其放到共享目录即可。


网络配置连接

  • 电脑windows连接上网络(可以是有线网络,也可以是无线网络,推荐无线)
  • 检查设置ubuntu为桥接网络连接方式
Vmware netset 01.png

注意:必须设置为桥接方式。


  • 重启ubuntu网络
Vmware netset 02.png
  • 测试网络是否可联网
Vmware netset 03.png

如果可以ping通百度,则网络配置成功。


shell命令简单使用

shell终端打开

点击mouse右键,选中”open terminal”,打开shell终端。

Vmware install 22.png

或者同时按下“ctrl + alt +t”快速打开

Vmware install 23.png
  • 命令提示符说明

gec@ubuntu:~$
gec :用户名
@ :分隔符
ubuntu :机器名

:分隔符

~ :家目录 /home/gec
$ :普通用户


root@ubuntu:~#
root :root用户(超级用户)

  1. :root用户标志

常用shell命令

此处略


实践操作

  • 实践1:请按照以下步骤完成shell命令操作
# mkdir /opt/shell_test          //在opt目录下新建一个名为shell_test文件
# ls /opt/shell_test             //查看/opt/shell_test目录
# cd /opt/shell_test             //进入/opt/shell_test目录
# mkdir hello			 //新建一个名为hello目录
# ls                             //查看当前目录内容
# rmdir hello                    //删除hello目录
# ls 
# touch hello.c                  //创建一个hello.c文件 
# ls 
# rm hello.c                     //删除hello.c文件 
# ls 
# mkdir hello 
# touch hello/hello.c 	         //在hello目录下新建一个hello.c文件
# touch world.c                  //新建world.c文件
# ls 
# rm -rf ./*                     //删除当前目录下所有文件
# ls 


  • 实践2: 完成以下shell命令操作

# cd /opt/shell_test                    //进入/opt/shell_test目录下
# touch hello.c                         //新建hello.c
# ls
# chmod 777 hello.c                     //修改hello.c文件为可读写
# ls 
 
# cp hello.c hello_backup.c  -rdf       //将hello.c拷贝保存为一个新文件hello_backup.c
# ls 

# mv hello_backup.c 123.c               //将hello_backup.c改名为123.c 
# ls                                    
# mkdir test 
# mv 123.c test                         //将123.c文件移到test目录下
# mv test smartHome                     //将test目录改名为smartHome
# ls 
# tar cvfj smartHome.tar.bz2 smartHome  //将smartHome目录压缩为smartHome.tar.bz2文件
# ls
# rm -rf smartHome
# ls 
# tar xvfj smartHome.tar.bz2            //将smartHome.tar.bz2文件解压为smartHome目录
# ls 

  • 实践3: 编辑、编译及执行代码

# cd /opt/shell_test
# rm -rf ./*

# touch hello.c 
# vi hello.c 
可以进入文件中,按下i,就可以编辑内容

#include <stdio.h>
#include <unistd.h>
int main()
{
        while(1)
        {
                printf("hello world.\n");
                sleep(1);
        }
              
        return 0;
}

按下Esc,退出插入模式,再输入
:wq!  (保存退出)

# gcc hello.c -o hello        // 将hello.c编译为hello
# ./hello                     // 执行可执行文件hello



应用开发

测试代码开发

  • 工程包准备

进入ubuntu,打开终端,执行

cd  /nfs

从网页中下载demo包playDemo.tar.bz2[下载],并放置共享文件目录,返回ubuntu终端,执行:

cp /mnt/hgfs/shareWin/playDemo.tar.bz2  ./ 
tar xvfj playDemo.tar.bz2
cd  playDemo 
  • 代码开发

打开源文件playCtl.c

vi  playCtl.c 

在main函数中,添加

PlayCtrl 001.png	


注意:上面代码中

“char *argv[]={"maplayer","-slave","-quiet","-input","file=/opt/fifo","-playList", "MediaList",NULL};”
请将maplayer改成mplayer

在ui_choice函数中,添加:

PlayCtrl 002.png

编译执行演示

  • 程序编译
gcc playCtl.c -o playCtl

可以看到在当前目录下生成了一个名为playCtl的可执行文件

  • 程序执行
mkfifo  /opt/fifo  
./playCtl

可以看到开始播放视频,而在终端可以看到控制列表,输入对应的数字可以执行相应的功能

注意:上面程序执行的前提是ubuntu系统中已安装有mplayer播放器,否则会异常退出。



附录:


资源编号 资源名称 下载链接
1 MPlayer-1.3.0.tar.xz mplayer源码包下载
2 debug.mp4 mp4测试文件
3 VirtualBox加载Ubuntu 打开查看


返回 上一页