I am trying to develop flash plugin, which will print some text on player. My question is how to do that? I mean is there any function that will put some text on player?
2 Answers
JWPlayer supports SRT files (subtitles) , so you can create this file to put text on your videos, if you need these text be generated , you can do it maybe using PHP and then giving the output url
you can find more information how to add subtitles on their official website
Other way can be just using a combination of CSS and Javascript to add text on the videoplayer container
There's no built-in function to display a text for the player but it should be pretty easy to do by yourself.
First, here's JWPlayer's documentation for creating a flash plugin.
Then what you want to do is add a sprite and a textfield to the plugin's display.
First, you'll need to import the relevant flash classes in the beginning of your .as file.
import flash.text.TextField
import flash.text.TextFormat;
import flash.display.Sprite;
Then you want to create a Sprite and and a TextField. Put the TextField inside the Sprite, and the Sprite inside the player's display control.
var textHolderSprite:Sprite = new Sprite();
var displayText:TextField = new TextField();
displayText.width = 200; // set size of your text field
displayText.height = 300;
displayText.x = 50;//and position it.
displayText.y = 100;
displayText.text = "hello world";//set the text you want to display.
displayText.wordWrap = true; // wrap text if you want to.
displayText.selectable = false; //probably want to make it not selectable.
displayText.textColor = 0xFFFFFF; //set the text colour;
//bonus: set font size and alignment; look at TextFormat documentation for more options.
var displayTextFormat:TextFormat = new TextFormat();
displayTextFormat.size = "17";
displayTextFormat.align = "center";
displayText.setTextFormat(displayTextFormat);
//put the TextField inside the sprite.
textHolderSprite.addChild(displayText);
//the following api object, is a com.longtailvideo.jwplayer.player.IPlayer object, as described in the JWPlayer plugin documentation.
var displayControl:MovieClip = (api.controls.display as MovieClip); //get the player's display control.
displayControl.addChild(textHolderSprite);//add youre sprite.
//When you're done with the text, don't forget to remove the sprite.
displayControl.removeChild(textHolderSprite);
Good luck!