Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Create client-server apps by incorporating JavaScript and TVML files in your binary app using TVMLKit.

Posts under TVMLKit tag

3 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How to Properly Integrate Google IMA SDK for Pre-roll, Mid-roll, and Post-roll Ads in a tvOS App using TVJS and Swift?
I'm working on a tvOS application that plays video content using TVMLKit/TVJS. I'm trying to integrate Google IMA SDK to show pre-roll, mid-roll, and post-roll ads in my app. Here’s what I’ve done so far: Video playback is handled through JavaScript in application.js. Ads are managed in Swift using Google IMA SDK. I use the evaluateJavaScript bridge to control video playback from Swift. I pause and resume the TVJS player (Player object) using a function like startPlayingVideo(value) from Swift based on the ad lifecycle. Current Flow: When the video is about to start, I call loadAds() from JS. This presents a Swift ViewController that handles IMA ad requests. On adsManagerDidRequestContentPause, I pause the video using JS via the bridge. On adsManagerDidRequestContentResume, I resume the video. The Issue: This setup doesn't behave consistently: Sometimes the ad plays in the background and video started playing as well but can not see the ad. Not able to see the post-roll ads Relevant Code Snippets: application.js function startPlayingVideo(value) { if (playerReference != undefined) { if (value == true) { playerReference.play(); else { playerReference.pause(); } } } function playVideo(videoURL) { setup playerReference, push mediaItem, etc. loadAds(); player.present(); } AppDelegate.swift let loadAds: @convention(block) () -\> Void = { DispatchQueue.main.async { let adManagerVC = ViewController() AppDelegate.tvController?.navigationController.present(adManagerVC, animated: true) } } let updateVideoPlayTime: @convention(block) (Double) -\> Void = { time in CustomContentPlayhead.shared.currentTime = TimeInterval(time) } ViewController.swift func adsManagerDidRequestContentPause(\_ adsManager: IMAAdsManager) { showAdUI() playerViewController.player?.pause() } func adsManagerDidRequestContentResume(\_ adsManager: IMAAdsManager) { hideAdUI() // Expecting JS video to resume via bridge } And yeah my IMSDK Implementation is working fine if I am using it with swift AVPlayer. What I Need Help With: Best practice for coordinating video playback between JS (Player) and Swift (IMAAdsManager). How can I sync the playhead reliably between JS and Swift? Is there a better way to pause/resume TVJS player from Swift during ad lifecycle? How to reliably insert mid-roll ads when the playback is primarily controlled in JS? Any insights, code examples, or recommended architecture improvements would be greatly appreciated!
0
0
33
6d
How to Display Multiple Fields in a User Registration Form Using TVML for Apple TV?
Hello, I am currently developing an application for Apple TV using TVML, and I am trying to create a user registration or login form with multiple input fields (e.g., "Username" and "Password"). However, I am facing issues with displaying multiple textField components in the formTemplate. Here are the approaches I have tried: Attempt 1: <document> <formTemplate> <banner> <title>Login</title> </banner> <banner> <textField>UserName</textField> </banner> <banner> <textField>Password</textField> </banner> <footer> <button id="button1"> <text>Button 1</text> </button> </footer> </formTemplate> </document> Attemp 2: <document> <formTemplate> <banner> <title>Login</title> </banner> <textField>UserName</textField> <textField>Password</textField> <footer> <button id="button1"> <text>Button 1</text> </button> </footer> </formTemplate> </document> In both cases, the layout does not render the fields as expected. Either the textField components do not display at all, or the structure seems incorrect. Could someone please guide me on the proper way to display multiple textField components in a formTemplate? Is there a limitation or specific requirement for structuring these elements? Thank you in advance for your assistance!
0
0
494
Jan ’25
I want to establish connection between iOS app and Apple TV via WIFI to develop apple tv remote app, Any one have idea how?
I'm looking to develop an iOS application that functions as a remote for Apple TV, including discovering Apple TV devices over Wi-Fi. If anyone has experience building similar applications, could you share insights on available frameworks or protocols to discover Apple TVs? Additionally, if there are reference apps on the App Store that work like Apple's default remote app, I would greatly appreciate recommendations. Any guidance from developers who have worked on similar projects would be very helpful!
1
0
470
Oct ’24