question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot Tell Play or Paused on Android: onPlaybackStateChanged and onPlaybackRateChange payload not accessible

See original GitHub issue

Bug

I found this issue #1879 that has part of my issue in it, but the possible resolution also does not work. The other part of my issue is the other way I would be able to tell if the video is playing at least, does not return anything. So I am wondering if there is any reliable way to tell if the video is playing or paused in Android?

Thank you!

Platform

Which player are you experiencing the problem on:

  • Android using React Native Video

Environment info

 React native info output:

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 1.58 GB / 15.83 GB
  Binaries:
    Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: 20210110.135312.0 - C:\ProgramData\chocolatey\bin\watchman.EXE
  SDKs:
    Android SDK:
      API Levels: 23, 28, 29, 30, 31
      Build Tools: 28.0.2, 28.0.3, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0
      System Images: android-28 | Google APIs Intel x86 Atom_64, android-29 | Android TV Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: AI-212.5712.43.2112.8609683
    Visual Studio: 16.8.30804.86 (Visual Studio Community 2019)
  Languages:
    Java: 11.0.12
  npmPackages:
    @react-native-community/cli: ^7.0.0 => 7.0.4
    react: 17.0.2 => 17.0.2
    react-native: Not Found
    react-native-tvos:  0.68.2-5
    react-native-windows: ^0.68.0 => 0.68.14
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.2.0

Steps To Reproduce

<Video
   ref={(ref) => (videoPlayer.current = ref)}
   source={{ uri: video }}  
   paused={state.paused}
   onPlaybackRateChanged={(e) => console.log(e)}
   resizeMode={"contain"}
   style={{
         top: 0,
         left: 0,
         bottom: 0,
         right: 0,
         height: height, 
         width: width,
      }}
  />
  1. Use the event prop onPlaybackRateChanged or onPlaybackStateChanged and console log the payload.

Expected behaviour

  1. I am trying to get the payload from onPlaybackRateChanged or onPlaybackStateChanged (not shown). In the documentation, it shows that they should both work on Android.
  2. onPlaybackRateChanged should give me back a zero or one to show that it is playing or paused.
  3. onPlaybackStateChanged (not shown) would provide me a isPlaying : true/false.

Reproducible sample code

<Video
   ref={(ref) => (videoPlayer.current = ref)}
   source={{ uri: video }}  
   paused={state.paused}
   onPlaybackRateChanged={(e) => console.log(e)}
   resizeMode={"contain"}
   style={{
         top: 0,
         left: 0,
         bottom: 0,
         right: 0,
         height: height, 
         width: width,
      }}
  />

Video sample

If possible, include a link to the video that has the problem that can be streamed or downloaded from.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
freeboubcommented, Sep 14, 2022

Good so let’s close the ticket!

0reactions
esegebartcommented, Sep 14, 2022

@freeboub Perfect thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - SeekTo does not trigger onPlaybackStateChanged ...
It appears that MediaControllerCompat.Callback.onPlaybackStateChanged(PlaybackStateCompat state) is only called if the MediaSessionCompat 's ...
Read more >
Using a media session - Android Developers
A newly-created media session has no capabilities. ... The transport state (whether the player is playing/paused/buffering, etc.
Read more >
mozilla-central: changeset 459322 ... - Mercurial
If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const...
Read more >
react-native-video - bytemeta
Cannot Tell Play or Paused on Android: onPlaybackStateChanged and onPlaybackRateChange payload not accessible. minhas-weoveri. minhas-weoveri OPEN.
Read more >
freeboub (freeboub) - PullAnswer
Cannot Tell Play or Paused on Android: onPlaybackStateChanged and onPlaybackRateChange payload not accessible. 0 Likes 1 Replies. Robiullah2244. 2022-08-02 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found