void Initialize(TitleDatabase database, MainActivity activity) { this.activity = activity; view = new PlayerView(this, database, activity); task = new CorePlayer(this); headset_status_receiver = new HeadphoneStatusReceiver(this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); title_database = new TitleDatabase(this); player = new Player(title_database, this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); title_database = new TitleDatabase (this); player = new Player(title_database, this); }
public PlayerView(Player player, TitleDatabase database, MainActivity activity) { this.player = player; this.database = database; this.activity = activity; this.load_button = activity.FindViewById<Button>(Resource.Id.SelectButton); this.play_button = activity.FindViewById<Button>(Resource.Id.PlayButton); this.stop_button = activity.FindViewById<Button>(Resource.Id.StopButton); this.rescan_button = activity.FindViewById<Button>(Resource.Id.RescanButton); this.seekbar = activity.FindViewById<SeekBar>(Resource.Id.SongSeekbar); this.title_text_view = activity.FindViewById<TextView>(Resource.Id.SongTitleTextView); this.timeline_text_view = activity.FindViewById<TextView>(Resource.Id.TimelineTextView); PlayerEnabled = false; var ifs = IsolatedStorageFile.GetUserStoreForApplication (); if (!ifs.FileExists ("songdirs.txt")) load_button.Enabled = false; load_button.Click += delegate { var db = new AlertDialog.Builder (activity); db.SetTitle ("Select Music Folder"); List<string> dirlist = new List<string> (); if (ifs.FileExists ("history.txt")) dirlist.Add (from_history_tag); using (var sr = new StreamReader (ifs.OpenFile ("songdirs.txt", FileMode.Open))) foreach (var s in sr.ReadToEnd ().Split ('\n')) if (!String.IsNullOrEmpty (s)) dirlist.Add (s); var dirs = dirlist.ToArray (); db.SetItems (dirs, delegate (object o, DialogClickEventArgs e) { string dir = dirs [(int) e.Which]; ProcessFileSelectionDialog (dir, delegate (string mus) { player.SelectFile (mus); player.Play (); }); }); var dlg = db.Show (); }; play_button.Click += delegate { try { if (player.IsPlaying) { player.Pause (); } else { player.Play (); } } catch (Exception ex) { play_button.Text = ex.Message; } }; stop_button.Click += delegate { player.Stop (); }; rescan_button.Click += delegate { var db = new AlertDialog.Builder(activity); db.SetMessage ("Scan music directories. This operation takes a while."); db.SetPositiveButton ("OK", delegate { CreateSongDirectoryList (); load_button.Enabled = true; }); db.SetCancelable (true); db.SetNegativeButton ("Cancel", delegate {}); db.Show (); }; }
void Initialize(TitleDatabase database, MainActivity activity) { this.activity = activity; view = new PlayerView (this, database, activity); task = new CorePlayer (this); headset_status_receiver = new HeadphoneStatusReceiver (this); }
public Player(TitleDatabase database, MainActivity activity) { Initialize (database, activity); }
public PlayerView(Player player, TitleDatabase database, MainActivity activity) { this.player = player; this.database = database; this.activity = activity; this.load_button = activity.FindViewById <Button>(Resource.Id.SelectButton); this.play_button = activity.FindViewById <Button>(Resource.Id.PlayButton); this.stop_button = activity.FindViewById <Button>(Resource.Id.StopButton); this.rescan_button = activity.FindViewById <Button>(Resource.Id.RescanButton); this.seekbar = activity.FindViewById <SeekBar>(Resource.Id.SongSeekbar); this.title_text_view = activity.FindViewById <TextView>(Resource.Id.SongTitleTextView); this.timeline_text_view = activity.FindViewById <TextView>(Resource.Id.TimelineTextView); PlayerEnabled = false; var ifs = IsolatedStorageFile.GetUserStoreForApplication(); if (!ifs.FileExists("songdirs.txt")) { load_button.Enabled = false; } load_button.Click += delegate { var db = new AlertDialog.Builder(activity); db.SetTitle("Select Music Folder"); List <string> dirlist = new List <string> (); if (ifs.FileExists("history.txt")) { dirlist.Add(from_history_tag); } using (var sr = new StreamReader(ifs.OpenFile("songdirs.txt", FileMode.Open))) foreach (var s in sr.ReadToEnd().Split('\n')) { if (!String.IsNullOrEmpty(s)) { dirlist.Add(s); } } var dirs = dirlist.ToArray(); db.SetItems(dirs, delegate(object o, DialogClickEventArgs e) { string dir = dirs [(int)e.Which]; ProcessFileSelectionDialog(dir, delegate(string mus) { player.SelectFile(mus); player.Play(); }); }); var dlg = db.Show(); }; play_button.Click += delegate { try { if (player.IsPlaying) { player.Pause(); } else { player.Play(); } } catch (Exception ex) { play_button.Text = ex.Message; } }; stop_button.Click += delegate { player.Stop(); }; rescan_button.Click += delegate { var db = new AlertDialog.Builder(activity); db.SetMessage("Scan music directories. This operation takes a while."); db.SetPositiveButton("OK", delegate { CreateSongDirectoryList(); load_button.Enabled = true; }); db.SetCancelable(true); db.SetNegativeButton("Cancel", delegate {}); db.Show(); }; }
public Player(TitleDatabase database, MainActivity activity) { Initialize(database, activity); }