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

  • SEARCH
  • Home
  • 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 7552741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:51:39+00:00 2026-05-30T10:51:39+00:00

I need to play an embedded video file in my WP7 phonegap application. The

  • 0

I need to play an embedded video file in my WP7 phonegap application. The file (dizzy.mp4) is located in the www folder along with the following layout

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>PhoneGap WP7</title>
    <link rel="stylesheet" href="master.css" type="text/css" />
    <script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
    <script type="text/javascript" charset="utf-8" src="jquery-1.6.4.min.js"></script>
</head>
<body>
    <video onclick="play()">
        <source src="http://html5demos.com/assets/dizzy.mp4" type="video/mp4" />
    </video>
    <video onclick="play()">
        <source src="./dizzy.mp4" type="video/mp4" />
    </video>
</body>
</html>

If the first video element is clicked, the video file is being downloaded from the Internet and all is ok. But after clicking on the second (local video) just a video player screen with ‘Opening…’ label appears. Both videos are the same video file.

The app was run both on an emulator and on a real device (Nokia Lumnia 710 with WF7.5 Mango), the result is the same.

I tried to set different build actions to the video file: Content, Resource, Embedded Resource. It doesn’t help.

How to make it work?

UPDATE: A similar issue is described here. Is it a WP7 bug?

  • 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-05-30T10:51:41+00:00Added an answer on May 30, 2026 at 10:51 am

    Here is a workaround. The following code is a Phonegap command that implements video play back functionality.

    using System;
    using System.IO;
    using System.IO.IsolatedStorage;
    using System.Runtime.Serialization;
    using System.Windows;
    using System.Windows.Controls;
    using Microsoft.Phone.Controls;
    using WP7GapClassLib.PhoneGap;
    using WP7GapClassLib.PhoneGap.Commands;
    using WP7GapClassLib.PhoneGap.JSON;
    
    namespace PhoneGap.Extension.Commands
    {
    
        /// <summary>
        /// Implements video play back functionality.
        /// </summary>
        public class Video : BaseCommand
        {
    
            /// <summary>
            /// Video player object
            /// </summary>
            private MediaElement _player;
    
            [DataContract]
            public class VideoOptions
            {
                /// <summary>
                /// Path to video file
                /// </summary>
                [DataMember(Name = "src")]
                public string Src { get; set; }
            }
    
            public void Play(string args)
            {
                VideoOptions options = JsonHelper.Deserialize<VideoOptions>(args);
    
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        _Play(options.Src);
    
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                    }
                    catch (Exception e)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
                    }
                }); 
            }
    
            private void _Play(string filePath)
            {
                // this.player is a MediaElement, it must be added to the visual tree in order to play
                PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
                if (frame != null)
                {
                    PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
                    if (page != null)
                    {
                        Grid grid = page.FindName("LayoutRoot") as Grid;
                        if (grid != null && _player == null)
                        {
                            _player = new MediaElement();
                            grid.Children.Add(this._player);
                            _player.Visibility = Visibility.Visible;
                        }
                    }
                }
    
                Uri uri = new Uri(filePath, UriKind.RelativeOrAbsolute);
                if (uri.IsAbsoluteUri)
                {
                    _player.Source = uri;
                }
                else
                {
                    using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        if (isoFile.FileExists(filePath))
                        {
                            using (
                                IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filePath, FileMode.Open,
                                                                                                 isoFile))
                            {
                                _player.SetSource(stream);
                            }
                        }
                        else
                        {
                            throw new ArgumentException("Source doesn't exist");
                        }
                    }
                }
    
                _player.Play();
            }
        }
    
    }
    

    There is only the Play function here, but it can be extended to support Stop/Pause/Close ect.

    To register this command on client side:

        <script type="text/javascript">
    
        function playVideo(src) {
    
            PhoneGap.exec(         //PhoneGap.exec = function(success, fail, service, action, args)
                null, //success
                null, //fail
                "Video", //service
                "Play", //action
                {src: src} //args
               ); 
        };
       </script>
    

    To play back the file:

    <a href="#" class="btn" onClick="playVideo('/app/www/dizzy.mp4');">Play</a>  
    

    Pay attention to the path ‘/app/www/dizzy.mp4’.

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

Sidebar

Related Questions

i have to make an application where i need to play two video simultaniously,on
I need to play video file (using installed codecs) and get some file info
I need to play a wav file from a C# application running as a
I need to play a youtube video from my bb application. Does anyone know
I need to play some videos in my application. I am using the following
I need to play a part of an MP3 file in my java code.
i make iPhone web which need to play video.i use video tag for video
I have a video, and I need to play it in my ASP.NET page's
I need to be able to play a RealAudio (.RA) file from Xcode. If
Application names on Google Play don't need to be unique, and it's possible to

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.