我试图隐藏手柄(允许你拖动的滑块和滑块。
I'm currently using the nouislider javascript library现在正试图摆脱它。
到目前为止,我已尝试过以下方法:
Html:
<div class = 'slider' id='sliderinfo'> </div>
Javascript:
var slider = document.getElementById('sliderinfo');
var hider = slider.getElementsByClassName('.noUi-handle');
hider.remove();
//Separate way of hding
以及以下有些相关的SO response包括these two,而且我对隐藏或删除滑块的句柄没有任何回应。
感谢。
答案 0 :(得分:0)
我通过查看之前接受的答案的底部找到答案,虽然我不清楚。
public class MainActivity extends AppCompatActivity {
private Button btn;
private boolean playPause;
private MediaPlayer mediaPlayer;
private ProgressDialog progressDialog;
private boolean initialStage = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.audioStreamBtn);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
progressDialog = new ProgressDialog(this);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!playPause) {
btn.setText("Pause Streaming");
if (initialStage) {
new Player().execute("https://www.radioking.com/widgets/player/player.php?id=480&c=%23f39c12&ii=&p=1&pp=1&i=1&eq=1&po=1&t=1&a=1&f=big");
} else {
if (!mediaPlayer.isPlaying())
mediaPlayer.start();
}
playPause = true;
} else {
btn.setText("Launch Streaming");
if (mediaPlayer.isPlaying()) {
mediaPlayer.pause();
}
playPause = false;
}
}
});
}
@Override
protected void onPause() {
super.onPause();
if (mediaPlayer != null) {
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer = null;
}
}
class Player extends AsyncTask<String, Void, Boolean> {
@Override
protected Boolean doInBackground(String... strings) {
Boolean prepared = false;
try {
mediaPlayer.setDataSource(strings[0]);
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
initialStage = true;
playPause = false;
btn.setText("Launch Streaming");
mediaPlayer.stop();
mediaPlayer.reset();
}
});
mediaPlayer.prepare();
prepared = true;
} catch (Exception e) {
Log.e("MyAudioStreamingApp", e.getMessage());
prepared = false;
}
return prepared;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (progressDialog.isShowing()) {
progressDialog.cancel();
}
mediaPlayer.start();
initialStage = false;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog.setMessage("Buffering...");
progressDialog.show();
}
}
}