Last active
          January 5, 2021 16:11 
        
      - 
      
- 
        Save shhyou/606fea1e9d82149f681c4ff7d7d42e84 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| VOLUME=${VOLUME:-0.05} | |
| music_rec="/Volumes/ramdisk/music-rec" | |
| record_file="$music_rec/`pwd | sed -e \"s:$HOME::; s:/Uninterpreted::; s:/:_:g\"`-last_play.txt" | |
| echo Volume filter is $VOLUME. | |
| echo Using record file $record_file. | |
| if [ "$1" == "--reset" ]; then | |
| echo>"$record_file" | |
| elif [ "$1" != "" ]; then | |
| echo $1>"$record_file" | |
| fi | |
| if [ -f "$record_file" ]; then | |
| to_search=$(cat "$record_file" | sed -e 's:@$::') | |
| echo Looking for \'$to_search\'. | |
| else | |
| echo Record file does not exist. | |
| to_search="" | |
| fi | |
| if [ "$to_search" != "" ]; then | |
| flag=0 | |
| else | |
| flag=1 | |
| fi | |
| finished=1 | |
| while read fWithH; do | |
| f=$(printf "%s" "$fWithH" | sed -e 's:@$::') | |
| echo | |
| echo $f; | |
| if [ $flag -eq 0 ]; then | |
| if [ "$f" != "$to_search" ]; then | |
| continue | |
| else | |
| flag=1 | |
| fi; | |
| fi | |
| echo $f>"$record_file" | |
| ffplay -af "volume=$VOLUME" -autoexit -nodisp -hide_banner "$f" 2>&1 | |
| if [ $? -ne 0 ]; then | |
| finished=0; | |
| break; | |
| fi; | |
| done | |
| if [ $finished -ne 0 ]; then | |
| rm "$record_file" | |
| fi | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| FFPLAY_PID=`ps -o pid,command | grep '[f]fplay' | awk '{ print $1 }'` | |
| if [[ "$FFPLAY_PID" -ne "" ]]; then | |
| echo starting $FFPLAY_PID | |
| ps $FFPLAY_PID | |
| kill -CONT $FFPLAY_PID | |
| else | |
| echo ffplay not found | |
| fi | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| music_rec="DEFAULT-PATH/music-rec" | |
| record_file="$music_rec/`pwd | sed -s \"s:$HOME::; s:/Uninterpreted::; s:/:_:g\"`-last_play.txt" | |
| echo $record_file | |
| if [ "$1" == "--reset" ]; then | |
| echo>"$record_file" | |
| elif [ "$1" != "" ]; then | |
| echo $1>"$record_file" | |
| fi | |
| to_search=`cat "$record_file"` | |
| if [ "$to_search" != "" ]; then | |
| flag=0 | |
| else | |
| flag=1 | |
| fi | |
| finished=1 | |
| for f in *.mp3; do | |
| if [ $flag -eq 0 ]; then | |
| if [ "$f" != "$to_search" ]; then | |
| continue | |
| else | |
| flag=1 | |
| fi; | |
| fi | |
| echo $f>"$record_file" | |
| ffplay -af "volume=0.1" -autoexit -nodisp "$f" | |
| if [ $? -ne 0 ]; then | |
| finished=0; | |
| break; | |
| fi; | |
| done | |
| if [ $finished -ne 0 ]; then | |
| rm "$record_file" | |
| fi | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env python3 | |
| import os | |
| import time | |
| import random | |
| PLAY_COMMAND = "ffplay -autoexit -nodisp -af \"volume=0.08\" \"%s\"" | |
| def random_play(track_list): | |
| while True: | |
| k = random.randint(0, len(track_list)-1) | |
| return_code = os.system(PLAY_COMMAND % track_list[k]) | |
| if return_code != 0: | |
| break | |
| time.sleep(3) | |
| if __name__ == "__main__": | |
| fs = [f for f in os.listdir(".") if f[-4:] == ".mp3"] | |
| random_play(fs) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| FFPLAY_PID=`ps -o pid,command | grep '[f]fplay' | awk '{ print $1 }'` | |
| if [[ "$FFPLAY_PID" -ne "" ]]; then | |
| echo pausing $FFPLAY_PID | |
| ps $FFPLAY_PID | |
| kill -STOP $FFPLAY_PID | |
| else | |
| echo ffplay not found | |
| fi | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment