#include
#include
#include
#include
#include
QByteArray byteArray;
QBuffer buffer(&byteArray);
void *haddle(void *)
{
char buf[20000];
int n,i=0;
FILE *fp;
buffer.open(QIODevice::ReadWrite);
if((fp=fopen("/home/denggs/V4L2/2010.mpg","r+"))==NULL)
{
perror("error11\n"); exit(1);
}
do
{
n=fread(buf,1,20000,fp);
qDebug("%d %d\n",n,i);
if(n>0)
{
buffer.seek(i*20000);
i++;
buffer.write(buf,n);
}
if(feof(fp))
{
perror("OK\n");
break;
}
memset(buf,0,20000);
}
while(1);
return 0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("VideoPlayer");
QWidget *widget=new QWidget;
widget->setWindowTitle("Video Player");
widget->resize(600,400);
Phonon::VideoPlayer *player=new Phonon::VideoPlayer(Phonon::VideoCategory,widget);
pthread_t b;
pthread_create(&b,NULL,haddle,NULL);
sleep(1);
player->load(Phonon::MediaSource(& buffer));
player->play();
widget->show();
return a.exec();
}
阅读(5258) | 评论(0) | 转发(0) |