From c2ef6af08aaf8cf9d4c1d2bd4889ba828a7f75ac Mon Sep 17 00:00:00 2001 From: Henrik Date: Tue, 20 Sep 2011 15:54:19 +0200 Subject: [PATCH] Playlist --- src/playlist.cc | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/playlist.h | 47 +++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 0 deletions(-) create mode 100644 src/playlist.cc create mode 100644 src/playlist.h diff --git a/src/playlist.cc b/src/playlist.cc new file mode 100644 index 0000000..4059270 --- /dev/null +++ b/src/playlist.cc @@ -0,0 +1,104 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * bino + * Copyright (C) Henrik Reinstädtler 2011 + * + * bino is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bino is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +#include "gettext.h" +#define _(string) gettext(string) +#include "playlist.h" +#include "media_input.h" +#include +#include +using namespace std; +playlist::addItem(std::string FilePath) +{ + media_input medium= new media_input(); + medium->open(FilePath); + if (medium->video_streams() == 0) + { + throw exc(_("No video streams found.")); + } + Items.pushback(medium); +} +playlist::addItem(media_input Item) +{ + + if (medium->video_streams() == 0) + { + throw exc(_("No video streams found.")); + } + Items.pushback(Item); +} +playlist::open(std::string FilePath) +{ + FILE *in_stream; + media_input data; + if((in_stream = fopen(FilePath,r))==NULL) + { + char *buffer; + while(fgets(buffer,100,in_stream)) + { + data =new media_input(); + data->open(FilePath); + Items.pushback(data); + } + } + else exc(_("No Playlist found.")); + delete data; +} +playlist::save(std::string FilePath) +{ + FILE *out_stream; + if((out_stream = fopen(FilePath,w))==NULL) + { + for(i=0;i + * + * bino is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bino is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _PLAYLIST_H_ +#define _PLAYLIST_H_ + +class playlist +{ +public: + //void Createlist(const std::string name); + void addItem(std::string FilePath);//+ + void addItem(media_input Item);//+ + void save(std::string fileName);//- + void open(std::string path); + void next();//+ + void move(int From, int To);//+ + void reset();//+ + void setTo(int index);//+ + void last();//+ + int getCurrentIndex();//+ + media_input current();//+ +protected: + media_input getItem(int I); + +private: + int index=-1; + int size=0; +vector Items; +}; + +#endif // _PLAYLIST_H_ -- 1.7.6