Esempio n. 1
0
        public Player(Playlist playlist)
            : base(IntPtr.Zero)
        {
            this.playlist = playlist;
            playlist.SongReady += new Playlist.SongReadyHandler (OnSongReady);

            Raw = player_new ();
            playing = false;
            new_song_cb = new SignalUtils.SignalDelegate (OnNewSong);
            end_song_cb = new SignalUtils.SignalDelegate (OnEndSong);
            error_cb = new SignalUtils.SignalDelegateStr (OnError);
            SignalUtils.SignalConnect (Raw, "new-song", new_song_cb);
            SignalUtils.SignalConnect (Raw, "end-song", end_song_cb);
            SignalUtils.SignalConnect (Raw, "error", error_cb);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            // Search for existing DBus server
            IDBusPlayer dbus_core = DetectInstanceAndDbus();
            HandleDbusCommands (dbus_core, args);

            // If we are the only instance, start a new DBus server
            Console.WriteLine("Starting new Last Exit server");
            try {
                dbus_remote = new DBusRemote();
                dbus_player = new DBusPlayer();
                if (dbus_player != null) {
                    dbus_remote.RegisterObject(dbus_player, "Player");
                }
            } catch (Exception e) {
                Console.Error.WriteLine (e);
            }

            string username;
            string password;

            try {
                Driver.SetProcessName ("last-exit");
            } catch {} // Ignore exception if fail (not needed to run)

            Catalog.Init("last-exit", Defines.LOCALE_DIR);
            Application.Init("last-exit", ref args);

            StockIcons.Initialize ();

            SetDefaultWindowIcon ();

            config = new Config ();

            if (config.FirstRun) {
                FirstRunDialog frd = new FirstRunDialog ();

                int response = frd.Run ();

                frd.Visible = false;

                switch (response) {
                    case (int) ResponseType.Reject:
                        Gtk.Application.Quit();
                        Environment.Exit (0);
                        break;

                    case (int) ResponseType.Ok:
                        config.Username = frd.Username;
                        config.Password = frd.Password;
                        break;

                    default:
                        break;
                }

                frd.Destroy ();
                config.FirstRun = false;
            }

            Driver.SetUpConfigDirectory ();

            //TrayIcon.ShowNotifications = config.ShowNotifications;

            username = config.Username;
            password = config.Password;

            // We must get a reference to the JIT's SEGV handler because
            // GStreamer will set its own and not restore the previous, which
            // will cause what should be NullReferenceExceptions to be unhandled
            // segfaults for the duration of the instance, as the JIT is powerless!
            // FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=391777
            IntPtr mono_jit_segv_handler = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
            sigaction(Mono.Unix.Native.Signum.SIGSEGV, IntPtr.Zero, mono_jit_segv_handler);

            connection = new FMConnection (username, password);
            connection.Handshake ();

            Scrobbler scrobbler = new Scrobbler (username, password);
            Playlist playlist = new Playlist (connection);

            player = new Player (playlist);
            player.SongEnded += new Player.NewSongHandler (scrobbler.Scrobble);
            player.NewSong += new Player.NewSongHandler (scrobbler.NowPlayingNotification);

            actions = new Actions ();
            player_window = new PlayerWindow ();

            if (args.Length > 0) {
                player_window.InitialStation = args[0];
            }

            player_window.Run ();

            Application.Run ();

            // Reset the SEGV handle to that of the JIT again (SIGH!)
            sigaction(Mono.Unix.Native.Signum.SIGSEGV, mono_jit_segv_handler, IntPtr.Zero);
            System.Runtime.InteropServices.Marshal.FreeHGlobal(mono_jit_segv_handler);
        }
Esempio n. 3
0
        private void OnNewPlaylistReady(Playlist playlist)
        {
            Console.WriteLine ("PlayerWindow: Playlist ready");
            if (toggle_play_button.Active == false) {
                internal_toggle = true;
                toggle_play_button.Active = true;
            }

            Console.WriteLine ("PlayerWindow: Player is playing? "+ Driver.player.Playing);
            if (Driver.player.Playing == false) {
                Driver.player.Play ();
            }
        }