Link to home
Start Free TrialLog in
Avatar of badwolfff
badwolfffFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How could I rewrite this php code to load my youtube video in an HTML container rather than a flash container like now?

I have a working PHP code that loads a youtube video inside an iframe which contains a flash player unfortunately.
This is not a desirable situation as I don't want to use flash.

How could I change this code to load the video but inside an HTML5 container that works across all devices?

thanks

<div id="vendor_video" class="cmsms_post_cont col-lg-6 col-sm-6 col-xs-12">

    <h1>Video</h1>
    
    <?php $parsed = parse_url($gallery_link); //echo "<pre>"; print_r($parsed['host']); exit; ?>
    
    <?php if($parsed['host'] == 'www.youtube.com') { ?>
    <?php  $gallery_link = substr($gallery_link, -11); ?>
    <?php $link =  "https://www.youtube.com/v/"."$gallery_link"; ?>			
        <div class="cmsms_video_wrap">				
            <iframe width="522" height="284" src="<?php echo $link; ?>"></iframe>
            <!--<iframe  width="522" height="284" src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=0"></iframe>	-->				
        </div>
    <?php } else { ?>
            <div class="cmsms_video_wrap">				
                <iframe width="522" height="284" src="<?php echo $gallery_link; ?>"></iframe>						
            </div>
    <?php }  ?>
</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The link should be in this format, with ?html5=1 or &html5=1 at the end:
https://www.youtube.com/embed/9RY5Z8qwdqs?html5=1

Like this:
<iframe src="https://www.youtube.com/embed/9RY5Z8qwdqs?html5=1"></iframe>

<div id="vendor_video" class="cmsms_post_cont col-lg-6 col-sm-6 col-xs-12">
    <h1>Video</h1>
    <?php $parsed = parse_url($gallery_link) . "&html5=1"; ?>
    
    <?php if($parsed['host'] == 'www.youtube.com') { ?>
    <?php  $gallery_link = substr($gallery_link, -11); ?>
    <?php $link =  "https://www.youtube.com/embed/". $gallery_link . "?&html5=1"; ?>			
        <div class="cmsms_video_wrap">				
            <iframe width="522" height="284" src="<?php echo $link; ?>"></iframe>
        </div>
    <?php } else { ?>
            <div class="cmsms_video_wrap">				
                <iframe width="522" height="284" src="<?php echo $gallery_link; ?>"></iframe>						
            </div>
    <?php }  ?>
</div>

Open in new window

Avatar of badwolfff

ASKER

I sorted it out myself using video.js
I've requested that this question be closed as follows:

Accepted answer: 0 points for badwolfff's comment #a40805507

for the following reason:

I sorted it out myself using video.js
I sorted it out myself using video.js
Video.js was suggested in my first post.