media: modify recorder example for control the volume
media recorder support the control the volume
add volume up and down cases for recorder example
#include <iostream>
#include <memory>
-constexpr int APP_ON = 0;
-constexpr int RECORDER_START = 1;
-constexpr int RECORDER_PAUSE = 2;
-constexpr int RECORDER_RESUME = 3;
-constexpr int RECORDER_STOP = 4;
-constexpr int APP_OFF = 5;
-constexpr int PLAY_DATA = 6;
+constexpr int APP_ON = 1;
+constexpr int RECORDER_START = 2;
+constexpr int RECORDER_PAUSE = 3;
+constexpr int RECORDER_RESUME = 4;
+constexpr int RECORDER_STOP = 5;
+constexpr int VOLUME_UP = 6;
+constexpr int VOLUME_DOWN = 7;
+constexpr int PLAY_DATA = 8;
+constexpr int APP_OFF = 0;
using namespace std;
using namespace media;
@@ -103,17 +105,34 @@ public:
}
}
break;
+ case PLAY_DATA: {
+ std::cout << "PLAY_DATA" << std::endl;
+ play_data();
+ }
+ break;
+ case VOLUME_UP: {
+ std::cout << "VOLUME_UP" << std::endl;
+ if (mr.setVolume(mr.getVolume() + 1) == RECORDER_ERROR) {
+ cout << "setVolume failed" << endl;
+ }
+ std::cout << "Now, Volume is " << mr.getVolume() << std::endl;
+ }
+ break;
+ case VOLUME_DOWN: {
+ std::cout << "VOLUME_DOWN" << std::endl;
+ if (mr.setVolume(mr.getVolume() - 1) == RECORDER_ERROR) {
+ cout << "setVolume failed" << endl;
+ }
+ std::cout << "Now, Volume is " << mr.getVolume() << std::endl;
+ }
+ break;
case APP_OFF: {
std::cout << "SELECTED APP_OFF" << std::endl;
mr.destroy();
appRunning = false;
}
break;
- case PLAY_DATA: {
- std::cout << "PLAY_DATA" << std::endl;
- play_data();
- }
- break;
+
}
}
}
@@ -173,15 +192,15 @@ public:
void printRecorderMenu()
{
std::cout << "========================================" << std::endl;
-
- std::cout << "0. RECORDER APP ON" << std::endl;
- std::cout << "1. RECORDER Start" << std::endl;
- std::cout << "2. RECORDER Pause" << std::endl;
- std::cout << "3. RECORDER Resume" << std::endl;
- std::cout << "4. RECORDER Stop" << std::endl;
- std::cout << "5. RECORDER APP OFF" << std::endl;
- std::cout << "6. play Data" << std::endl;
-
+ std::cout << "1. RECORDER APP ON" << std::endl;
+ std::cout << "2. RECORDER Start" << std::endl;
+ std::cout << "3. RECORDER Pause" << std::endl;
+ std::cout << "4. RECORDER Resume" << std::endl;
+ std::cout << "5. RECORDER Stop" << std::endl;
+ std::cout << "6. RECORDER Volume Up" << std::endl;
+ std::cout << "7. RECORDER Volume Down" << std::endl;
+ std::cout << "8. play Data" << std::endl;
+ std::cout << "0. RECORDER APP OFF" << std::endl;
std::cout << "========================================" << std::endl;
}
