언어 설정

Menu
Sites
Language
MediaPlayer PrepareAsync Blocking

Hello,

I'm using API 4.0-5.0 on emulator TV 5.5,
When live stream list work, there is no problem; but if there are some problem ( example firewall blocking, or stream no working) we can't zap on another fastly,  beacause we are await prepareAsync, blocking too, when connection to url can't be etablished, and player status stay in preparing status, can't be unprepraed.
How can I cancel it, it doesn't accept a CancellationToken.

 

Thank you.

Responses

8 댓글
Tizen .NET
Hello
it doesn't accept a CancellationToken.
=> What does it mean? Even though you call CancellationTokenSource.Cancel, doesn't it work??
 
I can't exactly reproduce the situation in question so I've just confirmed that TaskCanceledException occurs by CancellationTokenSource.Cancel(true) during player preparation.
CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
try
{
    await player.PrepareAsync(token);
} catch (Exception ex)
{
	// Error handling (TaskCanceledException)
}
finally
{
	source.Dispose();
}
 
It would be helpful to understand the problem if you could share a simple sample code that reproduces the problem. (tizen.net@samsung.com)
Thanks.
Ali Demir

Hi,

I saw today, PrepareAsync(CancellationTokenSource) is avaible in API 6.0, not before.
 

Thanks

Ali Demir

Hi,

I saw today, PrepareAsync(CancellationTokenSource) is avaible in API 6.0, not before.
And its not work on Tizen 4.0, thats why I asking you, if there is another solution :) ?

Thank you.

Jeong-yoon Nam

Hello.

Unfortunately you cannot cancel asynchronous preparing with API 5.0 or lower.

CancellationToken is added to make it cancelable.

Ali Demir

Hello,

I'm using API 4.0-5.0,

and I would like to know
try{ 
     await 
PrepareAsync();
}catch(Exception ex){ .. }

Can cause crashes if executed multiple times?
Is it thread safe?

Because to test I run a video stream several times, one after the other, and 3-4 th my application crashes without exception during PrepareAsync()?

 

Thank you

Jeong-yoon Nam

Hello.

How did you run PrepareAsync() several times, if you call it with await keword?

Could you give us more details?

If you attach the log or test code, it will help us to find your problem.

Thanks.

Ali Demir

Hello,
I'm using a Player Page (like MediaPlayer), cache it in a dictionary and push it in navigation when  I need.
I'm awaiting every time PrepareAsync() during appaering and dont forgot stop the Player when page is Dissapearing.

Then I open and close this page quickly, the application crashes in (PrepareAsync) during the 3rd 4th call

 

  protected override async void OnAppearing()
{
    ...
    try
    {
        ...
        var result = await StartPlay(); // => await Player.Start();
        ...
    }
    catch (Exception ex)
    {
        Logger.Error($"MP : StartPlay {ex}");
    }
    ...
    MessagingCenter.Subscribe<IKeyEventSender, string>(this, "KeyDown", (s, e) => { KeyEventHandler(e); });
    // Subscribing after await, for not quit before or during the call
}

 async Task beforeDisappear()
{
    ...
    try
    {
        await Player.Stop();
    }
    catch (Exception ex)
    {
        Logger.Error($"MP beforeDisappear : {ex}");
    }
    ...
    MessagingCenter.Unsubscribe<IKeyEventSender, string>(this, "KeyDown");
}

 

I'm listening you, if you have any advice:)

Thank you.

Jeong-yoon Nam

Thanks for sharing it.

However it is insufficient to analyze the issue.

Could you attach the log as well please?