2

I am using the Cast Companion Library and it is mostly working fine, I get the mini player, and also the lock screen controls and the activity for playing content, but I can never get the notification screen to show. I am doing the following when initializing:

mCastMgr.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
              VideoCastManager.FEATURE_LOCKSCREEN |
              VideoCastManager.FEATURE_DEBUGGING);

and I am doing the incrementUiCounter() on resume and decrementUiCounter() on pause.

I don't see any errors, I just don't see what I am doing wrong. The only thing I am missing is that I am not passing URLs for images when telling media to play because my URLs are local assets to my app and I'm just not sure how to pass those.

Sufian
  • 6,405
  • 16
  • 66
  • 120
casolorz
  • 8,486
  • 19
  • 93
  • 200
  • Notification should show up when you are outside of your app; did you try that scenario? – Ali Naddaf Feb 26 '14 at 22:38
  • Yes, many times. And I don't see any errors. Is there a place on the CCL you would suggest I put a breakpoint to see what is happening? – casolorz Feb 26 '14 at 22:53
  • I stepped the code and the issue is on line 158 of `VideoCastNotificationService`, the variable visible is always false. – casolorz Feb 27 '14 at 00:45

2 Answers2

5

Are you using that with your own app or with CastVideos-android? If your own app, first I suggest you try the CastVideos-android app to make sure that works for you.

I suggest you print out the value of mVisibilityCounter in BaseCastManager.incrementUiCounter() and decrementUiCounter() to see if as you move in and out of different activities, it reflects the correct counter. When that counter reaches zero, then notification should show up. If the counter is reaching zero and the notification doesn't show up, I suggest you check your manifest file and see if you have the following in your Manifest:

<service
    android:name="com.google.sample.castcompanionlibrary.notification.VideoCastNotificationService"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.sample.castcompanionlibrary.action.toggleplayback" />
        <action android:name="com.google.sample.castcompanionlibrary.action.stop" />
        <action android:name="com.google.sample.castcompanionlibrary.action.notificationvisibility" />
    </intent-filter>
</service>

(you can copy-and-paste from the CastVideos-android manifest file). You may have grabbed what it is from the documentation; there is an error there (I am planning to update a bunch of things tonight or tomorrow and the documentation will be updated as well); basically when the counter reaches zero, it calls into the notification service (see the onUiVisibilityChanged() in VideoCastManager) and if that action in manifest is not correctly set, the notification never gets our memo! Let me know if that is not the issue.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • Must have been that xml because it is working now. Guess my old one said `com.google.sample.cast.refplayer.notification.visibility`. – casolorz Feb 27 '14 at 03:06
  • Good. As I said, updated doc will be pushed pretty soon. – Ali Naddaf Feb 27 '14 at 03:08
  • I do have some crashes with CCL right now, for example when I go back to my main activity I get a `IndexOutOfBoundsException` on line 241 of `VideoCastManager`. – casolorz Feb 27 '14 at 03:08
  • That line number (241) in VideoCastManager points to a comment (looking in the github source) so your code must be old. Please update your project and if you still run into crash, please open a bug on the github project. – Ali Naddaf Feb 27 '14 at 03:11
  • Just updated, the line is now 252. I'm guessing it has to do with me not passing images but I don't know what to do because I don't have urls for the images, I have bitmaps. I am also unsure about how to change the notification icon. – casolorz Feb 27 '14 at 03:28
  • File a feature request on the github site for the project; i will try to come up with a solution. Are you going to have different bitmaps for different media or one bitmap (like a placeholder) for all of them? – Ali Naddaf Feb 27 '14 at 05:01
  • Ideally I will have different bitmaps unless I'm unable to find one then it will be a common one. I'll file a request. – casolorz Feb 27 '14 at 05:06
0

I had the same trouble. Just an FYI to those looking at this in 2016. The manifest entry is now different. I suggest to grab whatever is in the manifest of the CastVideos-android project.

<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" />

<service
    android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService" />

<service android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
SamWise
  • 698
  • 10
  • 16
  • Glad to see you posted this a couple of days ago. I'm actually getting a crash with this when I put those in the manifest: java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.myapp/com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity} – Paul Ruiz Mar 25 '16 at 01:16
  • @PaulRuiz are you also including the newest cast companion library from github? https://github.com/googlecast/CastCompanionLibrary-android – SamWise Mar 26 '16 at 02:12
  • Yeah I figured it out :) had a derp moment and forgot to include the cast activity in my manifest – Paul Ruiz Mar 27 '16 at 03:14