[vlmc-devel] commit: VLCMediaPlayer.cpp: Add interfaces to control volume. (Rohit Yadav )

git at videolan.org git at videolan.org
Sun Sep 26 22:14:50 CEST 2010


vlmc | branch: master | Rohit Yadav <rohityadav89 at gmail.com> | Mon Sep 27 01:55:37 2010 +0530| [d51f68121e8f5587e55073c191bf8d4570dbbe07] | committer: Rohit Yadav 

VLCMediaPlayer.cpp: Add interfaces to control volume.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=d51f68121e8f5587e55073c191bf8d4570dbbe07
---

 src/LibVLCpp/VLCMediaPlayer.cpp |   19 ++++++++++++++++++-
 src/LibVLCpp/VLCMediaPlayer.h   |    6 ++++++
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/LibVLCpp/VLCMediaPlayer.cpp b/src/LibVLCpp/VLCMediaPlayer.cpp
index c220701..f97500d 100644
--- a/src/LibVLCpp/VLCMediaPlayer.cpp
+++ b/src/LibVLCpp/VLCMediaPlayer.cpp
@@ -117,8 +117,11 @@ MediaPlayer::callbacks( const libvlc_event_t* event, void* ptr )
         qDebug() << '[' << (void*)self << "] libvlc_MediaPlayerEncounteredError received."
                 << "This is not looking good...";
         self->emit errorEncountered();
-        break ;
+        break;
     case libvlc_MediaPlayerSeekableChanged:
+        // TODO: Later change it to an event that corresponds volume change, when this thing gets fixed in libvlc
+        self->emit volumeChanged();
+        break;
     case libvlc_MediaPlayerPausableChanged:
     case libvlc_MediaPlayerTitleChanged:
     case libvlc_MediaPlayerNothingSpecial:
@@ -152,6 +155,20 @@ MediaPlayer::stop()
     libvlc_media_player_stop( m_internalPtr );
 }
 
+int
+MediaPlayer::getVolume()
+{
+    int volume = libvlc_audio_get_volume( m_internalPtr );
+    return volume;
+}
+
+int
+MediaPlayer::setVolume( int volume )
+{
+    //Returns 0 if the volume was set, -1 if it was out of range
+    return libvlc_audio_set_volume( m_internalPtr, volume / 2 );
+}
+
 qint64
 MediaPlayer::getTime()
 {
diff --git a/src/LibVLCpp/VLCMediaPlayer.h b/src/LibVLCpp/VLCMediaPlayer.h
index 368b5f7..5c95953 100644
--- a/src/LibVLCpp/VLCMediaPlayer.h
+++ b/src/LibVLCpp/VLCMediaPlayer.h
@@ -27,6 +27,9 @@
 #include <QObject>
 #include "VLCpp.hpp"
 
+#define VOLUME_MAX         100
+#define AOUT_VOLUME_MAX    1024
+
 struct  libvlc_media_player_t;
 struct  libvlc_event_t;
 struct  libvlc_event_manager_t;
@@ -44,6 +47,8 @@ namespace   LibVLCpp
         void                                play();
         void                                pause();
         void                                stop();
+        int                                 getVolume();
+        int                                 setVolume( int volume );
         qint64                              getTime();
         void                                setTime( qint64 time );
         float                               getPosition();
@@ -79,6 +84,7 @@ namespace   LibVLCpp
         void                                paused();
         void                                stopped();
         void                                endReached();
+        void                                volumeChanged();
         void                                positionChanged( float );
         void                                lengthChanged( qint64 );
         void                                errorEncountered();



More information about the Vlmc-devel mailing list