Troubleshooting HTML5 Video Playback on a Meteor iOS App

I am currently developing an iOS application using Meteor that requires the playback of locally stored mp4 files. However, I am facing an issue where the mobile app is not displaying any videos.

Here is the template I am using:

<template name="video">
{{#if cordova}}
    Mobile Player

    <video webkit-playsinline id="example_video_1" width="50%" height="20%">
        <source src="/my_vid.mp4" type="video/mp4">
    </video>

 {{else}}
    Desktop

         <video control id="example_video_1" width="50%" height="20%" src="/my_vid.mp4">
        </video>

{{/if}}
</template>

While the video plays fine in the desktop version, I am encountering difficulties with getting it to work on the iOS version.

This is the Video.js code corresponding to this issue:

if(Meteor.isClient)
{
Template.video.rendered = function()
{

    videojs("example_video_1",
      {
        "controls" : true,
        "autoplay": true,
        "techOrder" : ["html5", "flash"],
        preload: "auto"
      },
        function()
        {

        }
    )
}

Template.video.helpers({
    cordova: function()
    {
        getBlobURL("/my_vid.mp4", "video/mp4", function(url, blob) 
        {
            $("video")[0].src = url
        });

        return Meteor.isCordova;
    }
})

function getBlobURL(url, mime, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open("get", url);
  xhr.responseType = "arraybuffer";

  xhr.addEventListener("load", function() {
    var arrayBufferView = new Uint8Array( this.response );
    var blob = new Blob( [ arrayBufferView ], { type: mime } );
    var url = window.URL.createObjectURL(blob);

    callback(url, blob);
  });
  xhr.send();
}
}

The following snippet provides a solution sourced from this StackOverflow question. Despite attempting to implement this solution, I have not been able to resolve the issue so far.

I also followed the instructions outlined here, by adding a config.xml and mobile-config.js file, but the problem persists.

It appears that the root cause might be Cordova setting an incorrect MIME-type, and while the previously mentioned SO solution seemed promising, I have had no luck getting it to work. Any guidance or assistance on this matter would be highly appreciated.

Answer №1

Generating a Blob URL for your video is the way to go, just make sure that your iOS version is above 8.1.2.

I made the jump to 8.2 and found that my code worked perfectly afterwards.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tried utilizing express to log URL parameters, but to no avail as it did not show any output on the console

Whenever I enter /posts/whatever at the end of the root URL, it doesn't log what comes after /posts to the console. app.get("/posts/:userId", function(req, res) { console.log(req.params.userId); }); Update: Here's the complete code: ...

Using a ternary operator to render a span tag in ReactJS

I need to display a number in a span tag with larger font size in Spanish. Here is my React.js code using a ternary operator: <div> {togo !== 0 ? (<div className="text-center"><span className="display-4">{togo}</span>{togo > ...

Using jQuery to dynamically add a value to a comment string

Is there a way to dynamically include tomorrow's start and end times in the message for the setupOrderingNotAvailable function if today's end time has passed? The current message states that online ordering will be available again tomorrow from 1 ...

Shadows in Three.js cascading onto clear surfaces with a low-resolution twist

Here's the problem I'm facing: I want to remove the shadows on the text but changing the shadowMap resolution doesn't seem to have any effect. This is the code snippet responsible for creating the mesh: var materialArray_Flying = [ ...

The jQuery inArray function fails to detect a match when the first element is the one being compared

I want to create an array and check if a specific value is present anywhere in the array. Depending on the presence of the value, I need the code to execute different actions. var Arr = [false, false, false, false, false]; // Works with this array: // Arr ...

Directing to a new page with Jquery

Is there a way to redirect to a new page when I click the edit button? Instead of displaying the data in a modal, I want it to open in a separate webpage. $sQuery = " SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns)) . " ...

What methods can be used to continuously send data to another web page within my website using XMLHttpRequest()?

As I delve into working with node.js and express.js, my primary goal is to efficiently tackle a specific issue. One of the pages on my website is tasked with receiving location data in latitude var lat and longitude var long. The challenge at hand is to c ...

What is the proper way to retrieve the value of the key "order" from this JSON object (containing semicolons in the name)?

Vijay Anand inquired about this particular matter yesterday, unfortunately, the discussion was closed before receiving any solutions: HTTP Response: { "entry": { "@xml:base": "https://API_PROC_SRV/", "@xmlns": "http://www.w3.org/2005/Atom", ...

Determining the position coordinates of an element in relation to the viewport using JavaScript, regardless of its relative positioning

I am currently developing a vueJs web application and I'm in need of determining the position of an element within my web app relative to the viewport itself, rather than its parent elements. I'm curious if there exists a function or property tha ...

What is the purpose of $ and # in the following code snippet: $('#<%= txtFirstName.ClientID%>')

$('#<%= txtFirstName.ClientID%>').show(); Attempting to pass the ClientId as a parameter from server tags to an external JavaScript file. <input type="text" ID="txtFirstName" runat="server" maxlength="50" class="Def ...

What is the file's location on an iPhone once it has been added to it through iTunes?

Enabling the feature known as iTunes file sharing support for the application, allows me to import files (such as images) into my device through iTunes. I am curious about the specific location of these files on my device and if there are methods to a ...

What is the best way to change a string into a file object?

The data format that I transmitted from the frontend to the server is in string form For example: "type": 'application/zip', "type":"image/png" "{"id":"4c1vjx4k1", "name" ...

Issue NG0203 encountered during material import attempt

I've been encountering an issue with importing material. Despite using code similar to the examples on material.angular.io, I keep running into the ""inject() must be called from an injection context..." error. My goal is to create a simple table ...

What is the best method to determine the accurate height of a window that works across all browsers and platforms?

Is there a way to accurately determine the visible height of the browser window, taking into consideration any floating navigation bars or bottom buttons that may interfere with the actual viewing area? For example, mobile browsers often have floating bar ...

What is the best way to generate a random item when a button is clicked?

I'm currently working on a feature in my component that generates a random item each time I access the designated page. While the functionality is set to automatically refresh and showcase a new random item, I am now looking to trigger this action man ...

3D Animation for All Browsers

I'm currently working on creating a small browser-based game and I've been experimenting with animations to get the desired effect. So far, the animation works well in Opera and Edge, although there is a slight cropping issue in Edge. Unfortunat ...

PlateJS: Transforming HTML into data

Trying to implement a functionality where clicking on a button retrieves an HTML string. The objective is to have this rich text editor within React-Hook-Form, and upon form submission, the value will be saved as HTML for database storage. Below is the pr ...

Unable to eliminate UI component by clicking in Angular

I have been experimenting with different examples and attempted a few methods, but I am struggling to remove items from the UI level. I attempted to use the *ngFor directive, however, it seems to only remove <span> elements and not the <button> ...

Transferring and bringing in components in React without ES6

I'm currently working on a react project and I want to export my ShoppingList class. However, I prefer not to use ES6 as I find it confusing. Here is the code for the ShoppingList class: class ShoppingList extends React.Component { render() { ...

Swiper.IO pagination indicators not displaying

Why is the pagination not showing up on the image carousel I created with Swiper? Despite being in the DOM, it has a height of 0 and manual changes have no effect. Any suggestions? import Swiper from '../../vendor/swiper.min.js'; export default ...