# Problem with device orientation

**URL:** <https://community.wowza.com/t/problem-with-device-orientation/54329>\
**Category:** Wowza GoCoder SDK\
**Created:** [December 12, 2019, 4:34pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329 "2019-12-12T16:34:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [December 12, 2019, 4:34pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/1 "2019-12-12T16:34:49Z")

</div>

Hi

I have a problem with device orientation using gocoder.

On the same devide with same gocoder version 1.9.1 an app that use gocoder in an activity works well but a second app seems to not recognize correct device orientation (the app uses gocoder in a fragment and I forced landscape but seems that gocoder record in portrait)

A link to see videos: [https://drive.google.com/open?id=1KecAVxXzvV7sZpG5rXydEvz4gdRRlomo](https://drive.google.com/open?id=1KecAVxXzvV7sZpG5rXydEvz4gdRRlomo)

---

<div class="post-metadata">

**Author:** ![video\_streaming](https://avatars.discourse-cdn.com/v4/letter/v/22d042/32.png) [@video\_streaming](https://community.wowza.com/u/video_streaming)\
**Post date:** [December 12, 2019, 10:58pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/2 "2019-12-12T22:58:51Z")

</div>

Are you using a fragment on both apps or is the issue only when you call the PlayerView in a fragment in the 2nd app @DarthXander?

---

<div class="post-metadata">

**Author:** ![Fabio\_De\_Lorenzo1](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/fabio_de_lorenzo1/32/419_2.png) [@Fabio\_De\_Lorenzo1](https://community.wowza.com/u/Fabio_De_Lorenzo1)\
**Post date:** [December 12, 2019, 11:07pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/3 "2019-12-12T23:07:30Z")

</div>

Hi @DarthXander,

can you please make a sample app with 2 activities. In the first activity you play (or broadcast or record) the video and in the second you do the same but within a fragment.

Then please share this code with me so I can reproduce the issue.

Thanks

---

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [December 13, 2019, 8:01am UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/4 "2019-12-13T08:01:55Z")

</div>

The issue is only for the app using the fragment

---

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [December 13, 2019, 8:03am UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/5 "2019-12-13T08:03:43Z")

</div>

Thanks for your support but I can’t share the code because I have no permission to do it.

If possible I would know if there are some methods in GoCoder SDK to know the gocoder orientation and to force programmatically the landscape.

---

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [December 13, 2019, 11:43am UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/6 "2019-12-13T11:43:39Z")

</div>

I partially resolved using the same approach of the first app. I open gocoder on another activity. In the next days I’ll try to test the solution using fragment.

---

<div class="post-metadata">

**Author:** ![Jason\_Tuchler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_tuchler/32/462_2.png) [@Jason\_Tuchler](https://community.wowza.com/u/Jason_Tuchler)\
**Post date:** [January 3, 2020, 6:59pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/7 "2020-01-03T18:59:29Z")

</div>

Hello @DarthXander

This is how you can detect the device orientation:  
[https://www.wowza.com/resources/gocodersdk/docs/api-reference-android/com/wowza/gocoder/sdk/api/devices/WOWZDeviceUtils.html](https://www.wowza.com/resources/gocodersdk/docs/api-reference-android/com/wowza/gocoder/sdk/api/devices/WOWZDeviceUtils.html)

Likely you’ll need to stop and restart the stream with the new orientation:

[https://www.wowza.com/docs/how-to-live-stream-with-wowza-gocoder-sdk-for-android](https://www.wowza.com/docs/how-to-live-stream-with-wowza-gocoder-sdk-for-android)

Then set to landscape:

[https://www.wowza.com/resources/gocodersdk/docs/api-reference-android/com/wowza/gocoder/sdk/api/configuration/WOWZMediaConfig.html#ORIENTATION\_LANDSCAPE](https://www.wowza.com/resources/gocodersdk/docs/api-reference-android/com/wowza/gocoder/sdk/api/configuration/WOWZMediaConfig.html#ORIENTATION_LANDSCAPE)

Regards,

JasonT

---

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [February 21, 2020, 2:41pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/8 "2020-02-21T14:41:38Z")

</div>

I worked again on this point but I did not found a solution yet.

If I use GoCoder in an Activity (opened by main activity) or if I use GoCoder in a Fragment opened by main activity SDK config seems to be ok.

Theese are the logs:

mWZBroadcastConfig.getVideoSourceConfig().getVideoFrameHeight(): 480 mWZBroadcastConfig.getVideoSourceConfig().getVideoFrameWidth(): 640 mWZBroadcastConfig.getVideoFrameHeight(): 720 mWZBroadcastConfig.getVideoFrameWidth(): 1280 mWZBroadcastConfig.getVideoFrameSize().height: 720 mWZBroadcastConfig.getVideoFrameSize().width: 1280

mWZBroadcastConfig.getOrientationBehavior() = ORIENTATION\_LANDSCAPE\_INVERTED in both cases

mWZBroadcastConfig.getRotation = 0 in both cases

But I seen some other logs during the stream that show the strange behavior.

Activity

I/ExtendedACodec: [OMX.qcom.video.encoder.avc] configure, AMessage : AMessage(what = ‘conf’, target = 1) = { int32\_t capture-rate = 30 int32\_t color-format = 2130708361 int32\_t i-frame-interval = 1 string mime = “video/avc” int32\_t width = 1280 int32\_t bitrate = 3750000 int32\_t frame-rate = 30 int32\_t height = 720 int32\_t encoder = 1 }

D/WMSTransport: [00]: “@setDataFrame”, [01]: “onMetaData”, [02]: {“videocodecid”: “avc1”, “width”: 1280, “height”: 720, “frameWidth”: 1280, “frameHeight”: 720, “displayWidth”: 1280, “displayHeight”: 720, “framerate”: 30, “videodatarate”: 3662, “audiocodecid”: “mp4a”, “audiosamplerate”: 44100, “audiochannels”: 2, “audiodatarate”: 62, “aacaot”: 2}

Fragment

I/ExtendedACodec: [OMX.qcom.video.encoder.avc] configure, AMessage : AMessage(what = ‘conf’, target = 1) = { int32\_t capture-rate = 30 int32\_t color-format = 2130708361 int32\_t i-frame-interval = 1 string mime = “video/avc” int32\_t width = 720 int32\_t bitrate = 3750000 int32\_t frame-rate = 30 int32\_t height = 1280 int32\_t encoder = 1 }

D/WMSTransport: [00]: “@setDataFrame”, [01]: “onMetaData”, [02]: {“videocodecid”: “avc1”, “width”: 720, “height”: 1280, “frameWidth”: 720, “frameHeight”: 1280, “displayWidth”: 720, “displayHeight”: 1280, “framerate”: 30, “videodatarate”: 3662, “audiocodecid”: “mp4a”, “audiosamplerate”: 44100, “audiochannels”: 2, “audiodatarate”: 62, “aacaot”: 2}

In the fragment’s logs width and height are inverted ☹

MainActivity and GoCoder Activity extend both AppCompatActivity

This is how I manage the orientation in the fragment

```auto
@Overridepublic void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated( savedInstanceState );
    getActivity().setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE );
    ((AppCompatActivity) getActivity()).getSupportActionBar().hide();

}

```

---

<div class="post-metadata">

**Author:** ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)\
**Post date:** [February 21, 2020, 3:44pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/9 "2020-02-21T15:44:46Z")

</div>

SDK configs seems to be ok, also device orientation detected by SDK methods.

But using fragment the problem persist.

See my last response to main thread

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [February 21, 2020, 5:17pm UTC](https://community.wowza.com/t/problem-with-device-orientation/54329/10 "2020-02-21T17:17:20Z")

</div>

Having someone look into it for you and we are aware that the fragment is not well supported in some devices.
