MCPcopy Create free account
hub / github.com/ActiveState/code / change_sound

Function change_sound

recipes/JavaScript/578517_Music_player/recipe-578517.js:1090–1170  ·  view source on GitHub ↗

* * * MEDIA CONTROLS * * *

(n)

Source from the content-addressed store, hash-verified

1088***********************/
1089
1090function change_sound(n)
1091{
1092 g_enable=false;
1093 var s="";
1094 var s_title="";
1095 var s_file="";
1096 var r=0;
1097 var b_explicit=false;
1098
1099 r=Math.random()*a_songs.length;
1100 r=parseInt(r);
1101 var e=document.getElementById("chgsnd");
1102
1103 if (n>=0)
1104 {
1105 r=n;
1106 }
1107
1108 if (g_sequential)
1109 {
1110 g_current_song++;
1111 if (g_current_song>=a_songs.length) g_current_song=0;
1112 r=g_current_song;
1113 }
1114
1115 s=a_songs[r];
1116 s_file=s;
1117 // Remove the extension.
1118 s=remove_ext(s);
1119 s_title=convert_to_song_and_artist(s);
1120 s=convert_string(s);
1121 if (string_ends_in(s,"EXPLICIT")) b_explicit=true;
1122 if (s.indexOf("BITCH")>=0) b_explicit=true;
1123 if (s.indexOf("RAPE")>=0) b_explicit=true;
1124 if (s.indexOf("FUCK")>=0) b_explicit=true;
1125 if (s.indexOf("JESUS")>=0) b_explicit=true;
1126 if (s.indexOf("DAMN")>=0) b_explicit=true;
1127 if (s.indexOf("DEVIL")>=0) b_explicit=true;
1128 if (s.indexOf("DEMON")>=0) b_explicit=true;
1129 if (s.indexOf("SATAN")>=0) b_explicit=true;
1130 if (s.indexOf("HELL")>=0) b_explicit=true;
1131 if (s.indexOf("GOD")>=0) b_explicit=true;
1132
1133 if (b_explicit==true)
1134 {
1135 if (g_user_choice==true)
1136 {
1137 var n=confirm("This song is explicit.\nPlay it anyway ?","Confirm","Confirm");
1138 if (n==false) return;
1139 }
1140 else
1141 {
1142 return;
1143 }
1144 }
1145
1146 g_previous_song=g_current_song;
1147 g_current_song=r;

Callers 3

do_searchFunction · 0.85
do_link_clickFunction · 0.85
play_next_soundFunction · 0.85

Calls 10

remove_extFunction · 0.85
convert_stringFunction · 0.85
string_ends_inFunction · 0.85
confirmFunction · 0.85
smart_stop_playerFunction · 0.85
volume_getFunction · 0.85
search_item_table_rowFunction · 0.85
update_recently_playedFunction · 0.85
randomMethod · 0.45

Tested by

no test coverage detected