Inheritance: IStorageItemExtraProperties
Beispiel #1
0
        public static async Task<string> track_love(MusicProperties id3)
        {
            try
            {
                string scrb_track_sig = "api_key" + Globalv.lfm_api_key + "artist" + id3.Artist + "methodtrack.love" + "sk" + Globalv.session_key + "track" + id3.Title + "0e6e780c3cfa3faedf0c58d5aa6de92f";

                //UTF8Encoding utf8e = new System.Text.UTF8Encoding();
                //scrb_track_sig = utf8e.GetString(utf8e.GetBytes(scrb_track_sig));

                HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm("MD5");
                CryptographicHash objHash = objAlgProv.CreateHash();
                IBuffer buffSig = CryptographicBuffer.ConvertStringToBinary(scrb_track_sig, BinaryStringEncoding.Utf8);
                objHash.Append(buffSig);
                IBuffer buffSighash = objHash.GetValueAndReset();

                scrb_track_sig = CryptographicBuffer.EncodeToHexString(buffSighash);

                HttpClient cli = new HttpClient();
                cli.DefaultRequestHeaders.ExpectContinue = false; //important
                string track_love = @"method=track.love&track=" + id3.Title + @"&artist=" + id3.Artist + @"&api_key=" + Globalv.lfm_api_key + @"&api_sig=" + scrb_track_sig + @"&sk=" + Globalv.session_key;

                cli.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
                HttpContent tscr = new StringContent(track_love);

                tscr.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");

                var loved_resp = await cli.PostAsync(new Uri("http://ws.audioscrobbler.com/2.0", UriKind.Absolute), tscr);
                return await loved_resp.Content.ReadAsStringAsync();
            }
            catch (Exception) { return null; }
        }
Beispiel #2
0
        public static async void track_updateNowPlaying(MusicProperties id3)
        {
            //try
            //{
                string updtrack_sig = "album" + id3.Album + "api_key" + Globalv.lfm_api_key + "artist" + id3.Artist + "methodtrack.updateNowPlaying" + "sk" + Globalv.session_key + "track" + id3.Title + "0e6e780c3cfa3faedf0c58d5aa6de92f";

                HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm("MD5");
                CryptographicHash objHash = objAlgProv.CreateHash();
                IBuffer buffSig = CryptographicBuffer.ConvertStringToBinary(updtrack_sig, BinaryStringEncoding.Utf8);
                objHash.Append(buffSig);
                IBuffer buffSighash = objHash.GetValueAndReset();

                updtrack_sig = CryptographicBuffer.EncodeToHexString(buffSighash);

                HttpClient cli = new HttpClient();
                cli.DefaultRequestHeaders.ExpectContinue = false; //important
                string track_updateNowPlaying = @"method=track.updateNowPlaying&track=" + id3.Title + @"&artist=" + id3.Artist + @"&album=" + id3.Album + @"&api_key=" + Globalv.lfm_api_key + @"&api_sig=" + updtrack_sig + @"&sk=" + Globalv.session_key;

                cli.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
                HttpContent tunp = new StringContent(track_updateNowPlaying);

                tunp.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");

                var upd_now_playing = await cli.PostAsync(new Uri("http://ws.audioscrobbler.com/2.0", UriKind.Absolute), tunp);
            //}
           // catch (Exception) { };
        }
Beispiel #3
0
 public Track(MusicProperties musicProp):this()
 {
     _musicProperties = musicProp;
     txtArtist.Text = _musicProperties.Artist;
     txtAlbum.Text = _musicProperties.Album;
     txtGenre.Text = _musicProperties.Duration.ToString();
     txtTrackName.Text = _musicProperties.Title;
 }
        public static AlbumModel NewAlbumModel(MusicProperties properties, int trackCount)
        {
            return new AlbumModel
            {
                Name = properties.Title,
                Artist = properties.AlbumArtist,
                SongsCount = trackCount,

            };
        }
Beispiel #5
0
 public async void initValue()
 {
     musicList.Clear();
     await getFiles(musicList, folder);
     STT = 0;
     musicProperties = null;
     stream = null;
     state = MediaState.STOP;
     pb = Playback.ORDER;
     rp = Repeat.ALL;
     nof = NumOfLoad.FIRST;
 }
 public static SongModel NewSongModel(MusicProperties properties, string path, int albumId)
 {
     return new SongModel
     {
         Name = properties.Title,
         Path = path,
         Artist = properties.Artist,
         TrackNumber = (int)properties.TrackNumber,
         Duration = properties.Duration.ToSongDuration(),
         AlbumId = albumId
     };
 }
Beispiel #7
0
        public LocalSong(MusicProperties musicProps)
        {
            Title = CleanText(musicProps.Title);
            AlbumName = CleanText(musicProps.Album);
            AlbumArtist = CleanText(musicProps.AlbumArtist);
            ArtistName = CleanText(musicProps.Artist);

            BitRate = (int)musicProps.Bitrate;
            Duration = musicProps.Duration;
            Genre = musicProps.Genre.FirstOrDefault();
            TrackNumber = (int)musicProps.TrackNumber;

            if (!string.IsNullOrEmpty(ArtistName) || !string.IsNullOrEmpty(AlbumArtist))
                ArtistId = Convert.ToBase64String(Encoding.UTF8.GetBytes((AlbumArtist ?? ArtistName).ToLower()));
            if (!string.IsNullOrEmpty(AlbumName))
                AlbumId = Convert.ToBase64String(Encoding.UTF8.GetBytes(AlbumName.ToLower()));
            if (!string.IsNullOrEmpty(Title))
                Id = Convert.ToBase64String(Encoding.UTF8.GetBytes(Title.ToLower())) + ArtistId + AlbumId;

            if (musicProps.Rating > 1)
                HeartState = HeartState.Like;
        }
Beispiel #8
0
 public static async Task<string> track_getInfo(MusicProperties id3)
 {
     try
     {
         HttpClient cli = new HttpClient();
         string get_track_info = @"http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=" + Globalv.lfm_api_key + @"&artist=" + id3.Artist + @"&track=" + id3.Title + @"&autocorrect=1";
         HttpResponseMessage track_info = await cli.GetAsync(get_track_info);
         return await track_info.Content.ReadAsStringAsync();
     }
     catch (Exception) { return null; }
 }
 protected override IEnumerable<string> ReadConductors(MusicProperties properties, IDictionary<string, object> customProperties)
 {
     return TryParseFromOneItem(base.ReadConductors(properties, customProperties));
 }
Beispiel #10
0
        public async static Task FillAudioProperties(PropertiesFlyoutAudio flyout, MusicProperties musicProps, StorageFile file)
        {
            try
            {
                if (!string.IsNullOrEmpty(musicProps.AlbumArtist))
                    flyout.Artist.Text = musicProps.AlbumArtist;
                else if (!string.IsNullOrEmpty(musicProps.Artist))
                    flyout.Artist.Text = musicProps.Artist;
                else
                {
                    string authors = await GetDocAuthors(file);
                    if (!string.IsNullOrEmpty(authors))
                        flyout.Artist.Text = authors;
                    else
                        flyout.HideArtist();
                }

                if (!string.IsNullOrEmpty(musicProps.Album))
                    flyout.Album.Text = musicProps.Album;
                else
                    flyout.HideAlbum();
                
                if (!string.IsNullOrEmpty(musicProps.Title))
                {
                    string track = "";
                    if (musicProps.TrackNumber > 0)
                        track += musicProps.TrackNumber.ToString("D02") + " ";
                    if (!string.IsNullOrEmpty(musicProps.Subtitle))
                        flyout.TrackTitle.Text = track + musicProps.Title + " - " + musicProps.Subtitle;
                    else
                        flyout.TrackTitle.Text = track + musicProps.Title;
                }
                else
                {
                    string docTitle = await GetDocTitle(file);
                    if (!string.IsNullOrEmpty(docTitle))
                        flyout.TrackTitle.Text = docTitle;
                    else
                        flyout.HideTrackTitle();
                }

                if (musicProps.Duration.TotalSeconds > 0)
                    flyout.Duration.Text = TimeSpan_ToString(musicProps.Duration);
                else
                    flyout.HideDuration();

                if (musicProps.Composers.Count >= 1)
                    flyout.Composers.Text += NameCreditsStr("", musicProps.Composers);
                else
                    flyout.HideComposers();

                if (musicProps.Conductors.Count >= 1)
                    flyout.Conductors.Text += NameCreditsStr("", musicProps.Conductors);
                else
                    flyout.HideConductors();

                if (musicProps.Writers.Count >= 1)
                    flyout.Writers.Text = NameCreditsStr("", musicProps.Writers);
                else
                    flyout.HideWriters();

                if (musicProps.Producers.Count >= 1)
                    flyout.Producers.Text = NameCreditsStr("", musicProps.Producers);
                else
                    flyout.HideProducers();

                if (!string.IsNullOrEmpty(musicProps.Publisher))
                    flyout.Publisher.Text = musicProps.Publisher;
                else
                    flyout.HidePublisher();

                if (musicProps.Genre.Count >= 1)
                    flyout.Genres.Text = NameCreditsStr("", musicProps.Genre);
                else
                    flyout.HideGenres();

                if (musicProps.Year > 0)
                    flyout.Year.Text = musicProps.Year.ToString();
                else
                    flyout.HideYear();

                if (musicProps.Rating > 0)
                {
                    uint starRating = (musicProps.Rating == 0) ? 0 : (uint)Math.Round((double)musicProps.Rating / 25.0) + 1;
                    flyout.Rating.Text = starRating.ToString() + "*";
                }
                else
                    flyout.HideRating();

                if (musicProps.Bitrate > 0)
                    flyout.Bitrate.Text = Util.NumberToString(musicProps.Bitrate, "bps");
                else
                    flyout.HideBitrate();
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }
        private static void GetMusicProperties(ICollection<StorageFileProperty> results, MusicProperties props)
        {
            var title = props.Title;
            var artist = props.Artist;
            var duration = props.Duration;
            var bitRate = props.Bitrate;

            if (!title.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "Title") == null)
                {
                    results.Add(new StorageFileProperty("Title", title));
                }
            }

            if (!artist.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "Artist") == null)
                {
                    results.Add(new StorageFileProperty("Artist", artist));
                }
            }

            if (duration != TimeSpan.FromSeconds(0))
            {
                var val = duration.ToString("G");
                if (!val.IsEmpty())
                {
                    if (results.FirstOrDefault(x => x.Name == "Duration") == null)
                    {
                        results.Add(new StorageFileProperty("Duration", val));
                    }
                }
            }

            if (bitRate != 0)
            {
                if (results.FirstOrDefault(x => x.Name == "Bitrate") == null)
                {
                    results.Add(new StorageFileProperty("Bitrate", bitRate));
                }
            }
        }
 //play
 private async void MediaPlay(PlaylistItem item)
 {
     if (item == null)
     {
         MediaElementObject.Play();
     }
     //this else block triggers when a displayed playlist item is opened explicitely 
     else
     {
         NowPlayingItem = CurrentPlaylist.Items.Where(x => x == item).FirstOrDefault();               
         Messenger.Default.Send(new NotificationMessage<string>("RequestDisplayed", "RequestDisplayed"));
     }
     CurrentPlaylist.Items.Select(x => { x.IsPlayingNow = false; return x; }).ToList();
     NowPlayingItem.IsPlayingNow = true;
     properties = await TryGetProperties(NowPlayingFile);
     MediaElementObject.SeekCompleted += MediaElementObject_SeekCompleted;
 }
 protected Track CreateTrack(MusicProperties musicProps, Tag tag, string audioUrl)
 {
     return new Track
     {
         Title = CleanText(tag.Title),
         AlbumTitle = CleanText(tag.Album),
         AlbumArtist = CleanText(tag.FirstAlbumArtist) ?? CleanText(tag.FirstPerformer),
         Artists = CleanText(tag.JoinedPerformers),
         DisplayArtist = CleanText(tag.FirstPerformer),
         Bitrate = (int)musicProps.Bitrate,
         Duration = musicProps.Duration,
         Genres = tag.JoinedGenres,
         Publisher = musicProps.Publisher,
         Lyrics = tag.Lyrics,
         Comment = tag.Comment,
         Conductors = tag.Conductor,
         Composers = tag.JoinedComposers,
         TrackNumber = tag.Track,
         TrackCount = tag.TrackCount,
         DiscCount = tag.DiscCount,
         DiscNumber = tag.Disc,
         Year = tag.Year,
         LikeState = musicProps.Rating > 0 ? LikeState.Like : LikeState.None,
         AudioLocalUri = audioUrl,
         Type = TrackType.Local
     };
 }
Beispiel #14
0
 public async void getProperties_accessStream(int nOfSTT)
 {
     var audioFile = await folder.GetFileAsync(musicList[nOfSTT].Name);
     musicProperties = await audioFile.Properties.GetMusicPropertiesAsync();
     stream = await audioFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
 }
 protected Track CreateTrack(MusicProperties musicProps, string audioUrl)
 {
     return new Track
     {
         Title = CleanText(musicProps.Title),
         AlbumTitle = CleanText(musicProps.Album),
         AlbumArtist = CleanText(musicProps.AlbumArtist) ?? CleanText(musicProps.Artist),
         Artists = CleanText(musicProps.Artist),
         DisplayArtist = CleanText(musicProps.Artist),
         Bitrate = (int)musicProps.Bitrate,
         Duration = musicProps.Duration,
         Genres = string.Join(";", musicProps.Genre),
         Publisher = musicProps.Publisher,
         Conductors = string.Join(";", musicProps.Conductors),
         Composers = string.Join(";", musicProps.Composers),
         TrackNumber = musicProps.TrackNumber,
         Year = musicProps.Year,
         LikeState = musicProps.Rating > 0 ? LikeState.Like : LikeState.None,
         AudioLocalUri = audioUrl,
         Type = TrackType.Local
     };
 }
        async void InitializeAllJoyn(){
            Debug.UseOSLogging(true);
            Debug.SetDebugLevel("ALLJOYN", 7);

            _bus = new BusAttachment(APPLICATION_NAME, true, 4);
            string connectSpec = "null:";
            _bus.Start();

            try
            {
                _mp3Reader = new MP3Reader();

                if (_streamingSong != null)
                {
                    _streamingSongBasicProperties = await _streamingSong.GetBasicPropertiesAsync();
                    if (_streamingSongBasicProperties != null)
                    {
                        _streamingSongMusicProperties = await _streamingSong.Properties.GetMusicPropertiesAsync();
                        if (_streamingSongMusicProperties != null)
                        {
                            await _mp3Reader.SetFileAsync(_streamingSong);

                            _bus.ConnectAsync(connectSpec).AsTask().Wait();
                            _connected = true;

                            _listeners = new Listeners(_bus, this);
                            _bus.RegisterBusListener(_listeners);
                            _mediaSource = new MediaSource(_bus);
                            _audioStream = new AudioStream(_bus, "mp3", _mp3Reader, 100, 1000);
                            _mediaSource.AddStream(_audioStream);

                            /* Register MediaServer bus object */ 
                            _bus.RegisterBusObject(_mediaSource.MediaSourceBusObject); 
                             /* Request a well known name */ 
                            _bus.RequestName(MediaServerName, (int)(RequestNameType.DBUS_NAME_REPLACE_EXISTING | RequestNameType.DBUS_NAME_DO_NOT_QUEUE));

                            /* Advertise name */
                            _bus.AdvertiseName(MediaServerName, TransportMaskType.TRANSPORT_ANY);
   
                            /* Bind a session for incoming client connections */
                            SessionOpts opts = new SessionOpts(TrafficType.TRAFFIC_MESSAGES, true, ProximityType.PROXIMITY_ANY, TransportMaskType.TRANSPORT_ANY);
                            ushort[] portOut = new ushort[1];
                            _bus.BindSessionPort(SESSION_PORT, portOut, opts, _listeners);
                        }
                    }
                }
            } catch (Exception ex)
            {
                string message = ex.Message;
                QStatus status = AllJoynException.GetErrorCode(ex.HResult);
                string errMsg = AllJoynException.GetErrorMessage(ex.HResult);
            }
        }
 protected override void ApplyGenre(MusicProperties properties, IDictionary<string, object> customProperties, IEnumerable<string> genre)
 {
     ApplyAsOneItem(properties.Genre, genre);
 }
 protected override void ApplyConductors(MusicProperties properties, IDictionary<string, object> customProperties, IEnumerable<string> conductors)
 {
     ApplyAsOneItem(properties.Conductors, conductors);
 }
Beispiel #19
0
        private async void Collection_Click_1(object sender, RoutedEventArgs e)
        {
            if (EnsureUnsnapped())
            {
                FileOpenPicker pkr = new FileOpenPicker();
                pkr.ViewMode = PickerViewMode.List;
                pkr.SuggestedStartLocation = PickerLocationId.MusicLibrary;
                pkr.FileTypeFilter.Add(".mp3");

                StorageFile file = await pkr.PickSingleFileAsync();
                if (null != file)
                {
                    
                    var strm = await file.OpenAsync(FileAccessMode.Read);
                    Playlist.NowPlaying.Clear();
                    App.GlobalAudioElement.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.BackgroundCapableMedia;
                    //mediaPlayer.SetSource(strm, file.ContentType);
                    App.GlobalAudioElement.SetSource(strm, file.ContentType);
                    App.GlobalAudioElement.Play();
                    //timelineSlider.Maximum = App.GlobalAudioElement.NaturalDuration.TimeSpan.TotalMilliseconds;
                    isScrobbledOnce = false;
                    
                    MediaControl.IsPlaying = true;
                    //PlayPauseBtn.Content = "";

                    id3 = await file.Properties.GetMusicPropertiesAsync();
                    SongTitle.Text = id3.Title;
                    Artist.Text = id3.Artist;                    

                    Playlist.NowPlaying.Add(id3);
                    Lastfm.track_updateNowPlaying(id3);

                    string xmlinfo = await Lastfm.track_getInfo(id3);
                    string artistinfo = await Lastfm.artist_getInfo(id3.Artist);
                    try
                    {
                        using (XmlReader rd = XmlReader.Create(new StringReader(xmlinfo)))
                        {
                            rd.ReadToFollowing("name");
                            TitleInfoTbx.Text = rd.ReadElementContentAsString();
                            rd.ReadToFollowing("artist");
                            rd.ReadToDescendant("name");
                            SubtitleInfoTbx.Text = rd.ReadElementContentAsString();                            
                        }
                        
                        using(XmlReader rd=XmlReader.Create(new StringReader(xmlinfo)))
                        {
                            rd.ReadToFollowing("image");
                            rd.ReadToNextSibling("image");
                            rd.ReadToNextSibling("image");
                            Uri src = new Uri(rd.ReadElementContentAsString(), UriKind.Absolute);
                            AlbumArtHolder.Source = new BitmapImage(src);                            
                        }
                        using (XmlReader rd = XmlReader.Create(new StringReader(xmlinfo)))
                        {
                            rd.ReadToFollowing("wiki");
                            rd.ReadToDescendant("summary");
                            SummaryInfoTbx.Text = rd.ReadElementContentAsString();
                        }
                    }
                    catch (Exception) 
                    {
                        try
                        {
                            using (XmlReader rd = XmlReader.Create(new StringReader(artistinfo)))
                            {
                                rd.ReadToFollowing("image");
                                rd.ReadToNextSibling("image");
                                rd.ReadToNextSibling("image");
                                Uri src = new Uri(rd.ReadElementContentAsString(), UriKind.Absolute);
                                AlbumArtHolder.Source = new BitmapImage(src);                        
                            }
                        }
                        catch (Exception) { AlbumArtHolder.Source = null; }
                    }
                    //prepare for scrobble
                    TimelineMarker tlm = new TimelineMarker();
                    tlm.Time = new System.TimeSpan(0,0,(int)id3.Duration.TotalSeconds/2);
                    App.GlobalAudioElement.Markers.Clear();
                    App.GlobalAudioElement.Markers.Add(tlm);
                    if (id3.Duration > new System.TimeSpan(0, 0, 30))
                    {
                        await Lastfm.track_scrobble(id3);
                        isScrobbledOnce = true;

                        //App.GlobalAudioElement.MarkerReached += mediaPlayer_MarkerReached_scrobble; //scrobble
                    }
                }
                else
                { return; }
            }
        }
Beispiel #20
0
        private void pageRoot_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (MediaControl.IsPlaying)
            {
                BG1.Begin();
                id3 = Playlist.NowPlaying[0];
                SongTitle.Text = id3.Title;
                Artist.Text = id3.Artist;
                
            }
            else
            {
                SongTitle.Text = "Play a song now!";
                Artist.Text = "Swipe up from bottom for more options!";
            }

            if (Security._vault.RetrieveAll().Count != 0)
            {
                Scrobble.SetValue(AutomationProperties.NameProperty, "Last.fm Signout");
                PasswordCredential rt = Security._vault.Retrieve("Session Key", "user");
                rt.RetrievePassword();
                Globalv.session_key = rt.Password;
            }

            /*
            if (Globalv.session_key != null)
                LoginBtn.Content = "Logoff";
            else
                LoginBtn.Content = "Login";
             */ 


        }