summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 9f51006..1e6bc4d 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,141 +1,141 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/config.h> 2#include <qpe/config.h>
3#include <qpe/qcopenvelope_qws.h> 3#include <qpe/qcopenvelope_qws.h>
4#include <qfileinfo.h> 4#include <qfileinfo.h>
5 5
6#include "mediaplayer.h" 6#include "mediaplayer.h"
7#include "playlistwidget.h" 7#include "playlistwidget.h"
8#include "audiowidget.h" 8#include "audiowidget.h"
9#include "videowidget.h" 9#include "videowidget.h"
10#include "volumecontrol.h" 10#include "volumecontrol.h"
11#include "lib.h" 11#include "lib.h"
12 12
13#include "mediaplayerstate.h" 13#include "mediaplayerstate.h"
14 14
15 // for setBacklight() 15 // for setBacklight()
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <sys/file.h> 17#include <sys/file.h>
18#include <sys/ioctl.h> 18#include <sys/ioctl.h>
19 19
20 20
21#define FBIOBLANK 0x4611 21#define FBIOBLANK 0x4611
22 22
23MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 23MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
24 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 24 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
25 25
26 m_audioUI = 0; 26 m_audioUI = 0;
27 m_videoUI = 0; 27 m_videoUI = 0;
28 m_xineControl = 0; 28 m_xineControl = 0;
29 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 29 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
30 30
31 fd=-1;fl=-1; 31 fd=-1;fl=-1;
32 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 32 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
33 33
34 qApp->processEvents(); 34 qApp->processEvents();
35 // QPEApplication::grabKeyboard(); // EVIL 35 // QPEApplication::grabKeyboard(); // EVIL
36 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 36 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
37 37
38 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 38 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
39 39
40// What is pauseCheck good for? (Simon) 40// What is pauseCheck good for? (Simon)
41// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 41// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
42 42
43 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 43 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
44 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 44 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
45 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 45 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
46 46
47 volControl = new VolumeControl; 47 volControl = new VolumeControl;
48 Config cfg( "OpiePlayer" ); 48 Config cfg( "OpiePlayer" );
49 cfg.setGroup("PlayList"); 49 cfg.setGroup("PlayList");
50 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 50 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
51 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 51 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
52 52
53 m_skinLoader = new SkinLoader; 53 m_skinLoader = new SkinLoader;
54 m_skinLoader->schedule( AudioWidget::guiInfo() ); 54 m_skinLoader->schedule( AudioWidget::guiInfo() );
55 m_skinLoader->schedule( VideoWidget::guiInfo() ); 55 m_skinLoader->schedule( VideoWidget::guiInfo() );
56 m_skinLoader->start(); 56 m_skinLoader->start();
57} 57}
58 58
59MediaPlayer::~MediaPlayer() { 59MediaPlayer::~MediaPlayer() {
60 // this shold never happen, but one never knows... 60 // this shold never happen, but one never knows...
61 if ( xine ) { 61 if ( xine ) {
62 xine->ensureInitialized(); 62 xine->ensureInitialized();
63 delete xine; 63 delete xine;
64 } 64 }
65 delete m_xineControl; 65 delete m_xineControl;
66 delete m_audioUI; 66 delete m_audioUI;
67 delete m_videoUI; 67 delete m_videoUI;
68 delete volControl; 68 delete volControl;
69} 69}
70 70
71void MediaPlayer::pauseCheck( bool b ) { 71void MediaPlayer::pauseCheck( bool b ) {
72 if ( b && !mediaPlayerState.isPlaying() ) { 72 if ( b && !mediaPlayerState.isPlaying() ) {
73 mediaPlayerState.setPaused( FALSE ); 73 mediaPlayerState.setPaused( FALSE );
74 } 74 }
75} 75}
76 76
77void MediaPlayer::play() { 77void MediaPlayer::play() {
78 mediaPlayerState.setPlaying( FALSE ); 78 mediaPlayerState.setPlaying( FALSE );
79 mediaPlayerState.setPlaying( TRUE ); 79 mediaPlayerState.setPlaying( TRUE );
80} 80}
81 81
82void MediaPlayer::setPlaying( bool play ) { 82void MediaPlayer::setPlaying( bool play ) {
83 if ( !play ) { 83 if ( !play ) {
84 return; 84 return;
85 } 85 }
86 86
87 if ( mediaPlayerState.isPaused() ) { 87 if ( mediaPlayerState.isPaused() ) {
88 mediaPlayerState.setPaused( FALSE ); 88 mediaPlayerState.setPaused( FALSE );
89 return; 89 return;
90 } 90 }
91 91
92 QString tickerText, time, fileName; 92 QString tickerText, time, fileName;
93 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 93 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
94 //if playing in file list.. play in a different way 94 //if playing in file list.. play in a different way
95 // random and looping settings enabled causes problems here, 95 // random and looping settings enabled causes problems here,
96 // since there is no selected file in the playlist, but a selected file in the file list, 96 // since there is no selected file in the playlist, but a selected file in the file list,
97 // so we remember and shutoff 97 // so we remember and shutoff
98 l = mediaPlayerState.isLooping(); 98 l = mediaPlayerState.isLooping();
99 if(l) { 99 if(l) {
100 mediaPlayerState.setLooping( false ); 100 mediaPlayerState.setLooping( false );
101 } 101 }
102 r = mediaPlayerState.isShuffled(); 102 r = mediaPlayerState.isShuffled();
103 mediaPlayerState.setShuffled( false ); 103 mediaPlayerState.setShuffled( false );
104 } 104 }
105 105
106 PlayListWidget::Entry playListEntry = playList.currentEntry(); 106 PlayListWidget::Entry playListEntry = playList.currentEntry();
107 fileName = playListEntry.name; 107 fileName = playListEntry.name;
108 xineControl()->play( playListEntry.file ); 108 xineControl()->play( playListEntry.file );
109 109
110 long seconds = mediaPlayerState.length(); 110 long seconds = mediaPlayerState.length();
111 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 111 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
112 112
113 if( fileName.left(4) == "http" ) { 113 if( fileName.left(4) == "http" ) {
114 fileName = QFileInfo( fileName ).baseName(); 114 fileName = QFileInfo( fileName ).baseName();
115 if ( xineControl()->getMetaInfo().isEmpty() ) { 115 if ( xineControl()->getMetaInfo().isEmpty() ) {
116 tickerText = tr( " File: " ) + fileName; 116 tickerText = tr( " File: " ) + fileName;
117 } else { 117 } else {
118 tickerText = xineControl()->getMetaInfo(); 118 tickerText = xineControl()->getMetaInfo();
119 } 119 }
120 } else { 120 } else {
121 if ( xineControl()->getMetaInfo().isEmpty() ) { 121 if ( xineControl()->getMetaInfo().isEmpty() ) {
122 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 122 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
123 } else { 123 } else {
124 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 124 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
125 } 125 }
126 } 126 }
127 audioUI()->setTickerText( tickerText ); 127 audioUI()->setTickerText( tickerText );
128} 128}
129 129
130 130
131void MediaPlayer::prev() { 131void MediaPlayer::prev() {
132 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 132 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
133 if ( playList.prev() ) { 133 if ( playList.prev() ) {
134 play(); 134 play();
135 } else if ( mediaPlayerState.isLooping() ) { 135 } else if ( mediaPlayerState.isLooping() ) {
136 if ( playList.last() ) { 136 if ( playList.last() ) {
137 play(); 137 play();
138 } 138 }
139 } else { 139 } else {
140 mediaPlayerState.setList(); 140 mediaPlayerState.setList();
141 } 141 }