userdoc:tt_external_moh_source

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
userdoc:tt_external_moh_source [2014/02/18 08:53]
abelbeck [Internet Streaming]
userdoc:tt_external_moh_source [2014/02/19 06:43]
abelbeck [Internet Streaming]
Line 85: Line 85:
 ===== Internet Streaming ===== ===== Internet Streaming =====
  
-You can also easily stream music over the Internet/LAN for MOH with sox:+You can also easily stream music over the Internet/LAN for MOH with sox.  The ''ast-stream-mp3'' script directly supports MP3 streams or indirectly MP3 streams via a ''.pls'' playlist.
  
 Create file: ''/mnt/kd/bin/ast-stream-mp3'' Create file: ''/mnt/kd/bin/ast-stream-mp3''
Line 91: Line 91:
   #!/bin/sh   #!/bin/sh
      
-  wget -q -O - ${1| sox -t mp3 - -t raw -r 8000 -c 1 -+  # Set VOLUME variable to linearly multiply the volume by a number. 
 +  # Value: "0.8" is 80%, "1.2" is 120%, default is "1.0" when not defined. 
 +  VOLUME="0.8" 
 +   
 +  URL="$1" 
 +  if [ "$URL" != "${URL%.pls}" ]; then 
 +    PLAYLIST="$(wget -q -O - $URL)" 
 +    if [ $? -ne 0 ]; then 
 +      sleep 10 
 +      exit 1 
 +    fi 
 +    URL="$(echo "$PLAYLIST" | sed -n -r -e 's/^File[0-9]*=(.*)$/\1/p' | head -n1)" 
 +    if [ -z "$URL" ]; then 
 +      sleep 10 
 +      exit 1 
 +    fi 
 +  fi 
 +   
 +  if [ -n "$VOLUME" ]; then 
 +    FOPTS="-v $VOLUME" 
 +  else 
 +    FOPTS="" 
 +  fi 
 +   
 +  wget -q -O - $URL | sox -t mp3 $FOPTS - -t raw -r 8000 -c 1 -
  
 Make the "''/mnt/kd/bin/ast-stream-mp3''" file executable: Make the "''/mnt/kd/bin/ast-stream-mp3''" file executable:
Line 103: Line 127:
   application=/mnt/kd/bin/ast-stream-mp3 http://wnycfm.streamguys.com:80/   application=/mnt/kd/bin/ast-stream-mp3 http://wnycfm.streamguys.com:80/
  
-!!Note ->!! The example URL shown above is only an example, and does not imply it is legal to use for MOH in your country.  Choose a URL carefully.+!!Note ->!! The example MP3 source URL shown above is only an example, and does not imply it is legal to use for MOH in your country.  Choose a MP3 source URL carefully.
  
 Reload the Asterisk MoH module: Reload the Asterisk MoH module:
  • userdoc/tt_external_moh_source.txt
  • Last modified: 2014/02/19 06:44
  • by abelbeck