int stopPlaylist(FILE * fp) { DEBUG("playlist: stop\n"); if(playerStop(fp)<0) return -1; playerCloseAudio(); playlist.queued = -1; playlist_state = PLAYLIST_STATE_STOP; playlist_noGoToNext = 0; if(playlist.random) randomizeOrder(0,playlist.length-1); return 0; }
int playPlaylistOrderNumber(FILE * fp, int orderNum) { if(playerStop(fp)<0) return -1; playlist_state = PLAYLIST_STATE_PLAY; playlist_noGoToNext = 0; playlist.queued = -1; playlist_queueError = 0; DEBUG("playlist: play %i:\"%s\"\n",orderNum, getSongUrl(playlist.songs[playlist.order[orderNum]])); if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])) < 0) { stopPlaylist(fp); return -1; } else playlist.current++; playlist.current = orderNum; return 0; }
VideoPlayer::VideoPlayer(QString programPath, QWidget *parent) : QWidget(parent) ,programDir(programPath) ,WIDTH(600) ,HEIGHT(380) ,videoNameWidth(300) ,videoListWidth(200) ,hideButtonsTime(2000) ,forwardStep(5) ,retreatStep(5) ,volumnChangeStep(5) ,hideCursor(false) ,keepAwakeTimes(0) { //设置窗口无边框 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); this->installEventFilter(this); //初始化窗口位置、大小 QDesktopWidget desktop; setGeometry((desktop.width()-WIDTH)/2, (desktop.height()-HEIGHT)/2, WIDTH, HEIGHT); setObjectName("videoPlayer"); //背景label lab_background = new QLabel(this); lab_background->setGeometry(0, 0, WIDTH, HEIGHT); lab_background->setObjectName("lab_background"); // videoList = new VideoList(0, 25, videoListWidth, this->height()-50, false, this); // videoList->show(); //设置鼠标跟踪,响应鼠标移动事件 this->setMouseTracking(true); lab_background->setMouseTracking(true); // videoWidget = new VideoWidget; videoWidget->hide(); videoWidget->installEventFilter(this); videoWidget->setMouseTracking(true); //保持视频屏幕常亮 helpKeepAwake = new HelpKeepAwake; //布局 layout_top = new QGridLayout; layout_top->addWidget(lab_background, 0, 0, 1, 1); layout_top->addWidget(videoWidget, 0, 0, 1, 1); layout_top->setSpacing(0); layout_top->setMargin(0); this->setLayout(layout_top); // videoContral = new VideoContral(this); videoContral->setGeometry(this->x(), this->y(), this->width(), this->height()); tbn_openVideoFile = new QToolButton(this); tbn_openVideoFile->setText("放入视频"); tbn_openVideoFile->setGeometry((this->width()-126-32)/2+35, (this->height()-41)/2+95, 80, 30); tbn_openVideoFile->setObjectName("tbn_openVideoFile"); //初始化多媒体播放器 player = new QMediaPlayer(this); QMediaPlaylist *playlist = new QMediaPlaylist; QMediaPlaylist *playlistHistory = new QMediaPlaylist; playlist_list.append(playlistHistory); playlist_list.append(playlist); player->setVideoOutput(videoWidget); player->setPlaylist(playlist); player->setVolume(60); connect(tbn_openVideoFile,SIGNAL(clicked()), this, SLOT(openVideoFile())); connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); /* connect(this, SIGNAL(moveWindow(QPoint)), videoList, SLOT(toMoveWindow(QPoint)));*/ //设置样式表 setStyleSheet( "#videoPlayer{" // "border-radius: 3px;" "}" "#lab_background{" // "border-radius: 3px;" "border-image: url(:/Images/videoPlayerBg.png);" "}" "#tbn_openVideoFile{" "background: rgba(0, 0, 0, 30);" "color: rgba(200, 255, 255, 255);" "}" ); //创建定时器(1.5秒无鼠标动作按钮自动隐藏) timerHideWidgets = new QTimer(this); timerHideWidgets->start(hideButtonsTime); connect(timerHideWidgets, SIGNAL(timeout()), this, SLOT(hideWidgets_timeout())); //操作控制 connect(videoWidget, SIGNAL(clicked()), this, SLOT(videoPlayPause())); connect(videoWidget, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen())); // connect(videoWidget, SIGNAL(goForward()), this, SLOT(videoGoForward())); // connect(videoWidget, SIGNAL(retreat()), this, SLOT(videoRetreat())); connect(videoWidget, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int))); connect(videoWidget, SIGNAL(volumnAdd()), this, SLOT(volumnAdd())); connect(videoWidget, SIGNAL(volumnReduce()), this, SLOT(volumnReduce())); connect(videoContral, SIGNAL(isHideWidget(bool)), this, SLOT(isHideWidget(bool))); connect(videoContral, SIGNAL(playerStop()), player, SLOT(stop())); connect(videoContral, SIGNAL(playPause()), this, SLOT(videoPlayPause())); connect(videoContral, SIGNAL(playNext()), player->playlist(), SLOT(next())); connect(videoContral, SIGNAL(currentMediaEnd()), this, SLOT(currentMediaEnd())); // connect(videoContral, SIGNAL(goForward()), this, SLOT(videoGoForward())); // connect(videoContral, SIGNAL(retreat()), this, SLOT(videoRetreat())); connect(videoContral, SIGNAL(playJump(int)), this, SLOT(videoPlayJump(int))); connect(videoContral, SIGNAL(switchFullScreen()), this, SLOT(switchFullScreen())); connect(player, SIGNAL(durationChanged(qint64)), videoContral, SLOT(durationChanged(qint64))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(setVideoTitle())); connect(player, SIGNAL(positionChanged(qint64)), videoContral, SLOT(positionChanged(qint64))); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playStateChanged(QMediaPlayer::State))); // connect(videoContral, SIGNAL(itemDoubleClicked(int, int)), this, SLOT(itemDoubleClicked(int, int))); // videoWidget->setFocus(); timerKeepAwake = new QTimer(this); connect(timerKeepAwake, SIGNAL(timeout()), this, SLOT(timeoutKeepAwake())); }
int deleteFromPlaylist(FILE * fp, int song) { int i; int songOrder; if(song<0 || song>=playlist.length) { commandError(fp, ACK_ERROR_NO_EXIST, "song doesn't exist: \"%i\"", song); return -1; } if(playlist_state==PLAYLIST_STATE_PLAY) { if(playlist.queued>=0 && (playlist.order[playlist.queued]==song || playlist.order[playlist.current]==song)) { lockPlaylistInteraction(); clearPlayerQueue(); unlockPlaylistInteraction(); } } if(playlist.songs[song]->type == SONG_TYPE_URL) { freeJustSong(playlist.songs[song]); } playlist.idToPosition[playlist.positionToId[song]] = -1; /* delete song from songs array */ for(i=song;i<playlist.length-1;i++) { moveSongFromTo(i+1, i); } /* now find it in the order array */ for(i=0;i<playlist.length-1;i++) { if(playlist.order[i]==song) break; } songOrder = i; /* delete the entry from the order array */ for(;i<playlist.length-1;i++) playlist.order[i] = playlist.order[i+1]; /* readjust values in the order array */ for(i=0;i<playlist.length-1;i++) { if(playlist.order[i]>song) playlist.order[i]--; } /* now take care of other misc stuff */ playlist.songs[playlist.length-1] = NULL; playlist.length--; incrPlaylistVersion(); if(playlist_state!=PLAYLIST_STATE_STOP && playlist.current==songOrder) { /*if(playlist.current>=playlist.length) return playerStop(fp); else return playPlaylistOrderNumber(fp,playlist.current);*/ playerStop(stderr); playlist_noGoToNext = 1; } if(playlist.current>songOrder) { playlist.current--; } else if(playlist.current>=playlist.length) { incrPlaylistCurrent(); } if(playlist.queued>songOrder) { playlist.queued--; } return 0; }
bool _d2Run::Update(float Lag) { vector<item>::iterator inventoryIt; if(ticksDiff > 0.35f) { if( beltPotionsRejuve.size() < 8) { if( inventoryPotionsRejuve.size() > 0) { if( transferItem.Id == 0) { for(inventoryIt = inventoryPotionsRejuve.begin(); inventoryIt != inventoryPotionsRejuve.end(); inventoryIt++) { if(inventoryIt->pickupAttempted == false) { transferItem = *inventoryIt; inventoryIt->Id = 0; Core->itemToBelt( transferItem ); inventoryIt->pickupAttempted = true; ticksEnd = GetTickCount(); return true; } } // for } else { // transferItem.id == 0 transferCount++; if(transferCount > 10) { transferItem.Id = 0; ticksEnd = GetTickCount(); return true; } ticksEnd = GetTickCount(); return true; } } // inventoryPotions } } // ticksDiff >0.2 if(waitTimer && ticksDiff > 0.10f) { waitTimer--; ticksEnd = GetTickCount(); return true; } // 0 is right hand if(skillTargetID[0] != 0 || skillTargetID[1] != 0) { // Check our skills // Right Hand if(skillCurrentID[0] != skillTargetID[0]) { if(skillCounter[0]++ == 0) { Core->SkillSelect( skillTargetID[0], false); ticksEnd = GetTickCount(); } else { if(skillCounter[0] > 1000) { skillCounter[0] = 0; //Core->GameOver("Right Skill change failed!", true); } return true; } attackRecast = false; return true; } // skillCurrentID[0] // Left Hand if(skillCurrentID[1] != skillTargetID[1]) { if(skillCounter[1]++ == 0) { Core->SkillSelect( skillTargetID[1], true); ticksEnd = GetTickCount(); } else { if(skillCounter[1] > 1000) { skillCounter[1] = 0; //Core->GameOver("Left Skill change failed!", true); } return true; } attackRecast = false; return true; } //skillCurrentID[1] } // TargetIDs != 0 if(ticksDiff > 0.20f && pickItems.size() > 0 && pickTime && pickingItem.Id == 0) { if(pickupTele && !teleporting) pickupTele = false; if(!teleporting && !pickupTele) if(itemsPickup()) { ticksEnd = GetTickCount(); return true; } } if(groundItems.size() > 0 || pickingItem.Id) { item Item; if(pickupTele && !teleporting) pickupTele = false; if(ticksDiff > 0.20f && !teleporting && !pickupTele) { if(pickingItem.Id == 0) { for(size_t i = 0; i < groundItems.size(); i++) { // Need to clear this flag at the end of the monster waves if(groundItems[i].pickupAttempted) continue; strTmp.str(""); strTmp << "Picking Up "; if( !Item.Id ) if(groundItems[i].BaseItem == "rvl") { if(inventoryPotionsRejuve.size() < 5) { Item = groundItems[i]; strTmp << "Rejuvination Potion"; if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) { Item.Id = 0; teleSet( Item.Pos.xPos, Item.Pos.yPos, false ); pickupTele = true; return true; } } } if( !Item.Id && beltPotionsHealth.size() < 4) if(groundItems[i].BaseItem == "hp5") { Item = groundItems[i]; strTmp << "Health Potion"; if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) { Item.Id = 0; continue; } } if( !Item.Id && beltPotionsMana.size() < 4) if(groundItems[i].BaseItem == "mp5") { Item = groundItems[i]; strTmp << "Mana Potion"; if(!Core->WithinRangePick( Item.Pos.xPos, Item.Pos.yPos ) ) { Item.Id = 0; continue; } } if(Item.Id) { groundItems[i].pickupAttempted = true; pickedItem = false; pickingItem = Item; Core->pickItem( Item ); Core->Debug(2, strTmp.str()); ticksEnd = GetTickCount(); return true; } } // for } else { // pickingItem != 0 pickItemFailed++; ticksEnd = GetTickCount(); if(pickItemFailed > 5) { //if(groundItems.size()) //groundItemRemove(pickingItem.Id); pickingItem.Id = 0; return true; } return true; } } // ticksDiff > 0.20 if(pickingItem.Id != 0) return true; } // groundItems.size if(ticksDiff > 0.24f || walkComplete || (teleportFirstStep && !cta)) { if(followBots) { map<DWORD, _d2Player>::iterator Player; if(followMode == 0) { //if(publicMode) playersMuteAll(false); } // flowMode = 0 //if(followMode == 1) //Core->SpeakToAll("1"); if(followAllow) if(followMode == 2) Core->SpeakToAll("follow"); if(followMode == 3) Core->SpeakToAll("precast"); //if(followMode == 4) // Core->SpeakToAll("!bo"); // Check all bounds just incase if(followMode >= 4 || followMode < 0) { followMode = 0; followBots = false; } followMode++; ticksEnd = GetTickCount(); return true; } // followBots if(Running) { if(purchasing && purchaseComplete) { if(purchaseAmount--) { purchaseComplete = false; shoppingPurchasing = true; Core->TownPurchaseItem( unitMalah, purchaseItem, false ); ticksEnd = GetTickCount(); return true; } else { stepTown++; purchasing = false; shoppingPurchasing = false; ticksEnd = GetTickCount(); return true; } } else if (purchasing && !purchaseComplete) {// purchasing return true; } if(!town && cta) { CTARun(); ticksEnd = GetTickCount(); return true; } // !town && cta // CTAing before out of town if(town && cta) { if(currentStep == 0) { Core->GameOver("CTA in town!", false); return true; } else town = false; } if(portalCasting) { // Make it wait 3 seconds before rechucking if(!portalCast || ticksDiff > 4.0f) { portalCast = true; ThrowTP(); } //ticksEnd = GetTickCount(); return true; } // portalCasting } // Running if(interacting) { currentLevel = GetCurrentLevel(); if(currentLevel) if(currentLevel->dwLevelNo == LevelTarget) { Sleep(100); if(cMap.GenerateMap() == false) return true; Core->AllowPlayerReassign(); playerStop(); currentStep++; groundItems.clear(); LevelTarget = 0; interacting = false; interactingCount = 0; } else interactingCount++; if(interactingCount > 5) { Core->Debug(0, "Interaction failed"); interactingCount = 0; interacting = false; } free(currentLevel); ticksEnd = GetTickCount(); return true; } // Interacting if(Running && walking) { if(walkComplete) { walkComplete = false; if(walkStep == 0) { Core->playerMove( walkSteps[walkStep].X, walkSteps[walkStep].Y ); ticksEnd = GetTickCount(); return true; } } else { walkFailCounter++; if(walkFailCounter > 6) { walkFailCounter = 0; walkStep++; if(walkSteps[walkStep].X == 0) { walkComplete = false; walkStep--; Hero->posX = walkSteps[walkStep].X; Hero->posY = walkSteps[walkStep].Y; playerStop(); Core->playerMove(walkSteps[walkStep].X, walkSteps[walkStep].Y); walkCompleted(walkSteps[walkStep].X, walkSteps[walkStep].Y ); ticksEnd = GetTickCount(); return true; } } if(walkFailCounter == 0 || walkFailCounter == 5 || walkFailCounter == 10 || walkFailCounter == 15) Core->playerMove( walkSteps[walkStep].X, walkSteps[walkStep].Y ); walkComplete = false; ticksEnd = GetTickCount(); } return true; } // Running/Walking if(teleporting || teleportMoving) { if(ticksDiff > 0.30f || teleportFirstStep) { teleportFirstStep = false; if(teleStep >= teleSteps) { teleportTimeout++; if(( teleSteps > 1 && teleportTimeout > 150) || (teleportTimeout > 250)) { Core->Debug(0, "Teleport Timeout"); teleportTimeout = 0; teleStep = teleportCompleted + 1; teleFail++; if(telePath[ teleStep ].x == 0 || telePath[ teleStep ].y == 0) { teleStep--; if(teleStep < 0) teleStep = 0; } teleportMoving = true; if(teleFail > 3) { Core->Debug(0, "Teleport Failed"); teleporting = false; teleportMoving = false; teleportCompleted = 0; teleFail = 0; if(teleAbort) { gameTeleTimeout++; Core->GameOver("Teleporting Failed!", true); } return true; } return true; } else return true; } //telestep if(!teleportMoving) { teleportTimeout++; if(teleportTimeout > 300) { teleportTimeout = 0; //teleporting = false; teleportMoving = true; teleStep = teleportCompleted + 1; } return true; } if(telePath[ teleStep ].x == 0 || telePath[ teleStep ].y == 0) { //teleporting = false; teleportMoving = false; // This basically means we are waiting for us to arrive at our destination //teleSteps = 0; teleFail++; if(teleFail >= 3) { Core->Debug(0, "Teleport Failed"); teleporting = false; teleportMoving = false; teleportCompleted = 0; teleStep = 0; teleFail = 0; } return true; } Core->RightSkillFire( (WORD) telePath[ teleStep ].x, (WORD) telePath[ teleStep ].y ); teleStep++; ticksEnd = GetTickCount(); } // ticksdiff return true; } // teleporting if(ticksDiff > 0.30f) { if(town) { Running = true; Town(); ticksEnd = GetTickCount(); return true; } // Town } // ticksDiff (0.30) } float ticksDiffStart; ticksDiffStart = ((float) (ticksStartup - ticksEnd)) / 1000; if(ticksDiffStart > 10.0f) { if(firstLoad) { EnableDebugPriv(); if(!cMap.InitMemory("Diablo II", D2WindowTitle)) { //Quit = true; //Paused = true; //Core->Debug(0, "Init memory Failed!"); return true; } else { firstLoad = false; return true; } } currentLevel = GetCurrentLevel(); if(currentLevel) { if(currentLevel->dwLevelNo == 109) { // 109 = harrogath town = true; } else { if(town) firstTownLeave = true; town = false; } free(currentLevel); if(town && (currentStep > 0)) { if(realmCreateNewGame == true) return true; if(!manualMode) Core->GameOver("Found ourselves in town mid run!", true); Running = false; return true; } } } else // ticksdiffstart ticksEnd = GetTickCount(); return false; }