Welcome! › Forums › Unity Plugins › In-App Web Browser › Back Button In front of page › Reply To: Back Button In front of page
July 12, 2017 at 2:50 pm
#268
Zeldarck
Participant
Ok, I have do that :
<script>
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
function isIOS() {
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return true;
} else {
return false;
}
}
function isAndroid() {
return (/android/i.test(userAgent));
}
In
function sendMessageToUnity(message) {
if (isIOS()) {
appendIframeWithURL('inappbrowserbridge://' + message);
} else if (isAndroid()){
UnityInAppBrowser.sendMessageFromJS(message);
}
}
</script>
<div style='position:absolute;left:0;right:0;top:0px;bottom:0;overflow:auto;'>
<button type="button" onclick="sendMessageToUnity('message')" style = "
border-radius: 8px; border: none; padding: 0em 1em;
color: white;
font-size: 16px;position: absolute;top: 10px;left: 10px;background-color: #000000;height: 30px;">X</button>
<iframe id="ytplayer" type="text/html" width="640" height="360"
src="http://www.youtube.com/embed/kQye2uNafk0?autoplay=1&controls=0&rel=0&showinfo=0&cc_load_policy=1&hl=ru&fs=1"
frameborder="0" style="margin:0px;padding:0px;"/>
</div>
void Start(){
InAppBrowserBridge bridge = FindObjectOfType<InAppBrowserBridge>();
bridge.onJSCallback.AddListener((string s) => OnCloseBrowser());
}
public void OnCloseBrowser()
{
StartCoroutine(CloseYouTubeVideo());
}
protected IEnumerator CloseYouTubeVideo()
{
InAppBrowser.CloseBrowser();
Screen.orientation = ScreenOrientation.Portrait;
while (Screen.currentResolution.height > Screen.currentResolution.width)
{
yield return null;
}
UICommander.ShowAll();
}
protected IEnumerator PlayYoutubeVideo()
{
yield return new WaitForSeconds(1);
UICommander.HideAll();
Screen.orientation = ScreenOrientation.Landscape;
while (Screen.currentResolution.height > Screen.currentResolution.width)
{
yield return null;
}
InAppBrowser.DisplayOptions displayOption = new InAppBrowser.DisplayOptions();
displayOption.displayURLAsPageTitle = false;
displayOption.hidesTopBar = true;
InAppBrowser.OpenLocalFile("test.html", displayOption);
}
still not very beautiful, if you have a better mean, I’m open to 🙂
- This reply was modified 7 years, 2 months ago by Zeldarck.