Play video in the background in TVML - tvos

I'm starting a player and then pushing a document onto the navigation stack. Video is playing in the background but is not visible as the document is occupying the screen. Can anyone please tell me how to make the document transparent or is there any better approach to achieve the same?

Overlay TVML?
TVJS player property overlayDocument, see https://developer.apple.com/library/tvos/documentation/TVMLJS/Reference/TVJSPlayer_Ref/index.html or https://forums.developer.apple.com/thread/18431

You can get interactive overlay over videos as referred to in the following link:
http://devstreaming.apple.com/videos/wwdc/2016/212s41rh77qgdg26s86/212/212_developing_tvos_apps_using_tvmlkit_part_1.pdf
Overlays can be made interactive since you are essentially adding documents to overlay doc. So any kind of button lock up will work just fine.

Interactive overlay document is the way to go. The following code shows how this is done.
App.onLaunch = function(options) {
var singleVideo = new MediaItem('video', 'http://somevideo.mp4');
var videoList = new Playlist();
videoList.push(singleVideo)
var myPlayer = new Player();
myPlayer.playlist = videoList;
var parser = new DOMParser();
var parsedDoc = parser.parseFromString(`<document>
<alertTemplate>
<button>
<text>Click Me</text>
</button>
</alertTemplate>
</document>`, "application/xml");
myPlayer.interactiveOverlayDocument = parsedDoc;
myPlayer.interactiveOverlayDismissable = false;
myPlayer.play();
}
Apple doesn't have a lot of doc on it. but they did mention it in WWDC,
slide 98-102 of the WWDC 2016 presentation.
the end of this document-- Apple TV Markup Language Reference-- Compound Multimedia Elements
and an example in TVML Guide: Core concepts in TVML and TVMLKit-- Server/PlaybackVideo/index.js
This thing does have some bugs, namely the interactiveOverlayDismissable value not being active if the video is the first thing you display, or does this whole thing play well with the native code outside of TVML. But this is the easier part to do video background.
Note, you might want to add some even listeners to replay the video at the end, as the default behavior is to pop the view.

Related

display only a specific content in AS3 code using webStage View

I'd like to display, in my app, only a part of a web page.
On this website, I'd like to display, in my app, only the div id "MovieCart".
What should I write in my as3 code in order to do so ?
For now, I have this line :
webView.loadURL("http://www.cinecity.nc/Cinecity/Film/40565");
But, of course, it's displaying the fullwebpage.
EDIT
So, I've tried this :
webView.addEventListener(Event.COMPLETE,onComplete);
var res : String = ExternalInterface.call("function(){return document.getElementById('movieCart').outerHTML}");
var urlOfMovie: URLRequest = new URLRequest("http://www.cinecity.nc/Cinecity/Film/40567");
var loaderMovie:URLLoader = new URLLoader();
loaderMovie.load(urlOfMovie);
webView.loadString(res);
But, as it's an AIR app, ExternalInterface.call can't be call. Any idea ?
Here is one easy way you can accomplish this:
//First, load the full page as you're currently doing:
webView.addEventListener(Event.COMPLETE, webLoadComplete); //listen for when the load is finished
webView.loadURL("http://www.cinecity.nc/Cinecity/Film/40565");
//runs when the load finishes
function webLoadComplete(e:Event):void {
webView.removeEventListener(Event.COMPLETE, webLoadComplete); //stop listening
//second, invoke the following Javascript on the page which assigns the `MovieCart` element as the html for the whole document body
webView.loadURL("javascript:document.body.innerHTML = document.getElementById("MovieCart").outerHTML");
}
Disclaimer:
Keep in mind that scrapping content from websites is generally frowned upon and you may be infringing on peoples work/copyrights by doing so.

HTML - image cover on object

I'm a begginer, and I need your help :)
I have a simple landing page, made from one long jpg + image mapping.
I've embedded a youtube video in a specific location on the image as an object command but I want to show a different image until it is pressed (an image with a play button, for example).
The page will be shown on a facebook tab as well.
Can any1 help me?
P.S - Sorry if I have grammar mistakes :)
Thanks!
Pretty sure a placeholder can be implemented via the Youtube API or you could take a look at this, How to add a splash screen/placeholder image for a YouTube video
Using JavaScript: You could add a Listener to the image so once it is pressed it loads a video.
var image = new Image(); //Image with playbutton
//Then load your Video in the EventListener
image.onclick("load", function() {
alert("loaded");
The function() method will contain the code to run your video
This is a good link about EventListeners http://idratherbewriting.com/javascript/events-and-listeners-javascript/

html5 video interactive objects

Does anyone know if html5 video allows objects like buttons, menu, etc connected to the timeline?
Youtube flash player do this: in specific moment, show an object (banner, links, comments) over the video for defined seconds.
thanks
Yes and no,
It's possible to create very interactive video-based presentations using html5 video objects however it requires a lot more than just the video object itself. You can nest video into a canvas object then mess with the actual video image frames, you can overlay any visual html element on top of the video object itself then animate these, you can control the video playback with buttons, click events etc. You can even have the video object control the rest of the page with time-based listeners.
Popcorn.js is really really good and easy to learn, allowing you to do all of what you mentioned.
http://popcornjs.org
http://popcornjs.org/demos
It's not part of the HTML5 video standard, but it's easy to implement manually by wiring up some scripting to the progress event. By looking at the currentTime property of the video object you can decide when to show/hide additional elements.
eg showing an element on top of a video between 1 and 2 seconds into a video:
<video id="v">...</div>
<div id="overlay" style="position: relative; top: -80px;">HELLO</div>
<script type="text/javascript">
var overlay= document.getElementById('overlay');
var video= document.getElementById('v');
video.addEventListener('progress', function() {
var show= video.currentTime>=1 && video.currentTime<2;
overlay.style.visibility= show? 'visible' : 'hidden';
}, false);
</script>
X2TV (www.x2.tv) has a drag and drop studio where you can overlay icons and additional content within the HTML5 layer.
In case you woul like to use a more generic framework https://github.com/nise/vi-two could be interesting for you.

Html5 drag and drop unicode chessboard

I am trying to do html5 dragndrop on my html5/css chessboard using unicode pieces but have a problem at the moment with it.
On dragging & dropping the whole 'li' element seems to move & on drop this disrupts the board.
This can be seen on the chess WordPress site at:
http://www.buryknightschess.org.uk/play-chess/
(As can be seen I asked for help with this on SitePoint Forums but haven't had a reply to help yet from there).
Possibly I somehow need just to make the unicode chess pieces draggable & not the whole chess square (<li></li>).
I shall keep trying to fix this but meanwhile I would greatly appreciate any advice to help with this html5 dragndrop issue. I look forward to helpful replies, many thanks
The reason the <li/> is being moved (thus rearranging the chess board) is because in your drop function is calling appendChild:
function drop(event) {
var element = event.dataTransfer.getData("Text");
// This changes the DOM
event.target.appendChild(document.getElementById(element));
event.stopPropagation();
return false;
}
Instead of moving that actual DOM node, the drop function should copy the innerHTML of the node that's being dragged. Here's how the new drop would look function:
function drop(event) {
var coordinate = event.dataTransfer.getData("Text");
var element = document.getElementById(coordinate);
event.target.innerHTML = element.innerHTML; // Moving piece to new cell
element.innerHTML = ""; // Clearing old cell
event.stopPropagation(); // Consider using `event.preventDefault` instead
return false;
}
Also, I'd consider using event.preventDfault instead of event.stopPropagation. This makes it possible to add new drop listeners to the board or one of its parents. For example you may want to add a drop listener to the document body to handle the case where a user tries to drag a piece off the board.
As general remark, have you considering using jQueryUI draggable and droppable libraries? You'd be able to support much richer drag/drop interactions such as snap-to-grid movement and delayed starts. Also, HTML5 drag-and-drop is typically used to allow users to drag files from their OS desktop onto the a web page. The way your using it is totally fine, it's just a little strange.

Flash HTML image link AS3

I have a flash as3 file, and I'm importing an HTML file that contains this link:
<img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button">
and I cannot for the life of me figure it out, I've looked everywhere.
There were a couple of forums that suggested:
function onTicketLoad():void {
if(paypal != null && this.contains(paypal)) {
removeChild(paypal);
}
var imgLoader:DisplayObject = content_text.getImageReference("paypal_button");
//imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onHtmlImageLoaded);
paypal.addChild(imgLoader.content);
}
function onHtmlImageLoaded(e:Event):void {
e.target.removeEventListener(Event.COMPLETE, onHtmlImageLoaded);
paypal.addChild(e.target.content);
paypal.buttonMode = true;
paypal.useHandCursor = true;
addChild(paypal);
}
(that example is fragmented as all hell, I just included it to illustrate what I'm trying to do)
Basically I think I need to load the image into the getImageReference method... but I'm so lost... any help would be appreciated!
I've found creating links on <img> tags in TextFields in Flash can be problematic.
I spotted the issue has been reported on the adobe bug tracker here:
http://bugs.adobe.com/jira/browse/FP-2146
Once as a workaround I created a separate swf file the exact same size as the image and embedded that instead (i.e. a 160x47 stage and a MovieClip/button with a clickable link using navigateToURL). Basically you can embed swf files within TextFields the same way as images.
It's not ideal but it did seem like a decent compromise considering the swf 'button' can now be used and laid out in more or less the same way as you would have used the <img> tag.
If you are going to use the < img > tag in an htmlText box, "you must set the text field to be multiline and to wrap text"
I tried it, and it works fine for me. It loaded the image and the link worked too. Here is my code:
import flash.text.TextField;
var labelText:String = '<img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button">';
var label:TextField = new TextField();
label.border = true;
label.multiline = true;
label.wordWrap = true;
label.width = 200;
label.height = 100;
addChild(label);
label.htmlText = labelText;
My example uses pure AS3, but it should be exactly the same as selecting "multiline" and "wordwrap" from your textfields properties panel.
AIR (Mobile) ignores IMG tags for security apparently... useless in my opinion.
Adding the fact the TextFlow is not recommend or supported for that either in Mobile, and many other fruit less attempts to get an IMG tag to render is beyond challenging so far. I'll wager nearly impossible with the given components (in AIR Mobile land of course, which is not well documented and conflictive with online sources around the issues, so it is unclear and confusing being fresh out of beta).