I can't set width and height of video player - livecode - livecode

I want to set width and height of my video player.
Here my code.
put the text of fld "txt_width" into w_value
put the text of fld "txt_height" into h_value
set the width of player ID idplayer of stack stackname to w_value
set the height of player ID idplayer of stack stackname to h_value
And I set autoplay on opencard.Before autoplay video.Width and Height is working.After opencard and video play.Width and Height of video is resize to original.
How do I do ?

Try setting the lockLocation of the player object to true to stop the player resizing automatically;
set the lockLocation of player id idPlayer to true

Related

What is the code for each click on a button makes the image 2 times smaller in livecode?

I need an easy code for a push button that makes an image 2 times smaller with each click in livecode
the image is 300 width 300 height
Lets say the name of your image is myImage
set the width of image "myImage" to the width of image "myImage" /2
set the height of image "myImage" to the height of image "myImage" /2
Here is one way you could do it. Create a custom command handler in your card or stack script:
command resizeImage pImgName, pResizeFactor
set the resizeQuality of image pImgName to "good"
set the width of image pImgName to the width of image pImgName * pResizeFactor
set the height of image pImgName to the height of image pImgName * pResizeFactor
end resizeImage
In a button, or even in the image object script, write a mouseUp handler:
on mouseUp
resizeImage "imageNameHere", .5
end mouseUp
Of course you would put the actual name of the image in place of "imageNameHere".
I've checked out the older anwers and I think they forget to make sure that the image stays in the same location. I'm also adding a lock screen command. You may omit this if you think it slows down the button too much.
You can put the mouseUp handler into script of the button and the resizeImage handler anywhere higher up the message hierarchy or in the script of the button itself.
on mouseUp
lock screen
resizeImage the long id of img 1
unlock screen
end mouseUp
on resizeImage theImg
put the loc of theImg into myLoc
set the width of theImg to the width of theImg / 2
set the height of theImg to the height of theImg / 2
set the loc of theImg to myLoc
end resizeName
You need to adjust the long id of img 1 to make sure it changed the size of the correct image, for instance use the long id of img id 69456 if the short id is 69456 or the long id of img "my image" if the name of the image is "my image".

How to create player with command "mobileControlCreate" in group? - Livecode

I want to create the player in group on mobile.
I use this command "mobileControlCreate" for create player.
Here my code:
mobileControlCreate "player", "videoControl"
mobileControlSet "videoControl", "filename", specialFolderPath("engine") & "/vdo.mp4"
mobileControlSet "videoControl", "preserveAspect", true
mobileControlSet "videoControl", "showController", true
mobileControlSet "videoControl", "visible", true
mobileControlSet "videoControl", "rect", the rect of grp "o_c2"
How do I do?
Native controls float above the stack and are not part of the card, so - unfortunately - you can't place them in a group.
Use mobileControlCreate to create a player, as you currently do. Now use mobileControlCreate to create a scroller.
local lMovieScrollerID // declare outside handler
on createScroller
mobileControlCreate "scroller","Movie Scroller"
put the result into lMovieScrollerID
mobileControlSet lMovieScrollerID,"rect",the rect of this cd
put the rect of this cd into myRect
put item 3 of myRect * 2 into item 3 of myRect
put item 4 of myRect * 2 into item 4 of myRect
mobileControlSet lMovieScrollerID,"contentRect",myRect
end createScroller
The createScroller handler creates a scroller that can scroll over an area that is 4 times as large as your card. Therefore, you can scroll your movie exactly off screen. You will need to experiment to find out what kinf of rect (the value of myRect) you actually need.
In the next handler, let's assume that the rect of your group is 100,100,200,200.
on scrollerDidScroll theScrollH,theScrollV
put "100,100,200,200" into myInitialRect
add theScrollH to item 1 of myInitialRect
add theScrollH to item 3of myInitialRect
add theScrollV to item 2 of myInitialRect
add theScrollV to item 4 of myInitialRect
// obviously myInitialRect is no longer "initial" here
set the rect of grp "o_c2" to myInitialRect
mobileControlSet lMovieScrollerID,"rect",myInitialRect
end scrollerDidScroll
It should be clear that these handlers are untested and need some experimentation, but I am pretty sure that this is the path you'll have to follow.

why check box does not move when stack is resized?

I made a stack that displays lines of text that change their width when the stack is resized.
The Category columns is changing its position on resizing but the check box does not.
What am I missing in the code? What changes have to be made?
See the code in the stack that can be downloaded here:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form-variable%20line%20height%2Bcheckbox.zip
Thanks in advance.
keram
If I understand what you are trying to achieve here then in your LayoutControl handler make the following change:
-- put the rect of btn "btnCheck" of me into theFieldRect
-- put item 3 of pControlRect - 5 into item 3 of theFieldRect
-- set the rect of btn "btnCheck" of me to theFieldRect
set the left of btn "btnCheck" of me to the right of fld "cat" of me
However I think the resizing of the Cat field is wrong too. Try something like:
on LayoutControl pControlRect
set the right of btn "btnCheck" of me to item 3 of pControlRect-4
set the right of fld "Cat" of me to the left of btn "btnCheck" of me
get the rect of fld "Line" of me
put the left of fld "Cat" of me into item 3 of it
set the rect of fld "Line" of me to it
put the formattedHeight of fld "Line" of me + item 2 of it into item 4 of it
set the rect of fld "Line" of me to it
put item 4 of it into item 4 of pControlRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
To edit the LayoutControl script you need to open the datagrid property inspector and click on the Row Behavior... button. This will present the script editor for the behavior of the row template.
Because the DataGrid doesn't have this feature. If you would use the Geometry manager, the GM propeties are not copied from the checkbox in the template to the checkboxes in the actual DG. So, the GM won't work. Perhaps you could write a script of your own that sets the right of all checkboxes to a position relative to the width of the card:
on resizeStack
lock screen
repeat with x = 1 to number of buttons
if the style of btn x is "checkbox" then
set the right of btn x to the width of this cd - 100
end if
end repeat
unlock screen
end resizeStack
Unfortunately, this doesn't work with the datagrid either, because the DG also does some (or a lot) resizing of its own.
It would be much easier to create your own.

How can I get the screen width and length in android?

I want to display 9 buttons in the middle of the display, three on each row. In conclusion a big square that is composed from 9 little buttons displayed in the middle of the screen.
So I think I need to know the screen size to display buttons.
you only need to use Tablelayout or Linerlayout for this.but if need to know screen size it get as following :
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
If you're not in an Activity you can get the default Display via WINDOW_SERVICE:
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

How to get screen height in LWUIT out of height reserved for MenuBar and TitleBar?

I want to get the height and width of the screen which I could draw objects on. It's the space which is other than the the MenuBar (the footer containing commands) and other than the TitleBar.
TIP: I know that Display.getInstance().getDisplayHeight() returns the height of the screen but this is for the full sceen. So how could I, at least, know the height of the MenuBar and TitleBar to substract them from this height ?
I found the answer for those who are interested:
To get the height of TitleBar: Form.getTitleComponent().getPreferredH()
To get the height of AddressBar: Form.getSoftButton(0).getParent().getPreferredH()
So the answer of my question is:
Display.getInstance().getDisplayHeight()
- form.getTitleComponent().getPreferredH()
- (getSoftbuttonCount() < 1) ? 0 : form.getSoftButton(0).getParent().getPreferredH()

Resources