Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:55:52+00:00 2026-06-14T12:55:52+00:00

I’m working on a CakePHP 1.3 project in a LAMP environment in which we

  • 0

I’m working on a CakePHP 1.3 project in a LAMP environment in which we store a number of videos outside of /app/webroot/ and serve them up using CakePHP’s Media Views (we do this as we don’t want the files directly accessible). However, I’m having trouble serving these videos up to iOS devices (e.g., iPhone, iPad) via Media Views.

I can place my test video somewhere within /app/webroot/ and access it directly on an iOS device and playback works as expected, so I’m pretty sure it’s not a MOOV problem or another encoding issue with the video itself. As far as I can tell, it’s got something to do with CakePHP’s handling (or lack thereof) of byte-range requests that iOS devices use when loading video.

I found one other Stack Overflow ticket that has unfortunately gone unanswered, but details a similar problem. Looking at the /cake/libs/view/media.php class file, there is an if statement within the render() method that is cued on a check for a $_SERVER['HTTP_RANGE'] value; but as far as I can tell in testing, this value is never being set (at least not when CakePHP looks for it). The offsite solution linked in the aforementioned ticket doesn’t solve my problem as it too relies on a check of this value, which I’ve verified is not being found when checked for either in the Media View class itself, or in the controller that’s setting up said view.

So, has anyone had any luck or experience serving videos up to iOS devices using CakePHP Media Views? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:55:53+00:00Added an answer on June 14, 2026 at 12:55 pm

    After no hits on the various questions I posted around the web, we took another crack at this and were able to figure it out.

    Turns out it’s an issue in the Media.php class file (/cake/libs/view/media.php) with its expectation of the HTTP_RANGE header value, and how it was formatting the subsequent header. First, here’s the original relevant code snippet:

    $httpRange = env('HTTP_RANGE');
    if (isset($httpRange)) {
        list($toss, $range) = explode('=', $httpRange);
    
        $size = $fileSize - 1;
        $length = $fileSize - $range;
    
        $this->_header(array(
            'HTTP/1.1 206 Partial Content',
            'Content-Length: ' . $length,
            'Content-Range: bytes ' . $range . $size . '/' . $fileSize));
    
        fseek($handle, $range);
    }
    

    Note the list() call, which populates a $range value that is then used as if it were numeric. However, after debugging the header calls further, we noticed that the HTTP_RANGE value is actually given as Range: bytes=0-1000 where the given numeric range depends on the request. We made the following changes (and set the download boolean to true on the Media View call), and voila, working video on iOS devices.

    $httpRange = env('HTTP_RANGE');
    if (isset($httpRange)) {
        $start = 0; //start byte
        $end = $fileSize - 1; //end byte
        $length = $fileSize; //content length
    
        $c_start = $start; //default value
        $c_end = $end; //default value
        list($toss, $range) = explode('=', $httpRange); //extract range
    
        //grab range value(s)
        if ($range[0] == '-') {
            $c_start = $fileSize - substr($range, 1);
        } else {
            $range = explode('-', $range);
            $c_start = $range[0];
            $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $fileSize;
        }
    
        //validate end byte
        $c_end = ($c_end > $end) ? $end : $c_end;
    
        //set new values
        $start = $c_start;
        $end = $c_end;
        $length = $end - $start + 1;
    
        $this->_header(array(
            'HTTP/1.1 206 Partial Content',
            'Content-Length: ' . $length,
            'Content-Range: bytes ' . $start . '-' . $end . '/' . $fileSize));
        fseek($handle, $start);
    }
    

    Note that this incorporates much of the logic from Appendix A of this article, which handles a variety of cases. (Initially we eschewed much of this logic, and while playback worked fine, once the end of the file was reached on an iOS device it seemed to be acting a little wonky.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.