Esempio n. 1
0
        private static MediaQueueItem buildMediaQueueItem(DemoUtil.Sample sample)
        {
            MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MediaTypeMovie);

            movieMetadata.PutString(MediaMetadata.KeyTitle, sample.name);
            MediaInfo mediaInfo = new MediaInfo.Builder(sample.uri)
                                  .SetStreamType(MediaInfo.StreamTypeBuffered).SetContentType(sample.mimeType)
                                  .SetMetadata(movieMetadata).Build();

            return(new MediaQueueItem.Builder(mediaInfo).Build());
        }
Esempio n. 2
0
        public void SetSongUri()
        {
            string songUri =
                "http://freemusicarchive.org/music/download/4cc908b1d8b19b9bdfeb87f9f9fd5086b66258b8";

            if (googleApiClient != null && mediaPlayer != null)
            {
                try
                {
                    //currentSongInfo = info;
                    var metadata = new MediaMetadata(MediaMetadata.MediaTypeMusicTrack);
                    metadata.PutString(MediaMetadata.KeyArtist, "Deadlines");
                    metadata.PutString(MediaMetadata.KeyAlbumTitle, "Magical Inertia");
                    metadata.PutString(MediaMetadata.KeyTitle, "The Wire");
                    var androidUri =
                        Android.Net.Uri.Parse("http://freemusicarchive.org/file/images/albums/Deadlines_-_Magical_Inertia_-_20150407163159222.jpg?width=290&height=290");
                    var webImage = new Android.Gms.Common.Images.WebImage(androidUri);
                    metadata.AddImage(webImage);

                    MediaInfo mediaInfo =
                        new MediaInfo.Builder(songUri).SetContentType("audio/mp3")
                        .SetMetadata(metadata)
                        .SetStreamType(MediaInfo.StreamTypeBuffered)
                        .Build();

                    mediaPlayer.Load(googleApiClient, mediaInfo, true, 0)
                    .SetResultCallback <RemoteMediaPlayer.IMediaChannelResult> (r => {
                        Console.WriteLine("Loaded");
                    });
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception while sending a song. Exception : " + e.Message);
                }
            }
        }
Esempio n. 3
0
        public void SetSongUri()
        {
            string songUri =
                "http://freemusicarchive.org/music/download/4cc908b1d8b19b9bdfeb87f9f9fd5086b66258b8";
            
            if (googleApiClient != null && mediaPlayer != null)
            {
                try
                {
                    //currentSongInfo = info;
                    var metadata = new MediaMetadata(MediaMetadata.MediaTypeMusicTrack);
                    metadata.PutString(MediaMetadata.KeyArtist, "Deadlines");
                    metadata.PutString(MediaMetadata.KeyAlbumTitle, "Magical Inertia");
                    metadata.PutString(MediaMetadata.KeyTitle, "The Wire");
                    var androidUri =
                        Android.Net.Uri.Parse("http://freemusicarchive.org/file/images/albums/Deadlines_-_Magical_Inertia_-_20150407163159222.jpg?width=290&height=290");
                    var webImage = new Android.Gms.Common.Images.WebImage(androidUri);
                    metadata.AddImage(webImage);

                    MediaInfo mediaInfo =
                        new MediaInfo.Builder(songUri).SetContentType("audio/mp3")
                            .SetMetadata(metadata)
                            .SetStreamType(MediaInfo.StreamTypeBuffered)
                            .Build();

                    mediaPlayer.Load(googleApiClient, mediaInfo, true, 0)
                        .SetResultCallback<RemoteMediaPlayer.IMediaChannelResult> (r => {
                            Console.WriteLine ("Loaded");
                        });
                }
                catch (Exception e)
                {
                    Console.WriteLine ("Exception while sending a song. Exception : " + e.Message);
                }
            }
        }