Titanium: Youtube video - iphone

How can I show a youtube or bits on the run video full screen on my app? Is there a special link I have to naviate to? Or is there a special API that takes care of that to view it fullscreen?
The idea is to click on a link 'show video', then show the video fullscreen, and get a button play pauze and 'done'. When clicked done it goes back to the previous page.
I don't know how to get started on this one. Can anyone help me out?
I'm creating an iPhone app.
Thanks!

#Muhammad has the first part right but to get it to close when you hit the blue done button you'll need the following code.
replace
win.add(activeMovie);
activeMovie.play();
with
win.add(activeMovie);
activeMovie.fullscreen = 1; // this must be defined after you add to the window!
activeMovie.play();
then add this
activeMovie.addEventListener('fullscreen', function(e) {
if(!e.entering) { // this is run only when exiting fullscreen aka the blue done button
activeMovie.stop();
}
});

Here is a an example code to show video with controlls
var win = Titanium.UI.currentWindow;
var contentURL = 'http://movies.apple.com/media/us/ipad/2010/tours/apple-ipad-video-us-20100127_r848-9cie.mov';
var activeMovie = Titanium.Media.createVideoPlayer({
contentURL: contentURL,
backgroundColor:'#111',
movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL
});
win.add(activeMovie);
activeMovie.play();
Hope this will help.

Related

Unity 2D Button-Image color-swap causes image to disappear

I have a function ("ChangeAudio") wherein I toggle the sounds attached to it.
The audio toggling works fine, but I also have a button in the UI that when clicked, calls the audio toggle. Again this works fine. My problem is that when the audio is toggled I've added logic to swap the color of the buttons image to show a disabled state. The swap works, I can see it swap in the inspector, but the issue is that after the first click the image is no longer visible.
Here's the function:
public void ChangeAudio() {
Audio = !Audio;
if (Audio) {
soundIMG.color = enabled_color;
}
else {
soundIMG.color = disabled_color;
}
MM.AsDie.mute = !Audio;
MM.AsJump.mute = !Audio;
}
I hope that I've given all materials needed, if not please kindly let me know.
It looks like it should be working, why are the images disappearing?
Check alpha colors in the images

Restarting carousel event paused on iPad and iPhones

I recently worked out a solution to another problem involving carousels on another post, but I found one issue when it comes to restarting the auto transitions from panel to the next on iPhones and iPads. (They won't restart.)
Here's a link to my original post and solution: Vanilla JS carousel next/prev button killing mouseover event pause
Here's a link to a JSFiddle containing my solution: https://jsfiddle.net/npzu90do/
After posting that solution I found that everything worked as it should accept the auto transition from one panel to the next stopped if you ever clicked the 'Prev' and 'Next' buttons on the sides. So I added this code to help restart the auto panel movement if you clicked outside the carousel.
document.getElementsByTagName("body").onclick = function(e) {
if(e.target != document.getElementById('carousel')) {
intervalID=setInterval(carouselPlus,speed,1)
}
}
Which works perfectly on all browsers except if you are on an iPad or iPhone.
I tried adding the following but that stopped the carousel from auto-starting due to errors in all browsers.
let touchEvent = 'ontouchstart' in window ? 'touchstart' : 'click';
document.getElementsByTagName("body").addEventListener(touchEvent, function(e) {
if(e.target != document.getElementById('carousel')) {
intervalID=setInterval(carouselPlus,speed,1)
}
});
Any suggestions?

RE:Create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?

After seeing #catherinelagoon's post I also having difficulty in quite understand how to replace an object using a button so is it possible to create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?
I tried using the answer provided in the post however I couldn't understand it much due to I'm a beginner in using Smartface App Studio and coding itself.
Thankyou and sorry for any inconvienience
After you create an image you should add it to a Page so it can show on that page. So here is a simple code for creating and showing an image on the page.
var image = new SMF.UI.Image({
visible: false
});
Pages.Page1.add(image);
function Page1_TextButton1_OnPressed(e) {
image.visible = true;
}

Open File Picker in snap view of Metro Style App

When I try to open file picker on snap view in Metro Style App, exception occurs and exception dialog box was shown. How to solve that problem? Is there any good idea? I want my app works properly even on snap view.
Before opening the file picker, you must try to leave the snapped mode.
Here is the code I use:
var ready = true;
if (ApplicationView.Value == ApplicationViewState.Snapped)
ready = ApplicationView.TryUnsnap();
if (!ready)
return;
The SDK samples available on msdn use the following snippet
// FilePicker APIs will not work if the application is in a snapped state.
// If an app wants to show a FilePicker while snapped, it must attempt to unsnap first
bool unsnapped = ((ApplicationView::Value != ApplicationViewState::Snapped) || ApplicationView::TryUnsnap());
if (!unsnapped)
{
// Unsnapping failed
}

Take multiple pictures using Titanium/Appcelerator on iPhone

I am working on a small iPhone app using Titanium/Appcelerator. Now what I am trying to do is the following:
Open the camera to take a picture
Ask the user if he wants to add another picture (OptionDialog)
Open the camera again
{loop here}
Put the images (saved locally) into an array
I tried putting a OptionDialog into the success event of the camera, but it didn't work as expected.
maybe something like that.
dialog.addEventListener('click',function(e){
switch (e.index){
case 1:
takeAPicture();
case default:
...
};
});
function takeAPicture(){
Titanium.Media.showCamera({
success: function(evtSuccess) {
dialog.show();
},
...
});
};
Titanium.Media.takePicture();
what happened putting it into the success event? what exactly did you put into? i would put the
dialog.show();
into the success event too