Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
766 stars 305 forks source link

SHOUTcast Stream Server #309

Open Doxoh opened 6 years ago

Doxoh commented 6 years ago

Hello,

I want to use the MediaManager with a stream of a "shoutcast stream server". But I didn´t get MetaData. Do you know why or can you help?

Best Regards Doxoh

Doxoh commented 6 years ago

I got the following error:

[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys (
    title,
    artwork,
    artist
).
mike-rowley commented 6 years ago

There is no meta data (to my knowledge) embedded in the shoutcast stream. I am building an app that utilizes multiple shoutcast streams and I poll that data from the external XML data providing additional information such as song name etc. This data should also be available depending on the stream management software you use, I am using Centova Cast and Auto DJ.

I can get you more detailed information but my main development machine is currently undergoing a raid array backup and rebuild so it is out of commission for a day or two.

Doxoh commented 6 years ago

https://www.mixxx.org/manual/latest/chapters/livebroadcasting.html In this post under 9.3 is the description to set the metadata settings.

mike-rowley commented 6 years ago

My ShoutCast service provides and RPC call that returns and XML dataset. http://panel5.serverhostingcenter.com:2199/rpc/tjguhenj/streaminfo.get

I ingest this data for "Song Name" etc.

Doxoh commented 6 years ago

But that is not implement in this compontent?

When do you call the XML to get the information in the right time?

mike-rowley commented 6 years ago

Put it in a recurring timer, i update mine every 30 seconds

Doxoh commented 6 years ago

Can you send me an example what do you do in your PCL?

mike-rowley commented 6 years ago

RadioStreamData is just a poco class that matches the streaminfo.get xml. But I am using ServiceStack as the json client so I am not sure this helps you unless you have a ServiceStack license.

                var url = new Uri(DataURL);
                var jsonClient = new JsonServiceClient(url.AbsoluteUri.Replace(url.PathAndQuery, ""));
                var rsData = await jsonClient.GetAsync<RadioStreamData>(url.PathAndQuery);
TGlev commented 6 years ago

@mike-rowley I have the same, also using a SHOUTcast server. I can also get the data trough a JSON REST API, but how do I assign it to the MediaManager? What methods/properties do I call?

mike-rowley commented 6 years ago

I am not sure if IAndroidMediaNotificationManager and its collateral code is in the 0.45 release, if not pull the develop branch and build your own version until it is. Take a look at this pull request, it explains how to implement your own Android Notification class, this will allow you to customize your own Notifications in any way you like.

Here is where you will find the code that generates the Android Notification if you don't override the class. https://github.com/martijn00/XamarinMediaManager/blob/develop/MediaManager.Android/MediaSession/MediaNotificationManagerImplementation.cs

Doxoh commented 6 years ago

I am not working so long with Xamarin. I dont know how ich create a background task (IOS, Android) that every 30 seconds do the JSon Call

TGlev commented 6 years ago

Im getting this error on iOS, how could this fix it?

mike-rowley commented 6 years ago

@Doxoh Use a timer.

mike-rowley commented 6 years ago

@TGlev What error? Under what circumstances?

Doxoh commented 6 years ago

@mike-rowley ok thanks. I will try it

TGlev commented 6 years ago

Im also trying to stream from a shoutcast server and Im getting this error: (Xamarin.Forms.iOS)

[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys (
    title,
    artwork,
    artist
).

Since I can get this data from a JSON api, I was wondering how to pass it to the MediaManager to get rid of the error. Since the stream does not work at the moment.

mike-rowley commented 6 years ago

@TGlev are you passing a MediaFile object with the appropriate fields filled out to the MediaNotificationManager's StartNotification or UpdateNotifications?

TGlev commented 6 years ago

No. I found this plugin on Xamarin Blog and all Im doing is this:

await CrossMediaManager.Current.Play("stream.bigb21.nl:12000/live");

TGlev commented 6 years ago

Never mind! I forgot to add http:// to the URL! 😛

Doxoh commented 6 years ago

@TGlev now its worked?

TGlev commented 6 years ago

Yep.

Doxoh commented 6 years ago

var mediaFile = new MediaFile { Type = MediaFileType.Audio, Availability = ResourceAvailability.Remote, Url = "http://5.196.64.74:5099/live", MetadataExtracted = true }; await CrossMediaManager.Current.Play(mediaFile);

I do this, but I got the same error on IOS:

AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( title, artwork, artist ).

Doxoh commented 6 years ago

@TGlev did you change any options on the server?

TGlev commented 6 years ago

I am still getting the error, but the audio is working.

TGlev commented 6 years ago

No, I did not change anything. The server is not mine.

Doxoh commented 6 years ago

Alright. yes the audio is working too for me.

I will try the Timer option..

mike-rowley commented 6 years ago

@Doxoh you are getting an error in the log or an exception in the application?

Doxoh commented 6 years ago
bildschirmfoto 2017-12-01 um 21 05 13

in the console.

mike-rowley commented 6 years ago

Try filling in Artist and Title for the Metadata on the MediaFile

If you look at the code, that should be what is used to populate the notification on IOS

Doxoh commented 6 years ago

The Shoutcast server is not mine. I will tell that to the owner

Doxoh commented 6 years ago

Can I override the title and artist in the LockScreen control? Currently I shows "live"

mike-rowley commented 6 years ago

It has nothing to do with the Shoutcast server.

var mediaFile = new MediaFile { Type = MediaFileType.Audio, Availability = ResourceAvailability.Remote, Url = "http://5.196.64.74:5099/live", MetadataExtracted = false }; mediaFile.Metadata.Title = "Song Title"; mediaFile.Metadata.Artist = "Artist Name"; await CrossMediaManager.Current.Play(mediaFile);

I HIGHLY suggest downloading the code and playing with the sample projects.

Doxoh commented 6 years ago

I do this:

` async Task GetTitleInfo(){

var titleArtist = //WebRequest

        Device.BeginInvokeOnMainThread(() =>
        {
            if (titleArtist.Length > 1)
            {
                titel.Text = titleArtist[1].TrimStart(' ');
                artist.Text = titleArtist[0].TrimEnd(' ');
            }
            else
            {
                titel.Text = titleArtist[0];
                artist.Text = "HarbourTown - Radio";
            }

            mediaFile.Metadata.Title = titel.Text;
            mediaFile.Metadata.Artist = artist.Text;
        });

        return result;
    }`

In the first call it's worked. But when the next title is playing the MPNowPlayingInfo does not changed

Doxoh commented 6 years ago

I fixed it.

Run this after you changed the title CrossMediaManager.Current.MediaNotificationManager.UpdateNotifications(mediaFile, MediaPlayerStatus.Playing);

pakbaz commented 6 years ago

@Doxoh Can you elaborate please? I have the same issue with this plugin for my radio station. what does the //WebRequest look like. also when do you call GetTitleInfo() ?