Need guidance to build a media control widget for Edge 1040?

I've spent a day reading and experimenting, but seem to be bumping into the right approach to accomplish the widget I would like to build using the Garmin Connect SDK. The idea is to create a small visual icon that will fit on an activity page in the smaller positions that when clicked on will advance the media player to the next track. Sounds simple yah? I'm aware I can enable the built in media player screen for my profile, and that does work, but I would like to be able to advance the audio track from my main screen and not have to swipe pages. 

It seems this should do the trick as it compiles, but it generates a crash when ran in both the simulator and on the device.  

        var options = {
            :contentType => Toybox.Media.CONTENT_TYPE_AUDIO
        };

        // Get the ContentIterator object by calling the system function.
        var mediaControl = Media.getContentRefIter(options);
        mediaControl.next();

I've tried different app types with; widget, watch app and data field but all have the same result. Audio content provider app isn't available for the edge 1040. 

On a side note, it's curious though that the built in media controller wasn't designed in a way to be placed into a small size container for the page layout like some other widgets do (and pick the specific feature to display). That's basically the gap in functionality that I was trying to add. 

Once I get that all working, then I wanted to auto stop/start the media player when the bike comes to a stop (like the timer does). 

thanks in advance for any suggestions!

-Kevin

  • update... to clarify, I'm referring to the phone's media player specifically. 

  • You probably figured this out by now but:

    - no CIQ app can control the media player on your phone

    - the Toybox.Media module you are calling is for audio content provider apps only

    https://developer.garmin.com/connect-iq/api-docs/Toybox/Media.html 

    The Media module provides objects and methods for implementing audio content provider apps. 

    - Audio content provider apps can only play their own media (downloaded from the network), hence the key word provider, they can't control media on your phone

    - Audio content provider apps are not available for Edge devices, only for watches that support (on-device) music, and even if they were, they can't do what you want anyway