Esempio n. 1
0
        public TopList(libspotify.sp_toplisttype type, int region, Session session)
        {
            _session = session;
            try {
                ToplistType = type;
                toplistbrowse_complete_cb_delegate d = new toplistbrowse_complete_cb_delegate(toplistbrowse_complete);
                IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(d);

                _browsePtr = libspotify.sp_toplistbrowse_create(_session.GetSessionPtr(), type, region, IntPtr.Zero, callbackPtr, IntPtr.Zero);
            } catch (Exception ex) {
                throw ex;
            }
        }
Esempio n. 2
0
 private void StreamingError(IntPtr sessionPtr, libspotify.sp_error error)
 {
     _logger.ErrorFormat("Streaming error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 3
0
 private void LoggedIn(IntPtr sessionPtr, libspotify.sp_error error)
 {
     _loggedIn = true;
 }
Esempio n. 4
0
 private void ConnectionError(IntPtr sessionPtr, libspotify.sp_error error)
 {
     _logger.ErrorFormat("Connection error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 5
0
 private static void streaming_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
     Spotify.Log.ErrorFormat("Streaming error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 6
0
        static void Session_OnAudioDataArrived(libspotify.sp_audioformat fmt, byte[] obj, int num_frame)
        {
            if (audioStreamComplete)
                return;

            if (num_frame == 22050 || num_frame > 44100 || num_frame == 0)
            {
                //This isn't normal. It's trying to write some kind of silence at the end of the file.
                audioStreamComplete = true;
                staticfmt = fmt;
                FinishEncode();
                return;
            }

            buf.Write(obj, 0, obj.Length);
            if (frm != null)
            {
                frm.BeginInvoke((Delegate)new MethodInvoker(() => frm.SetStatus("Fetched " + buf.Length + " bytes")));
            }
        }
Esempio n. 7
0
        private static void logged_in(IntPtr sessionPtr, libspotify.sp_error error)
        {
            if (error == libspotify.sp_error.OK)
            {
                _isLoggedIn = true;
            }

            _loginError = error;

            if (Session.OnLoggedIn != null)
                Session.OnLoggedIn(sessionPtr);
        }
Esempio n. 8
0
        private static void SetupSoundOutput(libspotify.sp_audioformat format)
        {
            const int bitsPerSample = 16;
            int blockAlign = (format.channels * (bitsPerSample / 8));
            int averageBytesPerSecond = format.sample_rate * blockAlign;
            var waveFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, format.sample_rate, format.channels,
                                                           averageBytesPerSecond, blockAlign, bitsPerSample);

            soundBuffer = new BufferedWaveProvider(waveFormat);
            soundBuffer.BufferDuration = TimeSpan.FromSeconds(10);
            waveOut.Init(soundBuffer);
        }
Esempio n. 9
0
        private static void logged_in(IntPtr sessionPtr, libspotify.sp_error error)
        {
            if (error == libspotify.sp_error.OK) {
                Log.Debug("Logged in callback!");
                _isLoggedIn = true;

            }
            else
            {
                Log.Debug("Login issue in logged_in callback! " + error.ToString());
            }

            _loginError = error;

            if (Session.OnLoggedIn != null)
                Session.OnLoggedIn(sessionPtr);
        }
Esempio n. 10
0
 private static void connection_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
     Spotify.Log.ErrorFormat("Connection error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 11
0
 private void streaming_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
 }
Esempio n. 12
0
 private void connection_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
 }
Esempio n. 13
0
 private static void streaming_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
     Log.Error(Plugin.LOG_MODULE, "Streaming error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 14
0
 private static void connection_error(IntPtr sessionPtr, libspotify.sp_error error)
 {
     Log.Error(Plugin.LOG_MODULE, "Connection error: {0}", libspotify.sp_error_message(error));
 }
Esempio n. 15
0
        public static TopList BeginBrowse(libspotify.sp_toplisttype type, int region)
        {
            try {

                TopList t = new TopList();
                t.ToplistType = type;
                toplistbrowse_complete_cb_delegate d = new toplistbrowse_complete_cb_delegate(t.toplistbrowse_complete);
                IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(d);

                t._browsePtr = libspotify.sp_toplistbrowse_create(Session.GetSessionPtr(), type, region, IntPtr.Zero, callbackPtr, IntPtr.Zero);
                return t;

            } catch (Exception ex) {

                Log.Warning(Plugin.LOG_MODULE, "TopList.BeginBrowse() failed: {0}", ex.Message);
                return null;

            }
        }