why jw player wont be fullscreen? - android

I have a problem with JW player. when I touch fullscreen button in JW player nothing happen and just arrow state change. and when I rotate phone JW become from vertical to horizontal but won't be fullscreen. I check my another app that worked in JW player previously but now they won't work too. (JW can play video without any problem but can't be in fullscreen in no way).
may please help me with this?
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
if (newConfig?.orientation == Configuration.ORIENTATION_PORTRAIT) {
if(jw.fullscreen) {
jw.setFullscreen(false, true)
}
} else if (newConfig?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if(!jw.fullscreen) {
jw.setFullscreen(true, true)
}
}
}
this is my code that controls change rotation in JW player.

If you are using Android 9, you will need to update the JWPlayer SDK at least to 3.4.1 (there was fixed).
Here you can find the answer:
Android - JWplayer Fullscreen not working issue

Related

How to check if webview YouTube video player was started

In my Android app, I have a webview where there is an embedded YouTube video inside the webview. My app has a native AdMob banner.
I'd like to hide the native admob banner from the app when user plays the video, so the banner does not show while the video is playing and then show the ads again when the video stops playing
The issue is that I do not know how to check if the video was started or stopped.
Any idea how this can be done? Thanks much.
One of the suggestions I think of is to set your AdView's visibility to GONE and also call mAdView.pause() the AdView while the video is playing. This should prevent any additional requests being made to AdMob. Once the video is done playing and you want to show your banner again - you should set the AdView's visibility to VISIBLE and call mAdView.resume()
The communication between webview and native are done through JavascriptInterface. YouTube has built it's API in a similar fashion. you can use the below code to achieve what you want.
To achieve the play/pause functionality via Youtube video you can use YouTube JavaScript Player API.
Example:
<div id="video-placeholder"></div>
<script src="https://www.youtube.com/iframe_api"></script>
When the API is fully loaded, it looks for a global function called onYouTubeIframeAPIReady() which you should define.
Your code should look something like this
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('video-placeholder', {
width: 600,
height: 400,
videoId: 'Xa0Q0J5tOP0',
playerVars: {
color: 'white',
playlist: 'taJ60kskkns,FG0fTKAqZ5g'
},
events: {
onReady: initialize
}
});
}
Just make two buttons and call the needed method on click.
$('#play').on('click', function () {
player.playVideo();
});
$('#pause').on('click', function () {
player.pauseVideo();
});
You can use JavascriptInterface to get the callback inside the native java/kotlin code from WebView.
More details info
Youtube javascript player API with example
JavaScript Interface with example
I am using jquery to show my videos along wither other contents and the admob. It should apply to your case too as you are using webview.
You need to detect the event - onPlayerStateChange. Check this question which shows the code and prerequisties:
Check if YouTube video is playing and run script
why don't you use default videoview to play youtube videos it'll make easier communication between admob bannner and played video apply same logic as mentioned by kasiopeous

How to make my Unity 3d (AR) project play in a full screen on my phone?

Testing Augmented Reality made with Unity 3d and vuforia on my android device is not showing in full screen !
I have tried to change everything in unity player settings but nothing changed
i even tried to do a script for the AR Camera
public class fullscreen : MonoBehaviour
{
// Start is called before the first frame update
void Start() =>
// Toggle fullscreen
Screen.fullScreen = !Screen.fullScreen;
// Update is called once per frame
void Update()
{
}
}
but it didnt work
I want to show it in the full screen
check my imageon Android device
If your game is in fullscreen Screen.fullScreen = !Screen.fullScreen; will make your game not fullscreen anymore. Use Screen.fullScreen = true;
Then, under Project Settings -> Player -> Resolution and Presentation check Start in fullscreen mode.

Android HTML5 Video in Fullscreen Mode

I'm trying to get my video stream to work on android in fullscreen mode. For iOS I use a native <video> tag, which works perfectly.
I can play the video on my android, but I don't have a fullscreen button. I also tried to create a own template for the android devices and simply set the width and height of the player to the window size (Fake Fullscreen). The problem I have here is, that when I rotate the device, the resize doesn't work correctly, so that i can scroll over the video.
Heres what I tried:
$(document).ready(function() {
$(window).on('resize orientationchange', function() {
$('#myPlayer').width( $(window).width() ).height( $(window).height() );
});
}
Can anyone help me to get this to work on Android?
I hope you can understand my question, my english isn't that good ...
HTML5 video full screen on mobile browsers (android)
seems the same question.
The events you need are: webkitbeginfullscreen (enter fullscreen) and webkitendfullscreen (exit fullscreen)
var player = document.getElementsByTagName("video")[0];
player.addEventListener('webkitbeginfullscreen', onVideoBeginsFullScreen, false);
player.addEventListener('webkitendfullscreen', onVideoEndsFullScreen, false);

html5 video tag to play full screen with Android

I'm creating a mobile site where I have a video I'd like to play when someone clicks on a link:
<div id="player"></div>
<?php echo $result_videos[$i]["camera_name"]; ?>
<script type="text/javascript">
function DoNav(theUrl)
{
// only add the player if it doesn't yet exist
if($('#myfileplayer').length == 0) {
var mydiv = $("#player");
var myvideo = $("<video id='myfileplayer' src='"+ theUrl + "' width='320' height='240' controls></video>");
mydiv.append(myvideo);
} else {
$('#myfileplayer').attr("src",theUrl);
}
}
</script>
With the iPhone, this works great, I click on video and it goes full screen. Android works as well but it requires you to click the video to play then click on the full screen. Is it possible to get to the full screen like iPhone just when you hit play?
This should work, with plain Javascript:
var myVideo = document.getElementById('myVideoTag');
myVideo.play();
if (typeof(myVideo.webkitEnterFullscreen) != "undefined") {
// This is for Android Stock.
myVideo.webkitEnterFullscreen();
} else if (typeof(myVideo.webkitRequestFullscreen) != "undefined") {
// This is for Chrome.
myVideo.webkitRequestFullscreen();
} else if (typeof(myVideo.mozRequestFullScreen) != "undefined") {
myVideo.mozRequestFullScreen();
}
You have to trigger play() before the fullscreen instruction, otherwise in Android Browser it will just go fullscreen but it will not start playing.
Tested with the latest version of Android Browser, Chrome, Safari.
I've given up on this. My conclusion is that the html5 video tag on Android devices blows chunks. It works in some devices but not on others. And there is no common criteria like 3.x or 4.x, it just seems to be random. I hope this gets better sometime soon especially since flash support is not longer existent.
Oddly sticking with a simple href seems to be the most consistent. You lose some controls but way better than the video tag...at least so far.
Have you checked out mediaelement.js?
Try something along the lines of:
document.getElementById('myfileplayer').addEventListener('play', function (e) { this.mozRequestFullScreen ? this.mozRequestFullScreen() : this.webkitRequestFullScreen ? this.webkitRequestFullScreen() : null; }, false);
Either that or maybe something along the lines of:
document.getElementById('myfileplayer').addEventListener('play', function (e) { this.webkitEnterFullscreen(); }, false);
webkitEnterFullscreen is the fullscreen method of a VIDEO element that is currently working on iOS. I'm not sure about support on Android devices.
mozRequestFullScreen and webkitRequestFullScreen are implementations of Mozilla and Google's FullScreen API which is used to activate full screen mode on practically any DOM element.
Hopefully that gives you at least a starting point to work from...
Most vendors require user interaction to go full screen, which is why natalee's answer doesn't work. For Andriod, you can call webkitEnterFullScreen() inside your anchor's click handler since it's a valid user interaction:
myvideo[0].webkitEnterFullScreen();
myvideo[0].play();
or
$('#myfileplayer')[0].webkitEnterFullScreen();
$('#myfileplayer')[0].play();
Note how I'm stripping jQuery's wrapper with [0]. It doesn't work otherwise.

Cocos2d Game Lost Focus When we click Volume Up or Volume Down Button On Motorola xoom

I am developing a game using Cocos2d FrameWork in Android.
I encountered a problem while testing on Motorola Xoom.
What I want to do :
When User pressed Volume up and Volume down Button. All the Animation should play with sound .
But What actually Happened:
When I pressed volume up down button on Motorola Xoom than My Game Lost Focus and all Animation Paused but sound is playing according to the volume button settings.
This is only when I test my Application in Honey Comb OS.
I am using onWindowFocusChanged method to Resume Game Play.
Anyone having encounter this type of problem ?
Please let me know if anyone have solution for this .
Thanks.
i found answer myself ..
Here is the solution of this issue ..
public void onWindowFocusChanged(boolean hasFocus)
{
synchronized(sGLThreadManager) {
//mHasFocus = hasFocus;
mHasFocus = true;
sGLThreadManager.notifyAll();
}
if (LOG_SURFACE)
{
Log.i("Main thread", "Focus " + (mHasFocus ? "gained" : "lost"));
}
}
just change mHasFocus = true in GLSurfaceView class of Cocos2d android ...

Categories

Resources