window.onkeydown = onKeyDown; function onLoad() { is = toi.informationService; ss = toi.schedulerService; aos = toi.audioOutputService; vos = toi.videoOutputService; fps = toi.frontPanelService; ams = toi.assetManagerService; GetSettings(); createPlayer(); createEitCache(); if(pipPlayer){ addPipVideoplane(); createPip(); } if(PipSwitchGuide){ createPip(); } embedTeletextPlugin(); aos.setVolume(AudioOut, StartVolume); aos.setMuteState(AudioOut, false); showDisplay(currChan.toString(), false, 100, 0 ); //if box is in standby don't start a stream. if (is.getObject("var.io.state") == "normal") { play(channels[currChan]); } if (EPGMode) { eitCache.setFilterMode(eitCache.FILTER_MODE_PF_AND_SCHEDULE); } else { eitCache.setFilterMode(eitCache.FILTER_MODE_PF_ONLY); } eitCache.addEventListener(eitCache.ON_CACHE_UPDATED, onCacheUpdated); mediaPlayer.addEventListener(mediaPlayer.ON_DATA_AVAILABLE,onDataAvailableEvent); mediaPlayer.addEventListener(mediaPlayer.ON_STATE_CHANGED, MPD); if (is.getObject("var.capabilities.dvr") == "FALSE") { mediaRecorder = 0; // No harddisk, no recorder functions possible } if (is.getObject("config.architecture.target") !== "vip1903" && fullupdate !== 2) { fullupdate = 0; // No 19x3 so better turn fullupdate EPG off } if (mediaRecorder) { createRecorder(); mediaRecorder.addEventListener(mediaRecorder.ON_STATE_CHANGED, onRecorderStateChanged); om = toi.assetManagerService.getAssetOperationManager(); //toi.OperationManager; rma = om.createOperation("Remove Asset"); } is.addEventListener(is.ON_OBJECTS_CHANGED, onEvent); is.subscribeObject(onEvent, "var.io.state", true); ss.addEventListener(ss.ON_SCHEDULED_START, onScheduledStart); ss.addEventListener(ss.ON_SCHEDULED_STOP, onScheduledStop); ss.setCategorySubscription(onScheduledStart, "*"); ss.setCategorySubscription(onScheduledStop, "*"); setOSDscale();// Still used in 'guide_view.js' setOSDtimer(); showOSD(); videoplane.subtitles = Boolean(ShowSubs); colorkeys.innerHTML = "
" + " " + NN[4] + " " + NN[1] + " " + NN[2] + " " + NN[5] + ""; medialist.innerHTML = "
\n" + Lang[90] +"\n\n"; // Non free channel message switchtimer.style.opacity = 1; CAdelayID = setTimeout("switchtimer.style.opacity = 0;",ShowSetTimer); } } } function startTimeshiftBuffering() { // check that media player is working if (mediaPlayer.getState() != mediaPlayer.STATE_PLAYING ) { alert("Media Player must be playing when starting timeshift buffering!"); return; } mediaPlayer.startTimeshiftBuffering(600); } function FullScreen() { videoplane.style.width = "100%"; videoplane.style.height = "100%"; videoplane.style.left = "0px"; videoplane.style.top = "0px"; if(PipSwitchGuide){ if (pipPlayer.getState() != pipPlayer.STATE_IDLE) { pipPlayer.close(); } } } function onKeyDown(event) { //show key info, needed when a 'new' remote is used //alert( "keyIdentifier : " + event.keyIdentifier +"\n"+"ctrlKey : " + event.ctrlKey +"\n"+"altKey : " + event.altKey +"\n"+"shiftKey : " + event.shiftKey +"\n"+"RAW : " + event ); if(isVisible) { onKeyTeletext(event.keyIdentifier); } else if(isSetupMenu) { onKeyMenu(event.keyIdentifier); } else if(isMediaMenu) { onKeyMedia(event.keyIdentifier); } else { switch(event.keyIdentifier) { case KEY_UP1: case KEY_UP2: case KEY_UP: if(isFullscreen) { count = 0; Change = 0; prevChan = currChan; do { incChan(1); } while (!channels[currChan]); play(channels[currChan]); } else { // swap up <> down in guide mode count = 0; Change = 0; do { decChan(1); } while (!channels[currChan]); preview(channels[currChan]); } break; case KEY_DOWN1: case KEY_DOWN2: case KEY_DOWN: if(isFullscreen) { count = 0; Change = 0; prevChan = currChan; do { decChan(1); } while (!channels[currChan]); play(channels[currChan]); } else { // swap up <> down in guide mode count = 0; Change = 0; do { incChan(1); } while (!channels[currChan]); preview(channels[currChan]); } break; case KEY_LEFT2: case KEY_LEFT: count = 0; Change = 0; if(isFullscreen) { defChan[ChanGroup] = currChan; do { do ChanGroup -= 1; while (protChn[ChanGroup] == 1 && ShowProtectedChannels == 1) if (ChanGroup < 0) { ChanGroup = 9; } } while (!minChan[ChanGroup]); currChan = defChan[ChanGroup]; play(channels[currChan]); } else { prevChan = currChan; if (currChan > (minChan[ChanGroup] + 8)) { decChan(9); } else { currChan = baseChn[ChanGroup] + (maxChan[ChanGroup] - currChan); } do { decChan(1); } while (!channels[currChan]); preview(channels[currChan]); } break; case KEY_RIGHT2: case KEY_RIGHT: count = 0; Change = 0; if(isFullscreen) { defChan[ChanGroup] = currChan; do { do ChanGroup++; while (protChn[ChanGroup] == 1 && ShowProtectedChannels == 1) if (ChanGroup > 9) { ChanGroup = 0; } } while (!minChan[ChanGroup]); currChan = defChan[ChanGroup]; play(channels[currChan]); } else { prevChan = currChan; if (currChan < (maxChan[ChanGroup] - 9 )) { incChan(9); } else { currChan = baseChn[ChanGroup] + (maxChan[ChanGroup] - currChan); } do { incChan(1); } while (!channels[currChan]); preview(channels[currChan]); } break; case "Red": if(isFullscreen) { if(showClock == 0 ) { showDisplay("", true, 80, 1 ); showClock = 1; } else if(showClock == 1 ) { showClock = 0; showDisplay(currChan.toString(), false, 100, 0 ); } } else if(isSchedule == 0){ if(NowNext) { settimer(EPG[1][2][currChan],EPG[1][1][currChan],0,1,"",(EPG[1][4][currChan] + EPG[1][5][currChan]),EPG[1][6][currChan].toString()); } } break; case "Green": if(isFullscreen) { if(!epgactive) { if (audio_dyn < (lang_prio_dyn.length -1)) { audio_dyn += 1} else { audio_dyn = 0 } if (lang_prio_dyn.length > 1) { is.setObject("cfg.media.audio.languagepriority",lang_prio_dyn[audio_dyn] + "," + lang_prio[audio],is.STORAGE_PERMANENT); osdlang.style.opacity = 1; osdlang.innerHTML = "
" + ""; setTimeout("osdlang.style.opacity = 0; ", 3000); } } } else if(isSchedule == 0 && !epgactive){ colorkeys.innerHTML = "\n" + lang_prio_dyn[audio_dyn] + "
" + " " + NN[3 + NowNext] + " " + NN[NowNext] + " " + NN[2] + " " + NN[5] + ""; NowNext = 1 - NowNext; showChannelList(); } if(epgactive) { NowNext = 1 - NowNext; osdepginfo.style.opacity = 1 - osdepginfo.style.opacity ; osdepginfonext.style.opacity = 1 - osdepginfo.style.opacity; } break; case "Yellow": if(isFullscreen) { if(epgactive) { epg_unactive(); } medialist.style.opacity = 0.9; set_yellow_key = 1; setTimeout("getSchedule(currChan);LoadMediaSettings();",100); } else { GetSchedule(currChan,15); schedule.style.opacity = 1 - schedule.style.opacity; isSchedule = schedule.style.opacity; if(isSchedule == 1){ colorkeys.innerHTML = "
" + " " + NN[4] + " " + NN[4] + " " + NN[6] + " " + NN[4] + ""; } else { colorkeys.innerHTML = "
" + " " + NN[3 + (1 - NowNext)] + " " + NN[1 - NowNext] + " " + NN[2] + " " + NN[5] + ""; } } break; case "Info": case "Blue": case KEY_EPG: // if(isFullscreen) { // RestartPortal(); // } else if(isSchedule == 0) { if(!epgactive) { updateOSDtime(currChan); SetOsdInfo(); if(isFullscreen) { NowNext = 0;} if (NowNext) { osdepginfo.style.opacity = 0; osdepginfonext.style.opacity = 1; } else { osdepginfo.style.opacity = 1; osdepginfonext.style.opacity = 0; } epgactive = 1; } else { epg_unactive(); } // setTimeout("epgactive = 0; osdepginfo.style.opacity = 0; osdepginfonext.style.opacity = 0;", 5000); } break; case "BrowserBack": if(count) { count = 0; osdmain.style.opacity = 0; if(isFullscreen) { showDisplay(currChan.toString(), false, 100, 0 ); } Change = 0; } else { if(isSchedule) { isSchedule = 0; schedule.style.opacity = 0; colorkeys.innerHTML = "
" + " " + NN[3 + (1 - NowNext)] + " " + NN[1 - NowNext] + " " + NN[2] + " " + NN[5] + ""; break; } if(isFullscreen) { //SHOW epg info if(!epgactive) { // SetOsdInfo(); // osdepginfo.style.opacity = 1; // osdepginfonext.style.opacity = 0; // epgactive = 1; } else { epg_unactive(); } // setTimeout("epgactive = 0; osdepginfo.style.opacity = 0; osdepginfonext.style.opacity = 0;", 5000); } else if(!isFullscreen){ epg_unactive(); isFullscreen = 1; FullScreen(); currChan = preChan; ChanGroup = preGrp; } } break; case "Enter": // OK key on frontpanel case KEY_OK: if(isFullscreen) { // fullscreen if (osdmain.style.opacity !== 0) {opacity = 0; OSD(opacity);} if(count == 0) { if (osdtimeout) { clearTimeout(osdtimeout); osdtimeout = 0; opacity = 0; OSD(opacity); break; } osdepg.innerHTML = ""; showOSD(); GetEPG(currChan); updateOSDtime(currChan); osdepg.innerHTML = "
" + EPG[0][7][currChan] + "\n
" + EPG[1][7][currChan] + ""; // showOSD(); } else { CheckChannel(Change); count = 0; if(ChangeOK) { play(channels[currChan]); ChangeOK = 0; } } } else { // if not fullscreen if(count){ CheckChannel(Change); count = 0; if(ChangeOK) { preview(channels[currChan]); ChangeOK = 0; } } else { isFullscreen = 1; FullScreen(); if(isSchedule) { isSchedule = 0; schedule.style.opacity = 0; } play(channels[currChan]); } } break; case KEY_MENU: if(isFullscreen) { if(count) { count = 0; osdmain.style.opacity = 0; showDisplay(currChan.toString(), false, 100, 0 ); Change = 0; } epg_unactive(); isSetupMenu = 1; mainmenu.style.opacity = 0.8; menu = 0; InitMenu(menu); } break; case KEY_FAV: case "Scroll": if(isFullscreen) { GuideView_start(); } else { GuideView_end(); } break; case "TV": case "RADIO": if(isFullscreen) { if(ChanGroup !== 9) { //Radio defChan[ChanGroup] = currChan; OldChanGroup = ChanGroup; ChanGroup = 9; currChan = defChan[9]; } else { //TV defChan[ChanGroup] = currChan; ChanGroup = OldChanGroup; currChan = defChan[ChanGroup]; } isSetupMenu = 0; mainmenu.style.opacity = 0; play(channels[currChan]); } break; case KEY_0: digit = 0; Makedigit(); break; case KEY_1: digit = 1; Makedigit(); break; case KEY_2: digit = 2; Makedigit(); break; case KEY_3: digit = 3; Makedigit(); break; case KEY_4: digit = 4; Makedigit(); break; case KEY_5: digit = 5; Makedigit(); break; case KEY_6: digit = 6; Makedigit(); break; case KEY_7: digit = 7; Makedigit(); break; case KEY_8: digit = 8; Makedigit(); break; case KEY_9: digit = 9; Makedigit(); break; case KEY_A:// |> key on old long kpn 1710/1760 remote break; case KEY_B:// hh key on old long kpn 1710/1760 remote if (prevChan !== currChan) { // check if Group isn't protected var i = Number(Left((prevChan / 1000),1)); if ((protChn[i] == 1) && (ShowProtectedChannels == 1)) { // if protected don't do it ;) } else { currChan = [prevChan, prevChan = currChan][0]; count = 0; play(channels[currChan]); } } break; case KEY_C:// @ key on old long kpn 1710/1760 remote if(isFullscreen && Fav_max_channel !== 0 && ChanGroup !== Fav_group) { timerID = (defChan[Fav_group] - Fav_base - 1); if (timerID < 0) { timerID = 0;} maxTimers = Fav_max_channel; GotoFav(defChan[Fav_group]); } else if(isFullscreen && ChanGroup == Fav_group) { timerID = (currChan - Fav_base - 1); } if(isFullscreen && Fav_max_channel !== 0) { if(count) { count = 0; osdmain.style.opacity = 0; showDisplay(currChan.toString(), false, 100, 0 ); Change = 0; } epg_unactive(); isSetupMenu = 1; mainmenu.style.opacity = 0.8; menu = 10; InitMenu(menu); } break; case KEY_D:// >@ key on old long kpn 1710/1760 remote if (protChn[ChanGroup] !== 1 && ChanGroup !== Fav_group) { AddtoFav(); } break; case "Teletext": if(isFullscreen) { ClearScreen(); isVisible = 1; setVisible(isVisible); } break; case "VolumeMute": VolumeMute(); break; case "VolumeUp": VolumeUp(); break; case "VolumeDown": VolumeDown(); break; case "MediaRewind": if(isFullscreen) { mediaPlayer.play(mediaPlayer.PACE_REWIND); } else { count = 0; Change = 0; defChan[ChanGroup] = currChan; do { do ChanGroup -= 1; while (protChn[ChanGroup] == 1 && ShowProtectedChannels == 1) if (ChanGroup < 0) { ChanGroup = 9; } } while (!minChan[ChanGroup]); currChan = defChan[ChanGroup]; preview(channels[currChan]); } break; case "MediaForward": if(isFullscreen) { mediaPlayer.play(mediaPlayer.PACE_FASTFORWARD); } else { count = 0; Change = 0; defChan[ChanGroup] = currChan; do{ do ChanGroup++; while (protChn[ChanGroup] == 1 && ShowProtectedChannels == 1) if (ChanGroup > 9) { ChanGroup = 0; } } while (!minChan[ChanGroup]); currChan = defChan[ChanGroup]; preview(channels[currChan]); } break; case "MediaPlayPause": if(isFullscreen && PauseOnServer) { if(mediaPlayer.getState() == mediaPlayer.STATE_PLAYING) { isPause = 1; ServerPause(); SetLed(1,1,10); // setTimeout("mediaPlayer.play(0);",5000); mediaPlayer.play(0); break; } if(mediaPlayer.getState() == mediaPlayer.STATE_PAUSED || mediaPlayer.getState() == mediaPlayer.STATE_FASTFORWARDING || mediaPlayer.getState() == mediaPlayer.STATE_REWINDING) { SetLed(1,1,0); mediaPlayer.play(mediaPlayer.PACE_PLAY); break; } } if(TimeShift){ if(mediaPlayer.getState() == mediaPlayer.STATE_PAUSED || mediaPlayer.getState() == mediaPlayer.STATE_FASTFORWARDING || mediaPlayer.getState() == mediaPlayer.STATE_REWINDING) { SetLed(1,1,0); mediaPlayer.play(mediaPlayer.PACE_PLAY); break; } if(mediaPlayer.getState() == mediaPlayer.STATE_PLAYING) { SetLed(1,1,10); mediaPlayer.play(0); break; } } break; case "MediaStop": try { SetLed(1,1,0); if(TimeShift){ mediaPlayer.playFromPosition(mediaPlayer.POSITION_LIVE,mediaPlayer.PACE_PLAY); } } catch(e) { alert(e); } break; case KEY_REC: case KEY_REC2: if(isSchedule == 0) { if(epgactive) { ServerTimer(channels[currChan],EPG[NowNext][6][currChan]); settimer(EPG[NowNext][2][currChan],EPG[NowNext][1][currChan],(EPG[NowNext][3][currChan]*60),2); } else { ServerRecordStart(); } } // if(isFullscreen && !epgactive) { // ServerRecordStart(); // } else if(isSchedule == 0){ // if(NowNext) { // } else { // // make timer for recording // ServerTimer(channels[currChan],EPG[NowNext][6][currChan]); // settimer(EPG[NowNext][2][currChan],EPG[NowNext][1][currChan],(EPG[NowNext][3][currChan]*60),2); // } else { // ServerRecordStart(); // } // } break; case KEY_OPNAMES: case KEY_FILM: case KEY_DVR: if (smartTVplugin) { // jump to recordings menu. if(isFullscreen) { if(count) { count = 0; osdmain.style.opacity = 0; showDisplay(currChan.toString(), false, 100, 0 ); Change = 0; } epg_unactive(); medialist.style.opacity = 0.9; mainmenu.style.opacity = 0; recPath = "/recordings.xml"; setTimeout("getRecList();LoadMediaSettings();",100); } break; } default: break; } } } function GotoFav(ChanID) { count = 0; Change = 0; prevChan = ""; Fav_key1 = ""; defChan[ChanGroup] = currChan; ChanGroup = Fav_group; currChan = ChanID; play(channels[currChan]); } function AddtoFav() { Fav_max_channel++; maxChan[Fav_group] = Fav_base + Fav_max_channel; channelsnames[(Fav_base + Fav_max_channel)] = channelsnames[currChan]; channels[(Fav_base + Fav_max_channel)] = channels[currChan]; is.setObject(("vip.channelsnames." + Fav_max_channel),channelsnames[currChan],is.STORAGE_PERMANENT) is.setObject(("vip.channels." + Fav_max_channel),channels[currChan],is.STORAGE_PERMANENT) is.setObject("vip.fav_max_channel",Fav_max_channel.toString(),is.STORAGE_PERMANENT) settimer(0,channels[currChan],Fav_max_channel ,2); } function Read_Fav() { Fav_max_channel = Number(is.getObject("vip.fav_max_channel")); maxChan[Fav_group] = Fav_base + Fav_max_channel; for (var i=1; i<=Fav_max_channel; i++) { channelsnames[(i+Fav_base)] = is.getObject(("vip.channelsnames." + i)); channels[(i+Fav_base)] = is.getObject(("vip.channels." + i)); } } function Makedigit() { if (TimedChangeID != -1) { clearTimeout(TimedChangeID); TimedChangeID = -1; } oldChan = prevChan; // used for swap last channels with 0 prevChan = currChan; Change = (Change*10) + digit; count++; osdmain.style.opacity = isFullscreen; OSDchannr(Change); if(isFullscreen) { showDisplay((Change.toString()), false, 100, 0 ); } if (count>channeldigits) { CheckChannel(Change); count = 0; } else { TimedChangeID = setTimeout("TimedChange();",ChangeTime); } if(ChangeOK) { if(isFullscreen) { play(channels[currChan]); } else { preview(channels[currChan]); } ChangeOK = 0; } } function CheckChannel(CheckThis) { // function to check if channel exists // or swap prev <> currchan if (CheckThis == 0 && oldChan !== currChan) { // check if Group isn't protected var i = Number(Left((oldChan / 1000),1)); if ((protChn[i] == 1) && (ShowProtectedChannels == 1)) { ChangeOK = 0; } else { currChan = oldChan; ChangeOK = 1; } } else { CheckThis = baseChn[ChanGroup] + CheckThis; if(channels[CheckThis]) { ChangeOK = 1; currChan = CheckThis; } else { ChangeOK = 0; } if(prevChan == currChan) { ChangeOK = 0 ; } } osdmain.style.opacity = 0; if(isFullscreen) { showDisplay(currChan.toString(), false, 100, 0 ); } Change = 0; } function TimedChange() { if (count && ChangeTime) { CheckChannel(Change); count = 0; if(ChangeOK) { if(isFullscreen) { play(channels[currChan]); } else { preview(channels[currChan]); } ChangeOK = 0; } } } function showDisplay(showtxt,colonState,intensity,currentMode) { if(!showClock){ if (Number(showtxt) > 8999 && Number(showtxt) < 10000) { showtxt = "R" + Right(showtxt,3); } if (Number(showtxt) > 9999 && Number(showtxt) < 20000) { showtxt = "F" + Right(showtxt,3); } showtxt = Right(showtxt,4); try { fps.setSegmentDisplayState(toi.statics.ToiFrontPanelServiceSegmentDisplayState.create(showtxt,colonState,intensity,currentMode)); } catch (e) { // Display error, maybe no display... } } } function SetLed(NumLed,color,blinkfreq){ var state = toi.statics.ToiFrontPanelServiceLedState.create(color, blinkfreq); fps.setLedState(NumLed, state); } function showOSD() { if (osdtimeout) { clearTimeout(osdtimeout); } SetOsdInfo(); opacity = 0.8; OSD(opacity); osdtimeout = setTimeout("fadeOut(); osdtimeout = 0;", ShowOsdTime); } function epg_unactive() { osdepginfo.style.opacity = 0; osdepginfonext.style.opacity = 0; epgactive = 0; } function showVolume() { if (osdVolumetimeout) { clearTimeout(osdVolumetimeout); } osdvolume.innerHTML = "
" + Lang[1] + " : " + Volume + "% \n\uE007" + (new Array(Volume)).join("\uE008") + (new Array(100 - Volume)).join("\uE009") + "\uE00A"; osdvolume.style.opacity = 1; osdVolumetimeout = setTimeout("osdvolume.style.opacity = 0;", ShowOsdTime); } function OSD(opacity) { osdmain.style.opacity = opacity; } function SetOsdInfo() { OSDchannr(currChan); date_time(); OSDhtml(); return; } function onCacheUpdated() { GetEPG(currChan); if (osdtimeout) { SetOsdInfo(); } } function OSDchannr(channr) { // Show logo's if (experimental) { //osdlogo.innerHTML = ""; } else if ( ProgTime == 0 && SwitchTimer == 2) { var x = ""; } else { tijd = ProgTime; date = new Date(tijd*1000); tijd = date.toUTCString(); tijd = new Date(tijd); var tm = tijd.getMinutes(); var th = tijd.getHours(); th=addzero(th); tm=addzero(tm); var x = Lang[4] + th + ":" + tm + ""; } // switchtimer.style.background = BackGroundColor; switchtimer.innerHTML = ""; } osdnr.innerHTML = "" + Right(channr,3) + ""; // alert(cssres[css_nr][Set_Res]); } function OSDhtml(){ osdtime.innerHTML = "" + result + ""; if (ShowSource == 1) { osdname.innerHTML = "" + channels[currChan].split("-")[0] + "\uE003" + channelsnames[currChan] + ""; } else { osdname.innerHTML = " \uE003 " + channelsnames[currChan] + ""; } osdepg.innerHTML = "
" + EPG[0][7][currChan] + "\n" + EPG[1][7][currChan] + ""; osdepginfo.innerHTML = "" + "" + currChan + "\uE003" + channelsnames[currChan] + "
" + AvInfo[currChan] + "
" + EPG[0][7][currChan] + EPG[0][9][currChan] + EPG[0][8][currChan] + "
\n" + EPG[0][4][currChan] + "
\n" + Left(EPG[0][5][currChan],750) + "
"; osdepginfonext.innerHTML = "" + "" + currChan + "\uE003" + channelsnames[currChan] + "
" + EPG[1][7][currChan] + EPG[1][9][currChan] + EPG[1][8][currChan] + "
\n" + EPG[1][4][currChan] + "
\n" + Left(EPG[1][5][currChan],750) + "
"; } function updateOSDtime(timchan) { tijd = EPG[0][2][timchan]; date = new Date(tijd*1000); tijd = date.toUTCString(); tijd = new Date(tijd); dateCurrent = new Date(); var EPGminutes = Math.floor((dateCurrent.getTime() - date.getTime()) /1000/60); var tm = tijd.getMinutes(); var th = tijd.getHours(); th=addzero(th); tm=addzero(tm); EPG[0][7][timchan] = th + ":" + tm + " ("; if (Number(EPGminutes) > 1440 || Number(EPGminutes) < -1440 ) { // Duration is >24h, maybe current time isn't right. EPG[0][7][timchan] += EPG[0][3][timchan]; } else { EPG[0][7][timchan] += EPGminutes + " / " + ((EPG[0][3][timchan])-EPGminutes).toFixed(0); } EPG[0][7][timchan] += ")" + " " + EPG[0][1][timchan] + " "; if (!EPG[0][2][timchan] || ((EPG[0][3][timchan]-EPGminutes) < 0)) { EPG[0][7][timchan] = " "; } } function settimer(ProgTime,ProgName,ProgDura,SwitchTimer,BackGroundColor,ProgDesc,ProgEvID) { if (!BackGroundColor) { BackGroundColor = color_default;} // 1 - switchonly, 2 - record on server (display info only), 3 - record local, 4 - sleeptimer, 5 - Actions, 6 - reload if(SwitchTimer == 1) { try { var x = ss.schedule("SwitchOnly","notification", ProgTime , ProgDura); ss.setParameter(x, "Channel", currChan.toString() ); ss.setParameter(x, "Title", ProgName ); ss.setParameter(x, "Info", ProgDesc); ss.setParameter(x, "active", "False"); ss.setParameter(x, "Type", "\uE00C"); //Timer Symbol ss.setParameter(x, "resume", "0"); ss.setParameter(x, "Eventid", ProgEvID); } catch (e) { ProgName = "ERROR" ; BackGroundColor = color_error; } } else if(SwitchTimer == 3) { ProgTime -= preRecTime; ProgDura = Number(ProgDura) + (afterRecTime + preRecTime); var y = (new Date().getTime()/1000).toFixed(0); if(ProgTime < y) { ProgDura = ProgDura - (y - ProgTime); ProgTime = y; } try { var x = ss.schedule("RecLocal","record_hd_from_ip", ProgTime , ProgDura); if (x != 0) { ss.setParameter(x, "Channel", currChan.toString() ); ss.setParameter(x, "Title", ProgName ); ss.setParameter(x, "Info", ProgDesc); ss.setParameter(x, "active", "False"); ss.setParameter(x, "Type", "\uE00C"); //Timer Symbol ss.setParameter(x, "resume", "0"); ss.setParameter(x, "Eventid", ProgEvID); } else { ProgName = "ERROR" ; BackGroundColor = color_error; } } catch (e) { alert(e); } } else if(SwitchTimer == 4) { try { var x = ss.schedule("SleepTimer","notification", ProgTime , ProgDura); ss.setParameter(x, "Channel", currChan.toString() ); ss.setParameter(x, "Title", " " ); ss.setParameter(x, "Info", " "); ss.setParameter(x, "active", "False"); ss.setParameter(x, "Type", "\uE00C");//Timer Symbol ss.setParameter(x, "resume", "0"); ss.setParameter(x, "Eventid", "0"); } catch (e) { ProgName = "ERROR" ; BackGroundColor = color_error; } } else if(SwitchTimer == 5) { try { var x = ss.schedule("Cron","notification", ProgTime , ProgDura); if (Cron_switch_channel) { ss.setParameter(x, "Channel", Cron_switch_channel.toString() ); } else { ss.setParameter(x, "Channel", currChan.toString() ); } if (ProgEvID == 1) { ss.setParameter(x, "Title", "Standby" ); } else if (ProgEvID == 2) { ss.setParameter(x, "Title", "Switch to" ); } else { ss.setParameter(x, "Title", "No Action" ); } ss.setParameter(x, "Info", "-"); ss.setParameter(x, "active", "False"); ss.setParameter(x, "Type", "\uE01A");//Bomb Symbol ss.setParameter(x, "resume", "0"); ss.setParameter(x, "Eventid", ProgEvID); } catch (e) { } } else if(SwitchTimer == 6) { try { var x = ss.schedule("Reload","notification", ProgTime , ProgDura); ss.setParameter(x, "Channel", currChan.toString() ); ss.setParameter(x, "Title", "Reload" ); ss.setParameter(x, "Info", "-"); ss.setParameter(x, "active", "False"); ss.setParameter(x, "Type", "\uE01A");//Bomb Symbol ss.setParameter(x, "resume", "0"); ss.setParameter(x, "Eventid", "0"); } catch (e) { } } if (SwitchTimer !== 5 && SwitchTimer !== 6 ) { if ( ProgTime == 0 && SwitchTimer == 2 && ProgDura !== 0 ) { var x = Lang[3] + ProgDura + "
" + Lang[2] + ProgName + "\n" + Lang[3] + channelsnames[currChan] + "\n" + x + ""; setOSDtimer(); switchtimer.style.opacity = 1; setTimeout("switchtimer.style.opacity = 0;", ShowSetTimer); } } function setOSDtimer() { // Only for type "SwitchOnly" var today = new Date; today = today / 1000; var x = ss.getBookingIds("SwitchOnly", today, 0) if (x.length !== 0) { tijd = ss.getNextStartTime("SwitchOnly"); date = new Date(tijd*1000); tijd = date.toUTCString(); tijd = new Date(tijd); var tm = tijd.getMinutes(); var th = tijd.getHours(); th=addzero(th); tm=addzero(tm); osdtimer.innerHTML = "
" + th + ":" + tm + "
"; SetLed(0,2,1); switchicon = "\uE00C"; } else { osdtimer.innerHTML = " "; SetLed(0,0,0); switchicon = '\uE003'; } osdca.innerHTML = "" + CAicon + switchicon + RECicon + ""; } // Left n characters of str function Left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } // Right n characters of str function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } function fadeIn() { opacity += 0.2; OSD(opcity); if (opacity >= 1) { setTimeout("fadeOut()", 200); return; } setTimeout("fadeIn()", 100); } function fadeOut() { opacity -= 0.5; OSD(opacity); if (opacity <= 0) { return; } setTimeout("fadeOut()", 100); } function RestartPortal(){ try { ids = toi.applicationService.getApplicationIds(); for ( i = 0; i < ids.length; ++i ){ info = toi.applicationService.getInfo(ids[i]); if (info.applicationName == "WebKit Portal"){ dump("Killing app " + ids[i] + ": " + info.applicationName); toi.applicationService.kill(ids[i]); } } } catch(e) { dump(e) }; } function date_time() { date = new Date; year = date.getFullYear(); month = date.getMonth(); d = date.getDate(); day = date.getDay(); h = date.getHours(); m = date.getMinutes(); h=addzero(h); m=addzero(m); result = ''+days[day]+' '+d+' '+months[month]+' '+year+' '+h+':'+m; return; } function date_time_rec() { date = new Date(Number(recStrt[currMed])*1000); year = date.getFullYear(); month = date.getMonth(); month = addzero(month + 1); d = date.getDate(); d = addzero(d); day = date.getDay(); h = date.getHours(); m = date.getMinutes(); h = addzero(h); m = addzero(m); if (year!==1970) { result = ' ' + d + '-' + month + '-' + year + ' ' + h + ':' + m; } else { result = ""; } return; } // EPG Section function GetEPG(epgchan) { EPG[0][7][epgchan] = ""; EPGShortnow = ""; EPGExtnow = ""; EPG[1][7][epgchan] = ""; EPGShortnext = ""; EPGExtnext = ""; SI=""; try { eitCache.clearServices(); StreamInfo(epgchan); eitService = toi.statics.ToiDvbEitCacheServiceItem.create(SI[1],SI[2],SI[3]); eitCache.addService(eitService); event = eitCache.getPresentEvent(eitService); if(event.freeCaMode){ CAicon = "\uE00D"; } else { CAicon = Radioicon; } osdca.innerHTML = "" + CAicon + switchicon + RECicon + ""; if (event.name) { events = eitCache.getEvents(eitService, (Math.round(new Date().getTime()/1000.0)), 2000000000); extEventsnow = eitCache.getExtendedEventInfo(eitService, events.infoSequence[0].eventId); EPGShortnow = extEventsnow.shortInfo; EPGExtnow = extEventsnow.extendedInfo; Extok = 1; } else { Extok = 0; } EPG[0][1][epgchan] = event.name; EPG[0][2][epgchan] = event.time; EPG[0][3][epgchan] = (event.duration/60); // EPG[0][4][epgchan] = ""; // EPG[0][5][epgchan] = ""; EPG[0][6][epgchan] = event.eventId; if (event.parentalRating) { EPG[0][8][epgchan] = "" + ss.getParameter(x[timerID-1], "Title") + "\n " + "\n" + y + " - " + channelsnames[y] + "(" + ss.getParameter(x[timerID-1], "Eventid") + ")" + "\n
" + ss.getParameter(x[timerID-1], "Info") + "
" ; } else if (menu == 5) { // Show EPG info Timer osdepginfo.style.opacity = 1 - osdepginfo.style.opacity; osdepginfo.innerHTML = "1 -" + Lang[10] + "\n 2 -" + Lang[7] + "\n 3 -" + Lang[11]; htmltext += "\n 4 -" + Lang[12]; if (Restfulapiplugin) { htmltext += "\n 5 -" + Lang[13]; } else { htmltext += "" + "\n 5 -" + Lang[13] + "" ; } if (Restfulapiplugin) { htmltext += "\n 6 -" + Lang[14]; } else { htmltext += "" + "\n 6 -" + Lang[14] + "" ; } if (smartTVplugin) { htmltext += "\n 7 -" + Lang[15]; } else { htmltext += "" + "\n 7 -" + Lang[15] + "" ; } if (Restfulapiplugin) { htmltext += "\n 8 -" + Lang[16]; } else { htmltext += "" + "\n 8 -" + Lang[16] + "" ; } if (ShowMPD) { htmltext += "\n 9 -" + Lang[17]; } else { htmltext += "" + "\n 9 -" + Lang[17] + "" ; } htmltext += "\n 0 - " + Lang[83] + "\n\n \u25CF - " + Lang[120] + "\u25CF -" + Lang[99] + "\u25CF -" + Lang[35] + " \u25CF -" if (PowerDownServer) { htmltext += Lang[31] + Left(Lang[19],Lang[31].length); } else { htmltext += Lang[18]; } htmltext += ""; mainmenu.innerHTML = htmltext; } if(menu == 6) { // Main Menu when watching recording MainMenu = 6; mainmenu.innerHTML = "
1 -" + Lang[10] + "\n 2 -" + Lang[7] + "\n\n\n 5 -" + Lang[13] + "\n\n\n 8 -" + Lang[16] + "\n\n\n\n \u25CF -" + Lang[19] + "\u25CF -" + Lang[99] + "\u25CF -" + Lang[35] + " \u25CF -" + Lang[19] + ""; } if(menu == 1) { // settings menu var htmltext = "
1 - "; if (ShowSubs) { htmltext += "\uE017"; } else { htmltext += "\uE016"; } htmltext += Lang[20] + ": " + (is.getObject("cfg.media.subtitling.languagepriority")); if (subs_prio_dyn.length > 0) { htmltext += " (" + (subs_dyn + 1 ) + "/" + subs_prio_dyn.length + ") "; } htmltext += "\n 2 - \uE003" + Lang[22] + (is.getObject("cfg.media.subtitling.modepriority")); htmltext += "\n 3 - \uE003" + Lang[24] + (is.getObject("cfg.media.audio.languagepriority")); htmltext += "\n 4 - " + Lang[82]; var x = Number(is.getObject("vip.serveraddress")); htmltext += "\n 5 - VDR : "; if (x == 0) { htmltext += Lang[88] + "-> " + server_ip;} else { htmltext += server_ip_array[x];} htmltext += "\n 6 - "; if (showClock) { htmltext += "\uE017"; } else { htmltext += "\uE016"; } htmltext += Lang[25] + "\n 7 - "; if (ShowProtectedChannels) { htmltext += "\uE017"; } else { htmltext += "\uE016"; } htmltext += Lang[26] + "\n 8 - "; if (SwitchGuide) { htmltext += "\uE017"; } else { htmltext += "\uE016"; } htmltext += Lang[27] + "\n 9 -" + Lang[23] + OSDLang[lang_nr] + "\n \u25AA -" + Lang[29]; if (SleepTimer) { htmltext += SleepTimer + Lang[30]; } else { htmltext += Lang[31]; } htmltext += "\n\n \u25CF -" + Lang[20]; htmltext += "\u25CF - " + VideoOutputModes_txt[VideoOutputModes[Set_Res]] + " "; htmltext += "\u25CF -" + Lang[35]; htmltext += "\u25CF - " + Left(cssfile[css_nr],8) +""; // htmltext += "\n 0 -" + Lang[9] +""; mainmenu.innerHTML = htmltext; } if(menu == 2) { // Timers menu booking = ""; var x = timerID - 2; var y = ss.getBookingIds("*", 0, 0); if (y.length !== 0) { for (var i=0;i<10;i++) { if (timer.length !== 0) { do { x++; } while (!timer[x] && (x < timer.length)) } if (i == 0) { booking += ""; } else if (i == 1) { booking += ""; } if (timer.length > x) { try { if (ss.getParameter(y[x], "assetURI")) { // test if there is a file with the timer if so more info is added if (Number(ss.getParameter(y[x], "resume")) == 0 ) { booking += "\uE003\uE010"; } else { booking += "\uE003\uE003"; } } } catch(e) { booking += "\uE003\uE003"; } booking += ss.getParameter(y[x], "Type"); booking += timer[x]; } else { booking += "\n"; } } } if (mediaRecorder) { var x = NN[3]; } else { var x = Lang[19]; } mainmenu.innerHTML = "
\n 0 -" + Lang[9] + "\n" + booking + " \u25CF -" + Lang[48] + "\u25CF - " + x + " \u25CF -" + Lang[19] + "\u25CF - " + NN[5] + ""; } if(menu == 3) { // MPD Menu mainmenu.innerHTML = "
" + Lang[34] + "\n 0 -" + Lang[9] + ""; } if(menu == 4) { // INFO Menu var htmltext = "
"; try { htmltext += "\n Product name: " + is.getObject("config.productdisplayname"); htmltext += "\n Build date : " + is.getObject("config.build.date"); htmltext += "\n IP address : " + is.getObject("config.ipaddress"); htmltext += "\n MACaddress : " + MACaddress; var x = is.getObject("cfg.ip.eth0.mode"); if (x == "DHCP") { htmltext += "\n \uE003\uE017 "; } else { htmltext += "\n \uE003\uE016 "; } htmltext += "DHCP"; var x = is.getObject("var.capabilities.dvr"); if (x !== "FALSE") { htmltext += "\n \uE003\uE017 "; } else { htmltext += "\n \uE003\uE016 "; } htmltext += "DVR"; if (Global_Multicast) { htmltext += "\n VDR address : MultiCast"; } else { htmltext += "\n VDR address : " + server_ip; } htmltext += "\n Vip Client\uE003\uE003\uE003: " + Version; htmltext += "\n Channel list\uE003: " + Chan_Ver; } catch(e) { alert("Error : " + e); } htmltext += "\n\n 0 -" + Lang[9] + ""; mainmenu.innerHTML = htmltext; } if(menu == 5) { // Timers from Server if (timerOK) { booking = ""; var x = timerID - 1; for (var i=0;i<10;i++) { if (maxTimers !== 0) { do { x++; } while (!timers[x] && (x < maxTimers)) } if (maxTimers > x) { booking += timers[x]; } else { booking += "\n"; } if (i == 0) { booking += ""; } } if (get_timer) { mainmenu.innerHTML = "
\n" + booking + "\n \u25CF -" + Lang[48] + "\u25CF -" + Lang[49] + "\u25CF -" + Lang[19] + " \u25CF -" + Lang[28] + ""; } else { mainmenu.innerHTML = "
\n" + booking + "\n \u25CF -" + Lang[19] + "\u25CF -" + Lang[19] + "\u25CF -" + Lang[19] + " \u25CF -" + Lang[28] + ""; } } } if(menu == 7) { // SearchTimers from Server if (timerOK) { booking = ""; var x = timerID - 1; for (var i=0;i<10;i++) { if (maxTimers !== 0) { do { x++; } while (!searchtimers[x] && (x < maxTimers)) } if (maxTimers > x) { booking += searchtimers[x]; } else { booking += "\n"; } if (i == 0) { booking += ""; } } mainmenu.innerHTML = "
\n" + booking + "\n \u25CF -" + Lang[19] + "\u25CF -" + Lang[19] + "\u25CF -" + Lang[19] + " \u25CF -" + Lang[28] + ""; } } if(menu == 8) { // ChannelGroups enable/disable var htmltext = "
\n";
for (var i=0;i<10;i++) {
if (maxChan[i]) { } else { htmltext += ""; }
htmltext += "\uE003" + i + "\uE003-\uE003";
if (is.getObject(("vip.group." + i)) == "1") { htmltext += "\uE017"; } else { htmltext += "\uE016"; }
htmltext += "\uE003" + Lang[81] + i + "\n";
if (maxChan[i]) { } else { htmltext += ""; }
}
htmltext += "
";
mainmenu.innerHTML = htmltext;
}
if(menu == 9) { // INFO2 Menu
var htmltext = ""; try { if (fullupdate !== 0) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Full EPG Update "; experimental = Number(is.getObject("vip.testing")); if (experimental) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Experimental"; if (Number(is.getObject("vip.testing2"))) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Experimental 2 (Info box 'not in package')"; if (Number(is.getObject("vip.testing3"))) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Experimental 3 (Unused)"; if (Restfulapiplugin) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Has Restfulapiplugin" if (smartTVplugin) { htmltext += "\n \uE017 "; } else { htmltext += "\n \uE016 "; } htmltext += "Has smartTVplugin" htmltext += "\n gettimers from"; if (get_timer == 1) { htmltext += " smarttvweb "; } else { htmltext += " restfulapi "; } htmltext += "\n getmarks from"; if (get_marks == 1) { htmltext += " smarttvweb "; } else { htmltext += " restfulapi "; } htmltext += "\n getrecordings from"; if (get_recordings == 1) { htmltext += " smarttvweb "; } else if (get_recordings == 0) { htmltext += " restfulapi "; } else { htmltext += " streamdev "; } htmltext += "\n EPGMode : " if (EPGMode) { htmltext += "Full EPG"; } else { htmltext += "Now/Next Only"; } } catch(e) { alert("Error : " + e); } htmltext += "\n\n 0 -" + Lang[9] + ""; mainmenu.innerHTML = htmltext; } if(menu == 10) { // Favorite edit Menu var htmltext = "
\n"; htmltext += ""; var x = timerID; for (var i=0;i<10;i++) { if (maxTimers !== 0) { x++;} if (maxTimers >= x && x !== 0) { htmltext += " \u0003\u0003 " + x + " \u0003\u0003 " + channelsnames[(x + Fav_base)] + " \u0003\u0003\u0003 \n"; } else { htmltext += "\n"; } if (i == 0) { htmltext += ""; } } htmltext += "\n \u25CF -" + Lang[87]; htmltext += "\u25CF -" if (timerID == 0) { htmltext += Lang[19] } else { htmltext += Lang[84] } //no move up htmltext += "\u25CF -" if (timerID == (maxTimers - 1) || x == 0) { htmltext += Lang[19] } else { htmltext += Lang[85] } //no move down htmltext += "\u25CF -" + Fav_key1 + ""; mainmenu.innerHTML = htmltext; } if(menu == 11) { // Weather info WeatherInfo(); } if(menu == 12) { // News NewsInfo(); } } // end of initmenu function SetGroup(isgroup) { is.setObject("vip.group." + isgroup,(1 - is.getObject("vip.group." + isgroup)).toString(),is.STORAGE_PERMANENT); if (is.getObject("vip.group." + isgroup) == "0") { minChan[isgroup] = "";} else {minChan[isgroup] = minchan[isgroup];} } function LoadTimers() { timer.length = 0; var booking = ""; var x = ss.getBookingIds("*", 0, 0); for (var i=0;i
\n " + Lang[37] + ": \n " + server_ip + ""; } } catch(e) { timerOK = 0; alert("Get Timers problem: " + e); mainmenu.innerHTML = "
\n " + Lang[36] + ": \n " + server_ip + ""; } } function DeleteTimers() { if (get_timer==1) { try { xmlhttp=new XMLHttpRequest(); // // SmartTVWeb // xmlhttp.open("GET",(server_ip + recServ + "/deleteTimer?guid=" + timersChan[timerID] + "&dy=" + timersDay[timerID] // + "&st=" + timersStrt[timerID] + "&sp=" + timersStop[timerID] + "&" + new Date().getTime()),false); xmlhttp.open("GET",(server_ip + recServ + "/deleteTimer?index=" + timersID[timerID] + "&" + new Date().getTime()),false); xmlhttp.send(); } catch(e) { alert("Deleting Timers problem: " + e); } } } function activate_timers(){ if (get_timer==1) { // (De)activate timers. try { xmlhttp=new XMLHttpRequest(); if (timersFlag[timerID] == "0") { xmlhttp.open("GET",(server_ip + recServ + "/activateTimer?index=" + timersID[timerID] + "&activate=true&" + new Date().getTime()),false); } else { xmlhttp.open("GET",(server_ip + recServ + "/activateTimer?index=" + timersID[timerID] + "&activate=false&" + new Date().getTime()),false); } xmlhttp.send(); if (timersFlag[timerID] == "0") { timers[timerID] = timers[timerID].substr(0, 1) + "\uE00C" + timers[timerID].substr(2); timersFlag[timerID] = "1" } else { timers[timerID] = timers[timerID].substr(0, 1) + "\uE003" + timers[timerID].substr(2); timersFlag[timerID] = "0" } } catch(e) { alert("(De)Activate Timers problem: " + e); } } } function ShowTimerInfo() { if (osdepginfo.style.opacity == 1) { //Like Show EPG Info //setup some dummy vars var info1 = ""; var info2 = ""; var info3 = ""; var info4=""; if (timersEvnt[timerID] > 0) { try { xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET",(server_ip + RestFulAPI + "/events/" + timersChan[timerID] + "/" + timersEvnt[timerID] + ".xml?" + new Date().getTime()),false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; var x=xmlDoc.getElementsByTagName("event"); // x[0].getElementsByTagName("param")[1].childNodes[0].nodeValue --> Title // x[0].getElementsByTagName("param")[2].childNodes[0].nodeValue --> Short_text // x[0].getElementsByTagName("param")[3].childNodes[0].nodeValue --> Description // x[0].getElementsByTagName("param")[5].childNodes[0].nodeValue --> ChannelsName info1 = x[0].getElementsByTagName("param")[1].childNodes[0].nodeValue; info2 = x[0].getElementsByTagName("param")[5].childNodes[0].nodeValue; info4 = x[0].getElementsByTagName("param")[3].childNodes[0].nodeValue; info3 = x[0].getElementsByTagName("param")[2].childNodes[0].nodeValue; // + "
";
} catch(e) {
alert("Get EPG problem: " + e);
}
} else {
info3 = Lang[37];
}
osdepginfo.innerHTML = "" + " "
+ Left(info1,60) + " " + info3 + " " + Left(recTitl[currMed],60)
+ " " + AvInfo[currMed]
+ " " + result + " Sorry STREAMDEV-plugin : " + Lang[37] + " "
+ Left(recTitl[currMed],60)
+ " " + AvInfo[currMed]
+ " " + result + " " + Left(recDesc[currMed],750) + " "
+ Left(recTitl[currMed],60)
+ " " + AvInfo[currMed] + " " + "
" + timersDays[timerID] + " "
+ timersStrt[timerID] + " - " + timersStop[timerID] + "
"
+ info2 + "
" + Left(info4,750) + "";
if ((x[i].getElementsByTagName("use_as_searchtimer")[0].childNodes[0].nodeValue) == 0) {
SearchTimer[i] += "\uE003\uE016\uE003" + Lang[40] + "\n";
} else {
SearchTimer[i] += "\uE003\uE017\uE003" + Lang[40] + "\n";
}
SearchTimer[i] = SearchTimer[i] + "\uE003\uE003\uE003Mode :\uE003" + (searchmode[x[i].getElementsByTagName("mode")[0].childNodes[0].nodeValue]) + "\n";
if ((x[i].getElementsByTagName("use_time")[0].childNodes[0].nodeValue) == 1) {
SearchTimer[i] += "\uE003\uE017\uE003" + Lang[41] + "\uE003" +
x[i].getElementsByTagName("start_time")[0].childNodes[0].nodeValue +
"\uE003-\uE003" + x[i].getElementsByTagName("stop_time")[0].childNodes[0].nodeValue + "\n";
} else {
SearchTimer[i] += "\uE003\uE016\uE003" + Lang[41] + "\uE003" + "\n";
}
if ((x[i].getElementsByTagName("use_dayofweek")[0].childNodes[0].nodeValue) == 0) {
SearchTimer[i] += "\uE003\uE016\uE003" + Lang[47] + "\uE003" + "\n";
} else {
//bit is used for dayofweek.
var dowx = x[i].getElementsByTagName("dayofweek")[0].childNodes[0].nodeValue;
var dow = "";
if (dowx > 0) { var y = 1;} else { var y = 0;}
dowx = Math.abs(dowx);
for (var dowi=0; dowi<7; dowi++)
{
var mask = 1 << dowi;
if ((dowx & mask) != 0) { dow += days[(dowi+y)] + "\uE003";}
}
SearchTimer[i] += "\uE003\uE017\uE003" + Lang[47] + "\uE003:\uE003" + dow + "\n";
}
if ((x[i].getElementsByTagName("use_channel")[0].childNodes[0].nodeValue) == 0) {
SearchTimer[i] += "\uE003\uE016\uE003" + Lang[42] + "\uE003" + "\n";
} else {
SearchTimer[i] += "\uE003\uE017\uE003" + Lang[42] + "\uE003:\uE003" +
searchchan[(x[i].getElementsByTagName("use_channel")[0].childNodes[0].nodeValue)] + "\uE003" +
x[i].getElementsByTagName("channels")[0].childNodes[0].nodeValue + "\n";
}
SearchTimer[i] += "\n
";
// End of Extended INFO
searchtimers[i] += searchtimersSearch[i] + "\uE003\uE003\n" ;
}
timerOK = 1;
}
if (timerOK == 0) {
mainmenu.innerHTML = "" + Lang[8] + "
\n " + Lang[37] + ": \n " + server_ip + RestFulAPI + "
";
}
} catch(e) {
timerOK = 0;
alert("Get SearchTimers problem: " + e);
mainmenu.innerHTML = "" + Lang[8] + "
\n " + Lang[43] + ": \n " + server_ip + RestFulAPI + "
";
}
}
function ShowSearchTimerInfo() {
// info about a search timer.
//Like Show EPG Info
//setup some dummy vars
var info1 = ""; var info2 = "";
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + RestFulAPI + "/searchtimers/search/" + searchtimersID[timerID] + ".xml?" + new Date().getTime()),false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("event");
var maxinfo = x.length; if (maxinfo > 15) { maxinfo = 15;}
for (var i=0;i" + info1 + "
" ;
}
// End of Menu section
// MPD Section
function MPD(ev) {
// alert("Media player state changed: " + ev);
// alert("Media player state changed: state=" + ev.state + ", reason=" + ev.reason + ", code=" + ev.code);
// alert("Media player error :" + mediaPlayer.getError().details);
if (MPDListener == 0) {
if (ev.state == 6 ) {
if (ev.reason == "CommandClose" && ErrorAgain == 0) {
setTimeout("mediaPlayer.open(URL);mediaPlayer.play(1000);GetEPG(currChan);ExtraStuff();",500);
ErrorAgain = 1;
} else if (KeepTrying) {
ErrorAgain = 0;
settimer(0,Lang[63],0,2,color_error);
initialDelayPlayID = setTimeout("mediaPlayer.close();mediaPlayer.open(URL);mediaPlayer.play(1000);GetEPG(currChan);ExtraStuff();",TryingInterval);
} else {
ErrorAgain = 0;
//alert("Media player state changed: state=" + ev.state + ", reason=" + ev.reason + ", code=" + ev.code);
showDisplay("ERRR", false, 100, 0 );
if (experimental) {
settimer(0,ev.reason,0,2,color_error);
} else {
settimer(0,Lang[67],0,2,color_error);
}
}
} else if ( ev.state == 2 && ev.reason == "PositionEnd" && PromoChannel) {
if (currChan == PromoChannelNR) { play(channels[PromoChannelNR]);}
}
} else {
if ( ev.state == 6 && ev.reason == "HostUnreachable" ) {
showDisplay("ERRR", false, 100, 0 );
mainmenu.innerHTML = "" + Lang[60] + "
" + Lang[34] + "\n 0 -" + Lang[9] + "\n 9 -" + Lang[61] + "\n\n
";
} else if ( ev.state == 2 ) { // && ev.reason == "PositionEnd" ) {
showDisplay("STOP", false, 100, 0 );
mainmenu.innerHTML = "" + Lang[62] + ": \n" + server_ip + MPDAddress + "
" + Lang[60] + "
" + Lang[34] + "\n 0 -" + Lang[9] + "\n 9 -" + Lang[63] + "\n\n
";
} else if ( ev.state == 3 && ev.reason == "CommandPlay" ) {
showDisplay("MPD", false, 100, 0 );
mainmenu.innerHTML = "" + Lang[64] + ": \n" + server_ip + MPDAddress + "\n" + Lang[65] + "
" + Lang[60] + "
" + Lang[34] + "\n 0 -" + Lang[9] + "\n\n\n
";
} else {
showDisplay("ERRR", false, 100, 0 );
mainmenu.innerHTML = "" + Lang[64] + ": \n" + server_ip + MPDAddress + "
" + Lang[60] + "
" + Lang[34] + "\n 0 -" + Lang[9] + "\n 9 -" + Lang[63] + "\n\n
";
}
}
}
function playMPD(uri) {
try {
if (mediaPlayer.getState() != mediaPlayer.STATE_IDLE) {
mediaPlayer.close();
}
MPDListener = 1;
mediaPlayer.open(uri);
mediaPlayer.play(1000);
} catch (e) {
alert("Failed opening recording: " + e);
return;
}
}
// End of MPD Section
// Media Player Section
function LoadMediaSettings() {
subgroup = 0;
subsubgroup = 0;
isMediaMenu = 1;
isFullscreen = 0;
if (getRecOK !== 2) { showDisplay("STOP", false, 100, 0 ); }
currMed = 0;
if (getRecOK) { showMediaList();}
mediaPlayer.addEventListener(mediaPlayer.ON_POSITION_CHANGED, ShowMediaOSD);
mediaPlayer.addEventListener(mediaPlayer.ON_STATE_CHANGED, onStateChanged);
}
function UnloadMediaSettings() {
mediaPlayer.removeEventListener(mediaPlayer.ON_POSITION_CHANGED, ShowMediaOSD);
mediaPlayer.removeEventListener(mediaPlayer.ON_STATE_CHANGED, onStateChanged);
medialist.style.opacity = 0;
osdmedia.style.opacity = 0;
osdmediatime.style.opacity = 0;
epg_unactive();
medialist.innerHTML = "Error : " + ev.state + "\n" + Lang[66] + ": " + ev.reason + "
" + Lang[0] + "
";
showDisplay(currChan.toString(), false, 100, 0 );
isMediaMenu = 0;
isFullscreen = 1;
isPause = 0;
set_yellow_key = 0;
localRecording = 0;
if (mediaPlayer.getState() != mediaPlayer.STATE_PLAYING ) {
play(channels[currChan]);
}
}
function onKeyMedia(keyCode) {
if (DelisOK) {
switch(keyCode) {
case "Enter": // OK key on frontpanel
case KEY_OK:
medialist.innerHTML = "" + Lang[0] + "
";
switchtimer.style.opacity = 0;
setTimeout("DelRec2(); getRecList(); showMediaList();",100)
default:
switchtimer.style.opacity = 0;
DelisOK = 0;
break;
} // end of switch
} else if (medialist.style.opacity != 0) {
switch(keyCode) {
case "BrowserBack":
if (subgroup && osdepginfo.style.opacity == 0) {
subgroup = 0;
subsubgroup = 0;
if (ShowSubDir) {
MakeRecList2();
} else {
MakeRecList();
}
setTimeout("showMediaList();",100)
break;
}
if (osdepginfo.style.opacity == 1) { epg_unactive(); break; }
case "TV":
UnloadMediaSettings();
break;
case "Yellow":
if (set_yellow_key) {
//hide/display schedule with same button
UnloadMediaSettings();
}
break;
case KEY_RIGHT:
if (getRecOK !== 0) {
for (var i=0;i<10;i++) {
do
{
incMed(1);
}
// while (!recTitl[currMed]);
while (!recList[currMed]);
}
showMediaList();
}
break;
case KEY_LEFT:
if (getRecOK !== 0) {
for (var i=0;i<10;i++) {
do
{
decMed(1);
}
// while (!recTitl[currMed]);
while (!recList[currMed]);
}
showMediaList();
}
break;
case KEY_DOWN:
if (getRecOK !== 0) {
do
{
incMed(1);
}
// while (!recTitl[currMed]);
while (!recList[currMed]);
showMediaList();
}
break;
case KEY_UP:
if (getRecOK !== 0) {
do
{
decMed(1);
}
// while (!recTitl[currMed]);
while (!recList[currMed]);
showMediaList();
}
break;
case "Enter": // OK key on frontpanel
case KEY_OK:
case "MediaPlayPause":
if (getRecOK == 2) {
ShowInfo();
osdepginfo.style.opacity = 1 - osdepginfo.style.opacity;
}
if (getRecOK == 1) {
if (recGroup[currMed] !== 0 && subgroup == 0 && ShowSubDir) {
if (subgroup_old) {
setTimeout("MakeRecList_sublevel(recGroup[currMed]); showMediaList();",100)
} else {
setTimeout("MakeRecList3(recGroup[currMed]); showMediaList();",100)
}
subgroup = 1;
} else if (recSubGroup[currMed] !== 0 && subgroup == 1 && subsubgroup == 0 && ShowSubDir && subgroup_old) {
setTimeout("MakeRecList_sublevel2(recGroup[currMed],recSubGroup[currMed]); showMediaList();",100)
subsubgroup = 1;
} else {
recList[currMed] = "\u0003" + recList[currMed].substring(1);
medialist.style.opacity = 0;
if (get_recordings == 1) {
if (initialDelayPlayID != -1) { clearTimeout(initialDelayPlayID); initialDelayPlayID = -1; }
setTimeout("GetMarks(); getResume(); playRec(recLink[currMed]+ '?mode=streamtoend&time=' + position);",100);
} else if (get_recordings == 2) {
// setTimeout("playRec(recLink[currMed]+ '?pos=resume');position = (mediaPlayer.getPosition()/1000);",100)
if (initialDelayPlayID != -1) { clearTimeout(initialDelayPlayID); initialDelayPlayID = -1; }
position = 0;
setTimeout("playRec(recLink[currMed]);",100)
}
}
}
break;
case "Red":
if (getRecOK == 1 && (recGroup[currMed] == 0 || subgroup == 1)) {
// Only delete item if it isn't a subdir marker
DelRec();
}
if (getRecOK == 2) { //set timer
settimer(recStrt[currMed],recTitl[currMed],recDura[currMed],1,color_switchtimer,recDesc[currMed],recGUID[currMed].toString());
}
break;
case "Blue":
// only show info if not a subdir marker or if in EPG mode
if ( (getRecOK == 1 && (recGroup[currMed] == 0 || subgroup == 1)) || getRecOK == 2) {
ShowInfo();
osdepginfo.style.opacity = 1 - osdepginfo.style.opacity;
}
break;
case "Green":
if (getRecOK == 2 && mediaRecorder) { //set timer only if mediaRecorder = 1, unit has harddisk
settimer(recStrt[currMed],recTitl[currMed],recDura[currMed],3,"",recDesc[currMed],recGUID[currMed].toString());
}
break;
case "VolumeMute":
VolumeMute();
break;
case "VolumeUp":
VolumeUp();
break;
case "VolumeDown":
VolumeDown();
break;
case KEY_REC:
case KEY_REC2:
// make timer for recording
if (getRecOK == 2) { //set timer
settimer(recStrt[currMed],recTitl[currMed],recDura[currMed],2);
ServerTimer(channels[currChan],recGUID[currMed]);
}
break;
case KEY_0:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only rewind file if it isn't a subdir marker
setResumeNull();
showMediaList();
}
break;
case KEY_1:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(1);
}
break;
case KEY_2:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(2);
}
break;
case KEY_3:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(3);
}
break;
case KEY_4:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(4);
}
break;
case KEY_5:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(5);
}
break;
case KEY_6:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(6);
}
break;
case KEY_7:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(7);
}
break;
case KEY_8:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(8);
}
break;
case KEY_9:
if (getRecOK == 1 && (recGroup[currMed] == 0 || recSubGroup[currMed] == 0 || subsubgroup == 1)) {
// Only do reccmds if it isn't a subdir marker
reccmds(9);
}
break;
default:
break;
} // end of switch
} else {
switch(keyCode) {
case "TV":
setResume();
play(channels[currChan]);
UnloadMediaSettings();
break;
break;
case KEY_DOWN:
if (mediaPlayer.getState() != mediaPlayer.STATE_PAUSED) {
showDisplay("PAUS", false, 100, 0 );
mediaPlayer.play(0);
}
break;
case KEY_UP:
if (mediaPlayer.getState() != mediaPlayer.STATE_PLAYING) {
if (currMed == -1 || localRecording == 1 ) {
showDisplay("PLAY", false, 100, 0 );
mediaPlayer.play(1000);
} else {
position += (mediaPlayer.getPosition()/1000);
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
}
}
break;
case "Enter": // OK key on frontpanel
case KEY_OK:
osdmedia.style.opacity = 1 - osdmedia.style.opacity;
osdmediatime.style.opacity = osdmedia.style.opacity;
ShowMediaOSD();
break;
case "Green":
if (audio_dyn < (lang_prio_dyn.length -1)) { audio_dyn += 1} else { audio_dyn = 0 }
if (lang_prio_dyn.length > 1) {
is.setObject("cfg.media.audio.languagepriority",lang_prio_dyn[audio_dyn] + "," + lang_prio[audio],is.STORAGE_PERMANENT);
osdlang.style.opacity = 1;
osdlang.innerHTML = "" + "
";
setTimeout("osdlang.style.opacity = 0; ", 3000);
}
break;
case "Yellow":
ShowSubs = 1 - ShowSubs;
videoplane.subtitles = Boolean(ShowSubs); // Enable subtitles or Disable subtitles
break;
case "Blue":
if ( isPause == 0 ) {
ShowInfo();
osdepginfo.style.opacity = 1 - osdepginfo.style.opacity;
}
break;
case "Red":
GetMarks();
ShowMediaOSD();
break;
case KEY_MENU:
epg_unactive();
osdmedia.style.opacity = 0;
osdmediatime.style.opacity = 0;
isSetupMenu = 1;
mainmenu.style.opacity = 0.8;
menu = 6;
InitMenu(menu);
break;
case "VolumeMute":
VolumeMute();
break;
case "VolumeUp":
VolumeUp()
break;
case "VolumeDown":
VolumeDown();
break;
case "MediaRewind":
if (mediaPlayer.getState() != mediaPlayer.STATE_IDLE) {
mediaPlayer.play(-4000);
showDisplay("REW", false, 100, 0 );
}
break;
case "MediaForward":
if (mediaPlayer.getState() != mediaPlayer.STATE_IDLE) {
mediaPlayer.play(4000);
showDisplay("FF", false, 100, 0 );
}
break;
case KEY_REC:
case KEY_REC2:
break;
case "BrowserBack":
case "MediaStop":
if (currMed == -1 || isPause == 1 || localRecording == 1) {
if (localRecording == 1) {
ss.setParameter(recDummy[0], "resume", mediaPlayer.getPosition().toString());
}
epg_unactive();
isFullscreen = 1; play(channels[currChan]);
UnloadMediaSettings();
} else {
setResume();
epg_unactive();
isFullscreen = 0; play(channels[currChan]); isFullscreen = 1;
medialist.style.opacity = 0.9;
showDisplay("STOP", false, 100, 0 );
showMediaList();
}
break;
case "MediaPlayPause":
if (mediaPlayer.getState() != mediaPlayer.STATE_PAUSED) {
showDisplay("PAUS", false, 100, 0 );
mediaPlayer.play(0);
} else {
if (currMed == -1 || localRecording == 1) {
showDisplay("PLAY", false, 100, 0 );
mediaPlayer.play(1000);
} else {
position += (mediaPlayer.getPosition()/1000);
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
}
}
break;
case KEY_1:
if (localRecording != 1 ) {
position += (mediaPlayer.getPosition()/1000) - 30;
if (position <= 0) { position = 0;}
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()-30000),1000);
}
break;
case KEY_4:
if (localRecording != 1 ) {
position += (mediaPlayer.getPosition()/1000) - 60;
if (position <= 0) { position = 0;}
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()-60000),1000);
}
break;
case KEY_7:
if (localRecording != 1 ) {
position += (mediaPlayer.getPosition()/1000) - 240;
if (position <= 0) { position = 0;}
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()-240000),1000);
}
break;
case KEY_5:
if (localRecording != 1 ) {
if (recMark.length>posMark && get_recordings == 1) {
position = recMark[posMark];
playRec(recLink[currMed] + "?mode=streamtoend&time=" + position);
}
}
break;
case KEY_2:
if (localRecording != 1 ) {
if (posMark>0 && get_recordings == 1) {
posMark -= 1;
position = recMark[posMark];
playRec(recLink[currMed] + "?mode=streamtoend&time=" + position);
}
}
break;
case KEY_8:
if (localRecording != 1 ) {
if (recMark[posMark+1] && get_recordings == 1) {
posMark++;
position = recMark[posMark];
playRec(recLink[currMed] + "?mode=streamtoend&time=" + position);
}
}
break;
case KEY_3:
if (localRecording != 1 ) {
setResume();
position += (mediaPlayer.getPosition()/1000) + 30;
if (get_recordings == 1) {
if (position >= recDura[currMed]) {
BackToTV();
} else {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
}
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()+30000),1000);
}
break;
case KEY_6:
if (localRecording != 1 ) {
setResume();
position += (mediaPlayer.getPosition()/1000) + 60;
if (get_recordings == 1) {
if (position >= recDura[currMed]) {
BackToTV();
} else {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
}
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()+60000),1000);
}
break;
case KEY_9:
if (localRecording != 1 ) {
setResume();
position += (mediaPlayer.getPosition()/1000) + 240;
if (get_recordings == 1) {
if (position >= recDura[currMed]) {
BackToTV();
} else {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
}
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition((mediaPlayer.getPosition()+240000),1000);
}
break;
case KEY_0:
if (localRecording != 1 ) {
position = 0; posMark = 0;
setResumeNull();
if (get_recordings == 1) {
playRec((recLink[currMed] + "?mode=streamtoend&time=" + position));
} else if (get_recordings == 2) {
playRec((recLink[currMed] + "?pos=time." + position));
}
} else {
mediaPlayer.playFromPosition(0,1000)
}
break;
default:
break;
} // end of switch
} // end of if
}
function getRecList() {
getVDRstatus();
MaxInGroup = 14;
subgroup = 0;
subsubgroup = 0;
try {
if (get_recordings ==1) {
// get recordings from smartTVWeb
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + recServ + recPath + "?" + new Date().getTime()),false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("item");
nrMedia = x.length - 1;
recTitl.length = 0;
rec_lst.length = 0;
if (recPath == "/recordings.xml") {
for (var i=0;i\n" + lang_prio_dyn[audio_dyn] + "
\n\n\n" + Lang[37] + "
";
}
} catch(e) {
alert("Get Recordings problem: " + e);
getRecOK = 0;
medialist.innerHTML = "" + Lang[38] + "
";
}
}
function GetMarks() {
if (get_marks==1) {
try {
posMark = 0;
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + recServ + "/getMarks.xml?guid=" + recGUID[currMed] + "&" + new Date().getTime()),false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
recMark = [];
var x=xmlDoc.getElementsByTagName("mark");
for (var i=0;i\n\n\n" + Lang[39] + "
" + Lang[44] + "," + Lang[45] + "\n\n" + recTitl[currMed] + "
"; // Recording Name
DelisOK = 1
} catch(e) {
alert("Delete Recordings problem: " + e);
}
}
function DelRec2() {
if (get_recordings == 1) {
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",(server_ip + recServ + "/deleteRecording.xml?id=" + recGUID[currMed] ),false);
xmlhttp.send();
recList[currMed] = "";
recGroup[currMed] = -1;
recProt[currMed] = 0;
} catch(e) {
alert("Delete Recordings problem: " + e);
}
} else if (get_recordings == 0) {
// try {
// xmlhttp=new XMLHttpRequest();
// xmlhttp.open("DELETE",(server_ip + RestFulAPI + "/recordings/" + recGUID[currMed] ),true);
// xmlhttp.send();
// recList[currMed] = "";
// recGroup[currMed] = -1;
// recProt[currMed] = 0;
// } catch(e) {
// alert("Delete Recordings problem: " + e);
// }
//
}
}
function MakeRecList() {
//old style list
var x = "";
var xx = "";
for (var i=0;i";
if (subgroup) {
htmlstring = "
" + Group_Header[Number(recGroup[currMed])] + "
";
if (MaxInGroup < 14){ MaxMed = MaxInGroup; } else {MaxMed = 14; }
}
if (!subgroup) {
for(var i=0; i<=nrMedia; i++) {
if (recList[i]) { MaxMed++;}
}
}
} else {
if (nrMedia < 14) {MaxMed = nrMedia; } else {MaxMed = 14; }
var htmlstring = "
" + Lang[11] + channelsnames[currChan] + "
";
}
if (MaxMed > 14) { MaxMed = 14; }
if (MaxMed < 0 ) { MaxMed = 0; }
for(var i=currMed; i<=currMed + MaxMed; i++) {
if (listMed>=nrMedia) { listMed= -1; }
if (listMed<-1) { listMed=nrMedia - 1; }
// if (listMed>nrMedia) { listMed= -1; }
do
{
listMed++;
}
while (!recList[listMed] && (listMed<=nrMedia));
if (listMed > nrMedia) { recList[listMed] = ""; }
if (recList[listMed]) { //Solves empty string at the end.
htmlstring += "\uE003";
if ( listMed == currMed) { htmlstring += ""; }
htmlstring += "\uE003" + recList[listMed] + "\uE003\uE003\n";
if ( listMed == currMed) { htmlstring += "";}
}
}
medialist.innerHTML = htmlstring + "
";
//ShowInfo();
}
function getServerSchedule() {
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + RestFulAPI + "/events/" + channels[currChan] + ".xml?timespan=" + serverEPGdays + "&" + new Date().getTime()),false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("event");
nrMedia = x.length - 1;
for (var i=0;i" + Lang[50] + "
";
}
}
function getSchedule(schchan){
SI = "";
recTitl.length = 0;
nrMedia = 0;
try {
StreamInfo(schchan);
eitService = toi.statics.ToiDvbEitCacheServiceItem.create(SI[1],SI[2],SI[3]);
eitCache.addService(eitService);
event = eitCache.getPresentEvent(eitService);
events = eitCache.getEvents(eitService, (Math.round(new Date().getTime()/1000.0)), 2000000000);
if (event.name) {
if (events.more) {
var t = eitCache.getEvents(eitService, (Math.round(new Date().getTime()/1000.0)), 2000000000);
events.infoSequence.concat(t.infoSequence);
events.more = t.more;
}
nrMedia = events.infoSequence.length - 1;
for (var i = 0; i < events.infoSequence.length; i++) {
// Double info or scrollbar twice on the screen if nrMedia < 14
while ((i > 0) && (events.infoSequence[i].eventId == events.infoSequence[(i-1)].eventId) && (nrMedia > 14)) {
recList[i] = "";
i++;
}
recTitl[i] = events.infoSequence[i].name;
recDesc[i] = eitCache.getExtendedEventInfo(eitService,events.infoSequence[i].eventId).extendedInfo;
if (recDesc[i] == "" ) { recDesc[i] = eitCache.getExtendedEventInfo(eitService,events.infoSequence[i].eventId).shortInfo;}
recDura[i] = events.infoSequence[i].duration;
recStrt[i] = events.infoSequence[i].time;
recChan[i] = schchan + "\uE003-\uE003" + channelsnames[schchan];
recGUID[i] = events.infoSequence[i].eventId;
date = new Date(Number(recStrt[i])*1000);
year = date.getFullYear();
month = date.getMonth();
d = date.getDate();
day = date.getDay();
h = date.getHours();
m = date.getMinutes();
h=addzero(h);
m=addzero(m);
recList[i] = ' ' + days[day] + ' ' + d + ' ' + months[month] + ' ' + year + " " + h + ":" + m + " (" + (recDura[i]/60).toFixed(0) + ") " + Left(recTitl[i],30);
}
getRecOK = 2;
} else {
getRecOK = 0;
medialist.innerHTML = "\n\n\n" + Lang[51] + "
" + Lang[11] + "
";
if (experimental) {
medialist.innerHTML += "\n\n\n" + Lang[52] + "
";
}
}
} catch(e) {
getRecOK = 0;
medialist.innerHTML = "
" + Lang[11] + "
";
}
}
function incMed(step) {
currMed += step;
if (currMed > nrMedia ) {
currMed = 0;
}
}
function decMed(step) {
currMed -= step;
if (currMed < 0) {
currMed = nrMedia;
}
}
function playRec(uri,posrec) {
try {
if (mediaPlayer.getState() != mediaPlayer.STATE_IDLE) {
mediaPlayer.close();
}
if (osdepginfo.style.opacity == 1) {epg_unactive();}
mediaPlayer.open(uri);
if (posrec) {
mediaPlayer.playFromPosition(posrec,1000);
} else {
mediaPlayer.play(1000);
}
showDisplay("PLAY", false, 100, 0 );
} catch (e) {
alert("Failed opening recording: " + e);
return;
}
}
function pauseRec(uri) {
try {
if (mediaPlayer.getState() != mediaPlayer.STATE_IDLE) {
mediaPlayer.close();
}
if (osdepginfo.style.opacity == 1) {epg_unactive();}
mediaPlayer.open(uri);
mediaPlayer.play(0);
showDisplay("PAUS", false, 100, 0 );
} catch (e) {
alert("Failed opening recording: " + e);
return;
}
}
function createNewAsset() {
try {
assetId = ams.createAsset(ams.ASSET_PVR);
// alert("Created " + assetId);
} catch(e) {
alert("Couldn't create asset: " + e);
}
}
function onStateChanged(ev) {
// alert("Media player state changed: state=" + ev.state + ", reason=" + ev.reason + ", code=" + ev.code);
if ( ( ev.state == 6 && ev.reason == "HostUnreachable" ) || ( ev.state == 2 && ev.reason == "PositionEnd" )) {
BackToTV();
}
}
// Start recording/ timeshift
function ServerRecordStart() {
//Record current program
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + recServ + "/addTimer?guid=" + channels[currChan] + "&" + new Date().getTime() ),false);
xmlhttp.send();
if (xmlhttp.responseXML == null) {
//settimer(EPG[NowNext][2][currChan],Lang[55],0,2);
//Timer not set, try direct recording
ServerRecord();
settimer(0,Lang[57],0,2);
} else {
settimer(EPG[NowNext][2][currChan],EPG[NowNext][1][currChan],0,2);
}
} catch(e) {
alert("Sending Timers to server problem: " + e);
settimer(0,Lang[55],0,2,color_error);
}
}
function ServerRecord() {
//Instant record on server
try {
xmlhttp=new XMLHttpRequest();
//switch server to current channel
xmlhttp.open("POST",(server_ip + RestFulAPI + "/remote/switch/" + channels[currChan]),true);
xmlhttp.send();
//start recording
setTimeout("xmlhttp.open('POST',(server_ip + RestFulAPI + '/remote/Record'),false);xmlhttp.send();",5000);
} catch(e) {
alert("Sending key to server problem: " + e);
settimer(0,Lang[55],0,2,color_error);
}
//end of function
}
function ServerPause() {
//Instant pause on server
ServerRecord();
settimer(EPG[NowNext][2][currChan],Lang[70],0,2);
setTimeout("getPauseFile();",6000);
//end of function
}
function ServerPowerDown() {
//Power Down Server
if (smartTVplugin) {
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open('GET',(server_ip + recServ + '/execcmd?cmd=' + PowerDown));
xmlhttp.send();
} catch(e) {
alert("Sending key to server problem: " + e);
settimer(0,Lang[55],0,2,color_error);
}
}
//end of function
}
function getPauseFile() {
try {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",(server_ip + RestFulAPI + "/recordings.xml?" + new Date().getTime()),false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("recording");
nrMedia = x.length - 1;
for (var i=0;i\n\n\n" + Lang[53] + "
\n " + (pos/60).toFixed(0) + " / " + x + " " + Left(recTitl[currMed],40) + "\n " + pos4 + "\n " + result + "
";
} else if ( get_recordings == 2) {
var pos = position + (mediaPlayer.getPosition()/1000);
date_time();
osdmediatime.innerHTML = "" + result + "";
osdmedia.innerHTML = " \n " + (pos/60).toFixed(0) + " \n " + Left(recTitl[currMed],40) + "\n \n " + recStrt[currMed] + "
";
}
}
function ShowInfo() {
//Like Show EPG Info
if ( medialist.style.opacity == 0 ) { updateStreamInfo(currMed);} else { AvInfo[currMed] = "";}
if (get_recordings == 2) {
result = recStrt[currMed]
osdepginfo.innerHTML = ""
+ "
"
+ "???" + Lang[54]
+ "
"
+ (recDura[currMed] / 60).toFixed(0) + Lang[54] + "
" + recChan[currMed]
+ "