Nothing appears whilst attempting a render

Heyya! I come from Java, so I likely suck at Monkey C for the moment. I've been trying to learn it for a few days now, but the rendering still has me stumped -

File: <app>App.mc

import Toybox.Application;
import Toybox.Lang;
import Toybox.Media;
import Toybox.WatchUi;
import Toybox.Graphics;
import Toybox.Communications;

class :APP:App extends Application.AudioContentProviderApp{ // :APP: is a placeholder //

    function initialize(){
        var kacID = "redacted";
        var kacSecret = "redacted";
        AudioContentProviderApp.initialize();
    }

    // Calls Kerror.mc when program loads
    function onStart(state as Dictionary?) as Void{
        return new Kerror();
    }
/*
... more
*/
}

File: Kerror.mc

import Toybox.Graphics;
import Toybox.WatchUi;

class Kerror extends WatchUi.View{

    function initialize(){
        WatchUi.View.initialize();
    }

    function onUpdate(dc){
        dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_DK_GREEN);
        dc.clear();
        dc.drawText(132, 100, Graphics.FONT_SMALL, "asdasd", Graphics.TEXT_JUSTIFY_CENTER);
    }
}

By default, Music Provider Apps display the text "No Media" with a black backdrop, but all of my attempts to draw something else have either had no effect, or turned the screen white and unresponsive.
What am I doing wrong?

  • instead of

     function onStart(state as Dictionary?) as Void{
            return new Kerror();
        }

    try

    function getInitialView()
    {
      return [new Kerror()];
    }

  • Thanks for the suggestion, but I'm still getting nothing. Even trying to render anything directly from that function with a "dc" implementation (

        class :APP: extends Application.AudioContentProviderApp{
    /*
    ...
    */
        function getInitialView(dc){
            dc.setColor(Graphics.COLOR_PINK, Graphics.COLOR_PINK);
            dc.fillCircle(20, 90, 30);
        }
    }

    ) doesn't change the result..

  • I'm sorry my mistake. I thought the Audio Content Provider works just like other types of applications, but not.
    As I have no experience with Audio Content Provider, I can only help by referring you to

    https://developer.garmin.com/connect-iq/connect-iq-faq/how-do-i-create-an-audio-content-provider/

    And make sample app from "wizard" maybe it help.

  • And make sample app from "wizard" maybe it help.

    Yeah, in VS Code, use the command palette: CTRL/CMD-SHIFT-P > Monkey C: New Project > [enter project name] > [select project type] Audio Content Provider

    You'll see that the boilerplate for an audio content provider app is a bit different from what you (OP) have. e.g. This is what gets generated for the main app class:

    import Toybox.Application;
    import Toybox.Lang;
    import Toybox.Media;
    import Toybox.WatchUi;
    
    class testmusicApp extends Application.AudioContentProviderApp {
    
        function initialize() {
            AudioContentProviderApp.initialize();
        }
    
        // onStart() is called on application start up
        function onStart(state as Dictionary?) as Void {
        }
    
        // onStop() is called when your application is exiting
        function onStop(state as Dictionary?) as Void {
        }
    
        // Get a Media.ContentDelegate for use by the system to get and iterate through media on the device
        function getContentDelegate(arg as PersistableType) as ContentDelegate? {
            return new testmusicContentDelegate();
        }
    
        // Get a delegate that communicates sync status to the system for syncing media content to the device
        function getSyncDelegate() as SyncDelegate? {
            return new testmusicSyncDelegate();
        }
    
        // Get the initial view for configuring playback
        function getPlaybackConfigurationView() as Array<Views or InputDelegates>? {
            return [ new testmusicConfigurePlaybackView(), new testmusicConfigurePlaybackDelegate() ] as Array<Views or InputDelegates>;
        }
    
        // Get the initial view for configuring sync
        function getSyncConfigurationView() as Array<Views or InputDelegates>? {
            return [ new testmusicConfigureSyncView(), new testmusicConfigureSyncDelegate() ] as Array<Views or InputDelegates>;
        }
    
    }
    
    function getApp() as testmusicApp {
        return Application.getApp() as testmusicApp;
    }

    This is what I get when I run the project without making any changes (I do have to turn off Monkey C type checking)

  • Also, a general observation. I noticed your code example looks like this:

    dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_DK_GREEN);
    dc.clear();
    dc.drawText(132, 100, Graphics.FONT_SMALL, "asdasd", Graphics.TEXT_JUSTIFY_CENTER);

    That's just going to result in a solid green screen (in any context where it works), because both the FG and BG color in dc.setColor() are the same. In general you would want to set the background color to either transparent or the color of your choice (e.g. white or black.)

    e.g.

    dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_TRANSPARENT);

  • I haven't written any Audio app so don't knowm for sure...

    suspect, after example analysis, maybe you can't draw anything but only return data (icons, texts etc) - system draws itself

    you should synchronise data first and return info to systems and it shows media name...

    ...