1

this will be my first question. Sorry for mistakes.

Following code works in IE9 and Opera but does not work in Firefox.

In Firefox, I am clicking another link and going back to the page that contains the video then video is starting. Otherwise, video is not starting. (again not starting when refreshing the page)

function output_video_URL(id, local_path_of_video, remote_path_of_video) {
    var http_check = getHTTPObject();

    var local_URL = local_server + local_path_of_video;
    var remote_URL = remote_server + remote_path_of_video;

    http_check.open("HEAD", local_path_of_video);
    http_check.onreadystatechange = handleHttpResponse_check;
    http_check.send(null);


    function handleHttpResponse_check() {
        if (http_check.readyState == 4){
            if (http_check.status == 200) {
                var video = document.getElementById(id);
                video.src = local_URL;
                video.parentNode.Filename = local_URL;
            }
            else if (http_check.status == 404) {
                var video = document.getElementById(id);
                video.src = remote_URL;
                video.parentNode.Filename = remote_URL;
            }
        }
    }
}

HTML:

<object width="364" height="266" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="mediaplayer1">
  <param name="Filename" value="filmler/canakkeleklipkucuk.wmv" />
  <param name="AutoStart" value="True" />
  <param name="ShowControls" value="false" />
  <param name="ShowStatusBar" value="false" />
  <param name="ShowDisplay" value="false" />
  <param name="AutoRewind" value="false" />
  <embed id = "canakkeleklip" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" width="320" height="240" src="filmler/canakkeleklipkucuk.wmv" autostart="True"  showcontrols="false" showstatusbar="false"  showdisplay="false" autorewind="false"> </embed>
</object>
<script type = "text/javascript"> output_video_URL('canakkeleklip', 'videos/canakkeleklipkucuk.wmv', 'filmler/canakkeleklipkucuk.wmv') </script>
Marcin Gil
  • 62,506
  • 8
  • 57
  • 60
rasitburak
  • 11
  • 2
  • _In Firefox, I am clicking another link_ Where code of this link? It's a html anchor or ? – Andrew D. Sep 26 '11 at 10:11
  • What is difference between `local_server` and `remote_server`. They both `http:` ? Where from loaded page with above content: from remote or from local server? – Andrew D. Sep 26 '11 at 10:19
  • @Andrew D. they are two different url. I am checking if the video exists on local_URL. If video doesn't exist on local then I am checking the remote_URL. – rasitburak Sep 26 '11 at 12:48

1 Answers1

0

The problem is with how you try to set the Filename property. It's not an attribute of the object element, it's an element inside it. (The reason that it works in IE and Opera is that they use the embed element, not the object element.)

Assuming that the Filename parameter is the first one, you can use this to set it:

video.parentNode.getElementsByTagName('param')[0].value = local_URL;

If you don't know the order of the parameter elements, you would have to loop the child nodes and check for the one with the right name attribute.

Edit:

However, even when actually changing the the parameter value it won't work, as the object is already created. See Is it possible to change the file path of the video using javascript?

Community
  • 1
  • 1
Guffa
  • 640,220
  • 96
  • 678
  • 956
  • Thanks for reply but it does not change anything. video is not playing unless going forward and back. – rasitburak Sep 26 '11 at 09:13
  • @rasitburak: The difference is that you access the correct value, but there is another problem with that as you can't change the value once the object is created. See http://stackoverflow.com/questions/2857381/is-it-possible-to-change-the-file-path-of-the-video-using-javascript You will have to create a new `object` element with the new settings. – Guffa Sep 26 '11 at 11:21