summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-21 03:26:09 (UTC)
committer llornkcor <llornkcor>2002-04-21 03:26:09 (UTC)
commit6818807a46b80774de328b4c3001d4bc9d788666 (patch) (side-by-side diff)
tree1bede7ebbb324058b664330abf481f7afb25eb73
parent1c459273c0e9e387fd5fe2e2c05bef4db5bce115 (diff)
downloadopie-6818807a46b80774de328b4c3001d4bc9d788666.zip
opie-6818807a46b80774de328b4c3001d4bc9d788666.tar.gz
opie-6818807a46b80774de328b4c3001d4bc9d788666.tar.bz2
fixed when playing stream, slider moved and stopped stream when it reached the end
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp7
-rw-r--r--core/multimedia/opieplayer/audiowidget.h20
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp18
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp1
5 files changed, 28 insertions, 20 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 3212001..20345b7 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -79,31 +79,34 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
slider->setFixedWidth( 220 );
slider->setFixedHeight( 20 );
slider->setMinValue( 0 );
slider->setMaxValue( 1 );
slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
slider->setFocusPolicy( QWidget::NoFocus );
slider->setGeometry( QRect( 7, 262, 220, 20 ) );
connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
- connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
+ if( !mediaPlayerState->isStreaming) { // this stops the slider from being moved, thus
+ // does not stop stream when it reaches the end
+ connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ }
// Intialise state
setLength( mediaPlayerState->length() );
setPosition( mediaPlayerState->position() );
setLooping( mediaPlayerState->fullscreen() );
setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState->playing() );
}
AudioWidget::~AudioWidget() {
for ( int i = 0; i < 4; i++ )
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index d1d72b6..4ffd167 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -44,36 +44,36 @@ enum AudioButtons {
AudioLoop,
AudioPlayList
};
#define USE_DBLBUF
class Ticker : public QFrame {
Q_OBJECT
public:
Ticker( QWidget* parent=0 ) : QFrame( parent ) {
- setFrameStyle( WinPanel | Sunken );
- setText( "No Song" );
+ setFrameStyle( WinPanel | Sunken );
+ setText( "No Song" );
}
~Ticker() { }
void setText( const QString& text ) {
- pos = 0; // reset it everytime the text is changed
- scrollText = text;
- pixelLen = fontMetrics().width( scrollText );
- killTimers();
- if ( pixelLen > width() )
- startTimer( 50 );
- update();
+ pos = 0; // reset it everytime the text is changed
+ scrollText = text;
+ pixelLen = fontMetrics().width( scrollText );
+ killTimers();
+ if ( pixelLen > width() )
+ startTimer( 50 );
+ update();
}
protected:
void timerEvent( QTimerEvent * ) {
pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
#ifndef USE_DBLBUF
scroll( -1, 0, contentsRect() );
#else
repaint( FALSE );
#endif
}
void drawContents( QPainter *p ) {
#ifndef USE_DBLBUF
@@ -93,25 +93,25 @@ protected:
private:
QString scrollText;
int pos, pixelLen;
};
class AudioWidget : public QWidget {
Q_OBJECT
public:
AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
~AudioWidget();
void setTickerText( const QString &text ) { songInfo->setText( text ); }
-
+ bool isStreaming;
public slots:
void updateSlider( long, long );
void sliderPressed( );
void sliderReleased( );
void setPaused( bool b) { setToggleButton( AudioPause, b ); }
void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
void setPosition( long );
void setLength( long );
void setView( char );
signals:
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index b9f96de..45c2d3e 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -227,32 +227,33 @@ void LoopControl::startAudio() {
if ( !isMuted && mediaPlayerState->curDecoder() ) {
currentSample = audioSampleCounter + 1;
if ( currentSample != audioSampleCounter + 1 )
qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
long samplesRead = 0;
bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
long sampleWaitTime = currentSample - sampleWeShouldBeAt;
-// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
-// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
+// this causes drop outs not sure why its even here
+// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
+// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
+// }
+// else if ( sampleWaitTime <= -5000 ) {
+// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
+// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
+// currentSample = sampleWeShouldBeAt;
// }
-// else if ( sampleWaitTime <= -5000 ) {
-// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
-// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
-// currentSample = sampleWeShouldBeAt;
-// }
audioDevice->write( audioBuffer, samplesRead * 2 * channels );
audioSampleCounter = currentSample + samplesRead - 1;
moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
} else {
moreAudio = FALSE;
}
@@ -423,24 +424,27 @@ bool LoopControl::init( const QString& filename ) {
framerate = 25;
}
if ( total_video_frames == 1 ) {
DecodeLoopDebug(( "Cannot seek to frame" ));
}
}
current_frame = 0;
prev_frame = -1;
+ if( fileName.left(7) == "http://")
+ mediaPlayerState->isStreaming = TRUE;
+
connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
audioMutex->unlock();
return TRUE;
}
void LoopControl::play() {
qDebug("LC- play");
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index ad273f1..06c5556 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -25,25 +25,25 @@
class MediaPlayerDecoder;
class Config;
class MediaPlayerState : public QObject {
Q_OBJECT
public:
MediaPlayerState( QObject *parent, const char *name );
~MediaPlayerState();
-
+ bool isStreaming;
bool fullscreen() { return isFullscreen; }
bool scaled() { return isScaled; }
bool looping() { return isLooping; }
bool shuffled() { return isShuffled; }
bool playlist() { return usePlaylist; }
bool paused() { return isPaused; }
bool playing() { return isPlaying; }
long position() { return curPosition; }
long length() { return curLength; }
char view() { return curView; }
MediaPlayerDecoder *newDecoder( const QString& file );
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 250645c..ff156f8 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -984,24 +984,25 @@ void PlayListWidget::openFile() {
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->LineEdit1->text();
// InputDialog *fileDlg2;
// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0);
// fileDlg2->exec();
// if( fileDlg2->result() == 1 ) {
// name = fileDlg2->LineEdit1->text();
// }
//http://205.188.234.129:8030
+// http://66.28.68.70:8000
qDebug(filename);
DocLnk lnk;
// if(filename.left(7) == "http://")
// name= filename.right(filename.length()-filename.find("http://")-7);
// else name = filename;
// qDebug("name is "+name);
// lnk.setComment(filename);
lnk.setName(filename); //sets file name
if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
filename += "/";
lnk.setFile(filename); //sets File property