B4A Library External Displays

MarcoRome

Expert
Licensed User
Longtime User

Hi all.

1. I add this line in code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: ExternalDisplays
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
    #AdditionalRes: C:\Android\extras\android\support\v7\mediarouter\res, android.support.v7.mediarouter
    #AdditionalRes: D:\TV\cwac-mediarouter-res, com.commonsware.cwac.mediarouter
#End Region

2. Add in Library Folder this file:
  • android-support-v7-appcompat.jar
  • android-support-v7-mediarouter.jar
3. Verify that exist all file in C:\Android\extras\android\support\v7\appcompat\libs...etc. and all ok


Why i have again this error ? Depend new SDK ?

Thank you all
Marco
 

thedesolatesoul

Expert
Licensed User
Longtime User
Thanks. Was thinking more towards Chromecast. I think the new SDK may have broken the previous example.
Possibly. There are actually multiple ways to use Chromecast, and the SDK has been updated many times since this library was published.
 

ac9ts

Active Member
Licensed User
Longtime User
Setting the android.jar to Marshmallow (android-23\android.jar) allows the example code to compile. I haven't tested functionality.
 

ac9ts

Active Member
Licensed User
Longtime User
I receive the following when running on any pre-Lollipop system. It appears that there is a missing resource on the MediaRouteButton. I'm not sure where to look to correct this as I'm not to familiar with the inner workings of Java. I do NOT get this error when running on Android v5.0.1. I will also mention that I have only tested on Android 2.3.7 and 4.1.1 using GenyMotion and both a real device and GenyMotion for Android 5.x



** Activity (main) Create, isFirst = true **
main_activity_create (java line: 347)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010022 a=2}
at android.content.res.Resources.loadDrawable(Resources.java:1681)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1951)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:122)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:118)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:114)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.innerInitialize(MediaRouteButton.java:29)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.Initialize(MediaRouteButton.java:22)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main._activity_create(main.java:347)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.afterFirstLayout(main.java:100)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.access$100(main.java:17)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010022 a=2}
 

ac9ts

Active Member
Licensed User
Longtime User
I have a working version (files attached) that will connect to my Chromecast and start a MP3 stream. The problem I now have is that when I try to open the disconnect dialog, I get the following:


MediaRouterCallback onRouteSelected
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:112)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatDialog.<init>(AppCompatDialog.java:48)
at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:92)
at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:88)
at android.support.v7.app.MediaRouteControllerDialog.<init>(MediaRouteControllerDialog.java:98)
at android.support.v7.app.MediaRouteControllerDialog.<init>(MediaRouteControllerDialog.java:94)
at com.commonsware.cwac.mediarouter.MediaRouteControllerDialogFragment.onCreateControllerDialog(MediaRouteControllerDialogFragment.java:55)
at com.commonsware.cwac.mediarouter.MediaRouteControllerDialogFragment.onCreateDialog(MediaRouteControllerDialogFragment.java:60)
at android.app.DialogFragment.getLayoutInflater(DialogFragment.java:398)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Again, I really don't know the inner workings of Android to decipher what I need to change.
 

Attachments

  • ExternalDisplays2.zip
    24.1 KB · Views: 324
  • cwac-mediarouter-res.zip
    75.6 KB · Views: 318

gmh

New Member
Licensed User
Longtime User
Hi Martin, Luv'n your work. Made small donation (Aussie dollar not as strong as it was).

I'm also getting the error re "missing resource on the MediaRouteButton" similar to @ac9ts. It complies ok and the apk in #25 worked, so it must be something I'm doing re SDK files
 

ac9ts

Active Member
Licensed User
Longtime User
@gmh, the files I have in post 130 work. The problem was solved by changing the theme (and using the correct syntax ) in the manifest. It's a simple app that will connect and play and mp3. There are still some issues with disconnecting but the disconnect dialog does come up which was fixed by the theme change.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi All
Example @ac9ts work with out problem ( ChromeCast II )
A question:
is it possible send Activity in chromecast ? or is possible send 2 "link" ( mp3 for audio + mp4 without audio, so i can see a mp4 with mp3 as voice ) ?
For now example i have:

B4X:
RemotePlaybackClient1.Play("http://xxxx", "audio/mpeg3", 0, Null)

but if i add another link, in chromecast run only last link that i set.

Thank you
 

MarcoRome

Expert
Licensed User
Longtime User
Hi @warwound , all
is possible send entire screen device in place of a link.
Basically i can send on the device screen instead of sending a link ?

As in this movie:

Thank you very much
Marco
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User

I have setting the android.jar - android-23.
I use adapter Digicom amcast-L01
I have add in libraru folder;
  • android-support-v7-appcompat.jar
  • android-support-v7-mediarouter.jar
  • android-support-v4.jar
I have had this problem and I have not even solved by changing the theme in the Manifest as ac9ts. You give me some help?



LogCat connected to: 0123456789ABCDEF
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 363)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010030 a=3}
at android.content.res.Resources.loadDrawable(Resources.java:1967)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:3335)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:122)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:118)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:114)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.innerInitialize(MediaRouteButton.java:29)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.Initialize(MediaRouteButton.java:22)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main._activity_create(main.java:363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.afterFirstLayout(main.java:102)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.access$000(main.java:17)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010030 a=3}
 

warwound

Expert
Licensed User
Longtime User
I am happy to pay for the work if someone is willing update this library.

Post again in the job offers forum, your post will stand more chance of being read by someone with the time to help.
I'm too busy with work these days to help .
 

Martin Beukes

Member
Licensed User
Longtime User
Hi Warwound,

Someone has picked it up from Jobs forum. Once it is working I will be in contact for you to update this post with the new library.

Regards,
Martin
 

nedium

Active Member
Licensed User
Longtime User
Hi, I wanted to know if there is an updated version of this library,

I have an app that plays videos and I would like to share the video to my chromecast

I don't have these folders can you provide them to me?


#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\Android\extras\android\support\v7\mediarouter\res, android.support.v7.mediarouter

regards
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…