summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/om3u.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp7
3 files changed, 11 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 8b92a8c..778eb22 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -22,151 +22,154 @@
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "playlistwidget.h"
#include "om3u.h"
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <qpe/mimetype.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qdir.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qcstring.h>
static inline QString fullBaseName ( const QFileInfo &fi )
{
QString str = fi. fileName ( );
return str. left ( str. findRev ( '.' ));
}
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
f.open(mode);
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
// qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
QString name = fullBaseName ( f );
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
s.replace( QRegExp( "%20" )," " );
QString name;
// if( name.left( 4 ) == "http" ) {
// name = s.right( s.length() - 7 );
// } else {
name = s;
// }
append(name);
// qDebug(name);
}
}
}
}
void Om3u::readPls() { //it's a pls file
QTextStream t( &f );
+ t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s = t.readLine();
if( s.left(4) == "File" ) {
s = s.right( s.length() - 6 );
s.replace( QRegExp( "%20" )," ");
// qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
QString name = fullBaseName ( f );
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
if( s.at( s.length() - 4) == '.') // if this is probably a file
append(s);
else { //if its a url
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
append(s);
}
}
}
}
void Om3u::write() { //writes list to m3u file
QString list;
+ QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
// qDebug(*it);
- list += *it+"\n";
+ t << *it << "\n";
}
- f.writeBlock( list, list.length() );
}
// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
append(filePath);
}
void Om3u::remove(const QString &filePath) { //removes from m3u list
QString list, currentFile;
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
currentFile=*it;
// qDebug(*it);
if( filePath != currentFile)
list += currentFile+"\n";
}
f.writeBlock( list, list.length() );
}
}
void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
f.close();
f.remove();
}
void Om3u::close() { //closes m3u file
f.close();
}
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 00cfa33..664ec65 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -162,97 +162,97 @@ Lib::~Lib() {
xine_dispose( m_stream );
xine_exit( m_xine );
/* FIXME either free or delete but valgrind bitches against both */
//free( m_videoOutput );
//delete m_audioOutput;
}
void Lib::resize ( const QSize &s ) {
assert( m_initialized || m_duringInitialization );
if ( s. width ( ) && s. height ( ) ) {
::null_set_gui_width( m_videoOutput, s. width() );
::null_set_gui_height( m_videoOutput, s. height() );
}
}
int Lib::majorVersion() {
int major, minor, sub;
xine_get_version ( &major, &minor, &sub );
return major;
}
int Lib::minorVersion() {
int major, minor, sub;
xine_get_version ( &major, &minor, &sub );
return minor;
}
int Lib::subVersion() {
int major, minor, sub;
xine_get_version ( &major, &minor, &sub );
return sub;
}
int Lib::play( const QString& fileName, int startPos, int start_time ) {
assert( m_initialized );
// FIXME actually a hack imho. Should not be needed to dispose the whole stream
// but without we get wrong media length reads from libxine for the second media
//xine_dispose ( m_stream );
QString str = fileName.stripWhiteSpace();
//m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
//m_queue = xine_event_new_queue (m_stream);
//xine_event_create_listener_thread (m_queue, xine_event_handler, this);
- if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
+ if ( !xine_open( m_stream, str.utf8().data() ) ) {
return 0;
}
return xine_play( m_stream, startPos, start_time);
}
void Lib::stop() {
assert( m_initialized );
qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
xine_stop( m_stream );
}
void Lib::pause( bool toggle ) {
assert( m_initialized );
xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
}
int Lib::speed() const {
assert( m_initialized );
return xine_get_param ( m_stream, XINE_PARAM_SPEED );
}
void Lib::setSpeed( int speed ) {
assert( m_initialized );
xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
}
int Lib::status() const {
assert( m_initialized );
return xine_get_status( m_stream );
}
int Lib::currentPosition() const {
assert( m_initialized );
int pos, time, length;
xine_get_pos_length( m_stream, &pos, &time, &length );
return pos;
}
int Lib::currentTime() const {
assert( m_initialized );
int pos, time, length;
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 7183fb4..69e87e7 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -15,146 +15,149 @@
    .i_,=:_.      -<s. This program 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 library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "playlistwidget.h"
#include "om3u.h"
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <qpe/mimetype.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qdir.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qcstring.h>
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
f.open(mode);
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
// qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
QString name = f.baseName();
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
QString name;
name = s;
append(name);
}
}
}
}
void Om3u::readPls() { //it's a pls file
QTextStream t( &f );
+ t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s = t.readLine();
if( s.left(4) == "File" ) {
s = s.right( s.length() - s.find("=",0,true)-1 );
s = s.stripWhiteSpace();
s.replace( QRegExp( "%20" )," ");
// qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
QString name = f.baseName();
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
if( s.at( s.length() - 4) == '.') // if this is probably a file
append(s);
else { //if its a url
// if( name.right( 1 ).find( '/' ) == -1) {
// s += "/";
// }
append(s);
}
}
}
}
void Om3u::write() { //writes list to m3u file
QString list;
+ QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
// qDebug(*it);
- list += *it+"\n";
+ t << *it << "\n";
}
- f.writeBlock( list, list.length() );
}
// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
append(filePath);
}
void Om3u::remove(const QString &filePath) { //removes from m3u list
QString list, currentFile;
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
currentFile=*it;
// qDebug(*it);
if( filePath != currentFile)
list += currentFile+"\n";
}
f.writeBlock( list, list.length() );
}
}
void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
f.close();
f.remove();
}
void Om3u::close() { //closes m3u file
f.close();
}