# Pausing streaming internet radio (UE4.25, FMOD 2.01.07)

**URL:** <https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004>\
**Category:** Unreal Engine\
**Tags:** ue4, cpp\
**Created:** [April 8, 2021, 11:43am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004 "2021-04-08T11:43:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DracoNared](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/draconared/32/1875_2.png) [@DracoNared](https://qa.fmod.com/u/DracoNared)\
**Post date:** [April 8, 2021, 11:43am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/1 "2021-04-08T11:43:49Z")

</div>

Hi,

It’s partially referring to what was discussed here [Streaming internet radio (UE4) - #15 by DracoNared](https://qa.fmod.com/t/streaming-internet-radio-ue4/16884/15) , but I decided to make a different topic.

It’s not an issue, rather a question for cleanliness of the code for pausing an internet stream.

I was trying different methods to pause the radio and the only one that was not causing any errors is this:

```
void AFMODRadio::ToggleRadio()
{
    if (isPlaying)
    {
        this->AudioComp->Stop();
        this->Sound->release();
    }
    else
    {
        FMOD_RESULT Result;

        SoundInfo = { 0 };

        SoundInfo.cbsize = sizeof(SoundInfo);
        SoundInfo.ignoresetfilesystem = true;
        SoundInfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG;
        SoundInfo.filebuffersize = 1024 * 16;

        Result = CoreSystem->createStream("http://live-radio01.mediahubaustralia.com/2TJW/mp3/",
            FMOD_CREATESTREAM | FMOD_NONBLOCKING,
            &this->SoundInfo,
            &this->Sound);
        if (Result != FMOD_OK)
        {
            UE_LOG(LogTemp, Warning, TEXT("Couldn't create Stream, error: %i"), Result);
            return;
        }

        this->AudioComp->SetProgrammerSound(Sound);
        this->AudioComp->Play();
    }

    isPlaying = !isPlaying;
}

```

Is it ok to do it this way? I think the best would be to just use

`this->AudioComp->SetPaused(isPlaying ? true : false);`

but it didn’t work (it did stop the stream, but didn’t restart the stream).

///////  
And to remind you, my class looks like this:

```
class TEST425_API AFMODRadio : public AActor
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintCallable)
        void ToggleRadio();

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        UFMODAudioComponent* AudioComp;

protected:
    virtual void BeginPlay() override;
// Here I close and release the CoreSystem.
    virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

    FMOD::System* CoreSystem = nullptr;
    FMOD::Sound* Sound = nullptr;
    FMOD_CREATESOUNDEXINFO SoundInfo = { 0 };

    bool isPlaying = true;
};
```

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [April 12, 2021, 1:49am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/2 "2021-04-12T01:49:59Z")

</div>

There is a ‘netstream’ example included in the API download, which you can use as a bit of a guide.

What sort of errors are you getting when you try to pause/resume the stream?

---

<div class="post-metadata">

**Author:** ![DracoNared](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/draconared/32/1875_2.png) [@DracoNared](https://qa.fmod.com/u/DracoNared)\
**Post date:** [April 12, 2021, 7:24am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/3 "2021-04-12T07:24:31Z")

</div>

Yeah, I know; I was trying to get it done like in netstream example, like in the lines:

```
bool paused = false;
result = channel->getPaused(&paused);
ERRCHECK(result);
result = channel->setPaused(!paused);
ERRCHECK(result);

```

But the main problem is that in UE4 a channel is not needed to create or play a stream and thus it is not assigned.

Any way I can see of to get a channel, is by calling

```
FMOD::Channel* channel;
CoreSystem->getChannel(0, &channel);

```

But then calling

```
isPlaying = false;
this->channel->getPaused(&isPlaying);
this->channel->setPaused(!isPlaying);

```

is not working. It doesn’t stop the playback. And no, there is nothing in the output log.

The other way I thought of to get a channel was through:

```
FMOD::ChannelGroup* group;
this->AudioComp->StudioInstance->getChannelGroup(&group);
group->setPaused(isPlaying ? true : false);

```

and it does stop the stream, but when I want to unpause it, the only thing in output log is:

```
LogFMOD: e:\jk\workspace\2.1_UE4.25+_Win64\core_api\src\fmod_async.cpp(191) - Starting Asynchronous operation on sound 000002369E345608
LogFMOD: e:\jk\workspace\2.1_UE4.25+_Win64\core_api\src\fmod_async.cpp(336) - Finished Asynchronous operation on sound 000002369E345608

```

and the sound doesn’t return. I got the same result and the same output log when was calling:

```
this->AudioComp->SetPaused(isPlaying ? true : false);

```

So at the moment the only way of pausing the stream I see is by stopping the stream and creating a new one, just like in the initial post. Maybe there is another bug in UE4 streaming implementation or I’m doing something wrong.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [April 12, 2021, 10:29pm UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/4 "2021-04-12T22:29:27Z")

</div>

You shouldn’t be trying to pause the channel, use `AudioComponent::SetPaused` to pause the event and the API will handle pausing/resuming all the channels of the event. If that doesn’t work, can you share the error logs you get from this?

---

<div class="post-metadata">

**Author:** ![DracoNared](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/draconared/32/1875_2.png) [@DracoNared](https://qa.fmod.com/u/DracoNared)\
**Post date:** [April 13, 2021, 5:47am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/5 "2021-04-13T05:47:55Z")

</div>

I wrote twice that AudioComponent::SetPaused is not working and I wrote in the previous post that when I’m calling AudioComponent::SetPaused, there are no errors in the log, only:

```
LogFMOD: e:\jk\workspace\2.1_UE4.25+_Win64\core_api\src\fmod_async.cpp(191) - Starting Asynchronous operation on sound 000002369E345608
LogFMOD: e:\jk\workspace\2.1_UE4.25+_Win64\core_api\src\fmod_async.cpp(336) - Finished Asynchronous operation on sound 000002369E345608
```

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [April 14, 2021, 6:02am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/6 "2021-04-14T06:02:09Z")

</div>

> [@DracoNared](#):
>
> AudioComponent::SetPaused is not working

This appears to be caused the the stream going virtual when it is paused, then when it comes back from virtual it wants to do a seek to get to the right spot however most netstreams don’t support seeking. You can work around this by setting the priority of the Event to ‘highest’ so that it won’t go virtual when paused.

---

<div class="post-metadata">

**Author:** ![DracoNared](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/draconared/32/1875_2.png) [@DracoNared](https://qa.fmod.com/u/DracoNared)\
**Post date:** [April 14, 2021, 9:10am UTC](https://qa.fmod.com/t/pausing-streaming-internet-radio-ue4-25-fmod-2-01-07/17004/7 "2021-04-14T09:10:10Z")

</div>

Changing the event priority did the work. At the same time, it fixed a problem I was going to report (with stream not restarted when bus was set to 0 and reset to higher value), so we killed two birds with one stone.  
Thanks a lot!
