Advertisement
svenhoefer

Untitled

Aug 17th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.23 KB | None | 0 0
  1. diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale
  2. index 5321cd3..40cda13 100644
  3. --- a/data/locale/deutsch.locale
  4. +++ b/data/locale/deutsch.locale
  5. @@ -198,6 +198,8 @@ audioplayer.select_title_by_name Titelsuche nach Name (SMS)
  6.  audioplayer.show_playlist Playlist anzeigen
  7.  audioplayer.shuffle Zufällig
  8.  audioplayer.spectrum LCD Skala
  9. +audioplayer.streamripper_start Streamripper starten
  10. +audioplayer.streamripper_stop Streamripper stoppen
  11.  audioplayer.stop Stopp
  12.  audioplayer.title_artist Titel, Interpret
  13.  blank_screen Blanker Bildschirm
  14. diff --git a/data/locale/english.locale b/data/locale/english.locale
  15. index 4479fa8..7a0114c 100644
  16. --- a/data/locale/english.locale
  17. +++ b/data/locale/english.locale
  18. @@ -198,6 +198,8 @@ audioplayer.select_title_by_name Search title by name (SMS)
  19.  audioplayer.show_playlist Show playlist
  20.  audioplayer.shuffle Shuffle
  21.  audioplayer.spectrum LCD spectrum
  22. +audioplayer.streamripper_start Start streamripper
  23. +audioplayer.streamripper_stop Stop streamripper
  24.  audioplayer.stop Stop
  25.  audioplayer.title_artist Title, artist
  26.  blank_screen Blank screen
  27. diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp
  28. index a8e91e4..580f6ae 100644
  29. --- a/src/gui/audioplayer.cpp
  30. +++ b/src/gui/audioplayer.cpp
  31. @@ -216,7 +216,7 @@ CAudioPlayerGui::~CAudioPlayerGui()
  32.     delete m_titlebox;
  33.  }
  34.  
  35. -const struct button_label AudioPlayerButtons[][4] =
  36. +/*const*/ struct button_label AudioPlayerButtons[][4] =
  37.  {
  38.     {
  39.         { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP           },
  40. @@ -249,6 +249,7 @@ const struct button_label AudioPlayerButtons[][4] =
  41.     {
  42.         { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP           },
  43.         { NEUTRINO_ICON_BUTTON_PAUSE    , LOCALE_AUDIOPLAYER_PAUSE          },
  44. +       { NEUTRINO_ICON_BUTTON_RECORD_ACTIVE, LOCALE_AUDIOPLAYER_STREAMRIPPER_START },
  45.     },
  46.     {
  47.         { NEUTRINO_ICON_BUTTON_GREEN    , LOCALE_AUDIOPLAYER_ADD            },
  48. @@ -321,6 +322,9 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
  49.     m_idletime = time(NULL);
  50.     m_screensaver = false;
  51.  
  52. +   m_streamripper_available = !find_executable("streamripper").empty() && !find_executable("streamripper.sh").empty();
  53. +   m_streamripper_active = false;
  54. +
  55.     if (parent)
  56.         parent->hide();
  57.  
  58. @@ -838,6 +842,32 @@ int CAudioPlayerGui::show()
  59.                 update = true;
  60.             }
  61.         }
  62. +       else if (msg == (neutrino_msg_t) g_settings.key_record)
  63. +       {
  64. +           if (m_key_level == 1)
  65. +           {
  66. +               if (m_curr_audiofile.FileType == CFile::STREAM_AUDIO && m_streamripper_available)
  67. +               {
  68. +                   if (m_streamripper_active)
  69. +                   {
  70. +                       ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_AUDIOPLAYER_STREAMRIPPER_STOP, HINTBOX_MIN_WIDTH, 2);
  71. +                       my_system(2, "streamripper.sh", "stop");
  72. +                       m_streamripper_active = false;
  73. +                   }
  74. +                   else
  75. +                   {
  76. +                       ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_AUDIOPLAYER_STREAMRIPPER_START, HINTBOX_MIN_WIDTH, 2);
  77. +                       printf("streamripper.sh start \"%s\"\n", m_playlist[m_current].MetaData.url.c_str());
  78. +                       puts("[audioplayer.cpp] executing streamripper");
  79. +                       if (my_system(3, "streamripper.sh", "start", m_playlist[m_current].MetaData.url.c_str()) != 0)
  80. +                           perror("[audioplayer.cpp]: streamripper.sh failed\n");
  81. +                       else
  82. +                           m_streamripper_active = true;
  83. +                   }
  84. +                   update = true;
  85. +               }
  86. +           }
  87. +       }
  88.         else if (CRCInput::isNumeric(msg) && !(m_playlist.empty()))
  89.         { //numeric zap or SMS zap
  90.             if (m_select_title_by_name)
  91. @@ -1730,7 +1760,18 @@ void CAudioPlayerGui::paintFoot()
  92.         if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO)
  93.             ::paintButtons(button_x, button_y, button_width, 4, AudioPlayerButtons[0], button_width, m_button_height);
  94.         else
  95. -           ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[6], button_width, m_button_height);
  96. +       {
  97. +           int b = 2;
  98. +           if (m_streamripper_available)
  99. +           {
  100. +               b = 3;
  101. +               if (m_streamripper_active)
  102. +                   AudioPlayerButtons[6][2].locale = LOCALE_AUDIOPLAYER_STREAMRIPPER_STOP;
  103. +               else
  104. +                   AudioPlayerButtons[6][2].locale = LOCALE_AUDIOPLAYER_STREAMRIPPER_START;
  105. +           }
  106. +           ::paintButtons(button_x, button_y, button_width, b, AudioPlayerButtons[6], button_width, m_button_height);
  107. +       }
  108.     }
  109.     else // key_level == 2
  110.     {
  111. @@ -2028,6 +2069,13 @@ void CAudioPlayerGui::stop()
  112.  
  113.     if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
  114.         CAudioPlayer::getInstance()->stop();
  115. +
  116. +   if (m_streamripper_active)
  117. +   {
  118. +       ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_AUDIOPLAYER_STREAMRIPPER_STOP, HINTBOX_MIN_WIDTH, 2);
  119. +       my_system(2, "streamripper.sh", "stop");
  120. +       m_streamripper_active = false;
  121. +   }
  122.  }
  123.  
  124.  void CAudioPlayerGui::pause()
  125. diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h
  126. index 068a412..ff464b0 100644
  127. --- a/src/gui/audioplayer.h
  128. +++ b/src/gui/audioplayer.h
  129. @@ -109,6 +109,8 @@ class CAudioPlayerGui : public CMenuTarget
  130.         bool        m_select_title_by_name;
  131.         bool        m_show_playlist;
  132.         bool        m_playlistHasChanged;
  133. +       bool        m_streamripper_available;
  134. +       bool        m_streamripper_active;
  135.  
  136.         CAudioPlayList  m_playlist;
  137.         CAudioPlayList  m_radiolist;
  138. diff --git a/src/system/locals.h b/src/system/locals.h
  139. index 83a40bd..491debd 100644
  140. --- a/src/system/locals.h
  141. +++ b/src/system/locals.h
  142. @@ -225,6 +225,8 @@ typedef enum
  143.     LOCALE_AUDIOPLAYER_SHOW_PLAYLIST,
  144.     LOCALE_AUDIOPLAYER_SHUFFLE,
  145.     LOCALE_AUDIOPLAYER_SPECTRUM,
  146. +   LOCALE_AUDIOPLAYER_STREAMRIPPER_START,
  147. +   LOCALE_AUDIOPLAYER_STREAMRIPPER_STOP,
  148.     LOCALE_AUDIOPLAYER_STOP,
  149.     LOCALE_AUDIOPLAYER_TITLE_ARTIST,
  150.     LOCALE_BLANK_SCREEN,
  151. diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h
  152. index ae019c6..105d8de 100644
  153. --- a/src/system/locals_intern.h
  154. +++ b/src/system/locals_intern.h
  155. @@ -225,6 +225,8 @@ const char * locale_real_names[] =
  156.     "audioplayer.show_playlist",
  157.     "audioplayer.shuffle",
  158.     "audioplayer.spectrum",
  159. +   "audioplayer.streamripper_start",
  160. +   "audioplayer.streamripper_stop",
  161.     "audioplayer.stop",
  162.     "audioplayer.title_artist",
  163.     "blank_screen",
  164.  
  165.  
  166.  
  167. /bin/streamripper.sh:
  168. #!/bin/sh
  169.  
  170. . /etc/init.d/globals
  171.  
  172. usage() {
  173.     echo "[${BASENAME}] Usage: $0 {start [url]|stop}"
  174. }
  175.  
  176. case $1 in
  177.     start)
  178.         if [ $# -ne 2 ]; then
  179.             usage
  180.             exit 1
  181.         fi
  182.         streamripper "${2}" -a -s -d "$(get_setting network_nfs_recordingdir)/streamripper/" &
  183.     ;;
  184.     stop)
  185.         killall streamripper
  186.     ;;
  187.     *)
  188.         usage
  189.     ;;
  190. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement