This project has moved and is read-only. For the latest updates, please go here.

SegmentReaderManager creation

Aug 13, 2015 at 3:02 PM
Edited Aug 13, 2015 at 4:33 PM
Hello henric,

first off, thank you for sharing this library, you are awesome!

I use phonesm for implementing a streaming radio app which handles all kinds of shoutcasts. The overall performance is pretty good, but for some streams it takes very long to initialize. First thing I tried was at least killing the task after some time and trying to restart. I do it like this:
using (CancellationTokenSource cancelMediaInit = new CancellationTokenSource())
    var mss = await _mediaStreamFacade.CreateMediaStreamSourceAsync(new Uri(source),
This was not very effective, as the cancellationtoken is never passed foreward to the creation of the SegmentManager (the part which takes very long). So in a second attempt I changed SMMediaManager.OpenAsync() to receive my token:
async Task OpenAsync(ICollection<Uri> source, CancellationToken timeoutToken)
    using (var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(timeoutToken, _playbackCancellationTokenSource.Token)
        _readerManager = await _segmentReaderManagerFactory.CreateAsync(
                new SegmentManagerParameters
                    Source = source
                }, ContentType, _playbackCancellationTokenSource.Token).ConfigureAwait(false);
But then I just got a lot of cancelled tasks, even when commenting out the CancelAfter() part.

I noticed that you have some mechanism in the BackgroundAudio sample where you restart the stream, so I would be really glad if you could tell me what I am doing wrong.

edit I use the latest beta of 1.5.3 commit 10e93fc6e3a9. I have built my own background audio implementation and use the SM.Media, Builder and SM.Media.Platform.WinRT libraries and my primary target is WP8.1

Best regards,