protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _continueTimer = true; SetContentView(Resource.Layout.NowPlayingView); SetupToolbar("Now Playing"); play = FindViewById <Button>(Resource.Id.play); pause = FindViewById <Button>(Resource.Id.pause); mainLabel = FindViewById <TextView>(Resource.Id.label1); subLabel = FindViewById <TextView>(Resource.Id.label2); volume = FindViewById <SeekBar>(Resource.Id.volume_bar); webView = FindViewById <WebView>(Resource.Id.web_view); SetUpUI(); if (_service == null) { var intent = new Intent(ApplicationContext, typeof(RadioStationService)); var connection = new ServiceConnection <RadioStationServiceBinder>(binder => { if (binder != null) { _service = binder.Service; //_service.Playing += OnRadioStationPlaying; _service.StateChanged += OnRadioStationStateChanged; //_service.Error += OnRadioStationError; } else { //_service.Playing -= OnRadioStationPlaying; _service.StateChanged -= OnRadioStationStateChanged; //_service.Error -= OnRadioStationError; _service = null; } }); BindService(intent, connection, Bind.AutoCreate); } Action p = () => { while (_service == null) { Console.Out.WriteLine("waiting for service..."); } }; Task.Run(p).ContinueWith((arg) => OnPlayButtonClick()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.NowPlayingView); SetupToolbar("Now Playing"); play = FindViewById <Button>(Resource.Id.play); pause = FindViewById <Button>(Resource.Id.pause); webView = FindViewById <WebView>(Resource.Id.web_view); if (_service == null) { var intent = new Intent(ApplicationContext, typeof(RadioStationService)); var connection = new ServiceConnection <RadioStationServiceBinder>(binder => { if (binder != null) { _service = binder.Service; //_service.Playing += OnRadioStationPlaying; _service.StateChanged += OnRadioStationStateChanged; //_service.Error += OnRadioStationError; } else { //_service.Playing -= OnRadioStationPlaying; _service.StateChanged -= OnRadioStationStateChanged; //_service.Error -= OnRadioStationError; _service = null; } }); BindService(intent, connection, Bind.AutoCreate); } if (play != null) { play.Click += (sender, e) => OnPlayButtonClick(); } if (pause != null) { pause.Click += (sender, e) => OnPauseButtonClick(); } webView.Settings.JavaScriptEnabled = true; webView.SetWebViewClient(new MyWebViewClient()); webView.LoadUrl("http://godswayradio.com/wp-content/uploads/2018/08/scheduleV5.js"); }