protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); m_baseurl = Intent.GetStringArrayListExtra("BASE_URL")[0]; m_upd = new TrackListUpdater(m_baseurl + "static/songlist.dat"); // Create your application here SetContentView(Resource.Layout.AddTrack); ListView trackToAdd = FindViewById <ListView>(Resource.Id.AddTrackList); m_tracks = new JavaList <Track>(); m_upd.Update(m_tracks); TrackListArrayAdapter adapter = new TrackListArrayAdapter(this, m_tracks); trackToAdd.Adapter = adapter; trackToAdd.ItemClick += (sender, e) => { IList <Track> original_tracklist = new JavaList <Track>(); TrackListUpdater original_upd = new TrackListUpdater(m_baseurl + "cgi-bin/getpage.cgi"); original_upd.Update(original_tracklist); Track t = m_tracks[e.Position]; original_tracklist.Add(t); original_upd.SendToServer(original_tracklist); this.Finish(); }; Button cancel = FindViewById <Button>(Resource.Id.CancelAddTrack); cancel.Click += (sender, e) => { this.Finish(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); m_br = new StreamAudio.SongDoneReceiver(); m_br.MainAct = this; m_tracks = new JavaList <Track>(); ListView trackList = FindViewById <ListView>(Resource.Id.TrackList); TrackListArrayAdapter adapter = new TrackListArrayAdapter(this, m_tracks); trackList.Adapter = adapter; trackList.ItemClick += async(sender, e) => { Show_Dialog diag = new Show_Dialog(this); Show_Dialog.MessageResult result = await diag.ShowDialog("", "Delete this track?", false, false, Show_Dialog.MessageResult.YES, Show_Dialog.MessageResult.NO); if (result == Show_Dialog.MessageResult.YES) { m_tracks.RemoveAt(e.Position); m_upd.SendToServer(m_tracks); RefreshTracklist(); bool wasPlaying = Services.StreamingBackgroundService.IsPlaying; HandleMusicAction(Services.StreamingBackgroundService.ActionStop, m_tracks); if (wasPlaying) { PlayIfSongAvailable(); } } }; Button addTrack = FindViewById <Button>(Resource.Id.AddTrack); addTrack.Click += (sender, e) => { Intent addTrackIntent = new Intent(this, typeof(AddTrackActivity)); addTrackIntent.PutStringArrayListExtra("BASE_URL", new string[] { m_baseurl }); StartActivity(addTrackIntent); }; Button play = FindViewById <Button>(Resource.Id.Play); play.Click += (sender, e) => PlayIfSongAvailable(); Button pause = FindViewById <Button>(Resource.Id.Pause); pause.Click += (sender, e) => HandleMusicAction(Services.StreamingBackgroundService.ActionPause, m_tracks); Button stop = FindViewById <Button>(Resource.Id.Stop); stop.Click += (sender, e) => HandleMusicAction(Services.StreamingBackgroundService.ActionStop, m_tracks); m_baseurl = "http://10.142.9.106/"; m_upd = new TrackListUpdater(m_baseurl + "cgi-bin/getpage.cgi"); m_upd.Update(m_tracks); RegisterReceiver(m_br, new IntentFilter("PlaylistSyncClientAndroid.Services.SONG_IS_DONE")); var timer = new System.Threading.Timer((e) => { string old_url = ""; if (m_tracks.Count > 0) { old_url = m_tracks[0].Url; } m_upd.Update(m_tracks); if (m_tracks.Count > 0) { if (old_url != m_tracks[0].Url && Services.StreamingBackgroundService.IsPlaying) { HandleMusicAction(Services.StreamingBackgroundService.ActionStop, m_tracks); PlayIfSongAvailable(); } } else { HandleMusicAction(Services.StreamingBackgroundService.ActionStop, m_tracks); } if (Services.StreamingBackgroundService.IsPlaying) { Track t = m_tracks[0]; t.NowPlaying = "▶ "; m_tracks[0] = t; } m_upd.SendToServer(m_tracks); RefreshTracklist(); }, null, 1000, 1000); }